Welcome to Portal

?Unknown\pull-down

Welcome to Zoho Cares

Bienvenido a Soporte de Zoho

Search our knowledge base, ask the community or submit a request.

Triggers & Events

Triggers are configured to invoke function blocks when specific events occur in the application or Zoho service. For example, you can trigger a welcome email to a user when your extension is installed. The mail notification function is configured in the trigger called extension-install so that the user receives your welcome mail when they install your extension. These events are broadly categorized into: extension life cycle events, service specific events, and user created custom events. You can view the list of default events from Trigger Events.

Extension life cycle events

These events are directly associated with the extension. You can create a trigger for an extension installed event or based on any other extension event.

extension_on_run 

This event is triggered when you click Run  to test your extension. 

extension_on_stop

This event is triggered when you disable development mode to run your extension.

extension_installed

This event is triggered when you install an extension. 
For instance, You can trigger a function to execute a webhook that connects the third party app (Zendesk). Write a function to configure a webhook and use this event to execute that trigger automatically whenever a user installs your extension.

extension_uninstalled

This event is triggered whenever your extension is uninstalled. Use this trigger to remove the configuration or pre-setup activities done during set up in target applications.

extension_disabled

This event is triggered whenever your extension is disabled.

extension_enabled

This event is triggered whenever your extension is enabled.

extension_updated

This event is triggered whenever your extension is updated. For example, consider you want to install a set of security packs whenever your extension is enabled. Build a function for security updates and name it as DoSecurityUpdate. Create a trigger for extension_updated event and associate the function with this trigger event.

extension_upgraded

This event is triggered when a user upgrades to a paid version of your extension.

Service events

These events are specific to the service that you make use of. For example, if you are creating extensions for Zoho Projects then following are some service specific events: create_bug, delete_bug, update_task etc. You can write functions for specific events as per your business needs and trigger the events when required. Service specific events are fixed and it varies based on the service which you make use of to create extensions.

Custom Events 

Sigma allows you to create your own customized events along with the existing service events. The newly added custom events can then be associated with triggers in Sigma.

Add trigger to your function 

  1. Navigate to the  Extension module and hover over your extension and click
  2. Navigate to Triggers and click  Add Trigger
  3. Enter a name for your trigger and select the event to trigger.  
  4. Associate a function to your trigger. 
  5. Choose the corresponding version.  
  6. Click Create

 

Edit trigger associated with an extension

  1. Navigate to Extensions , hover over your extension and click .
  2. Go to the Triggers tab.
  3. Click (...) beside the corresponding trigger.
  4. Click Edit.
  5. Make necessary changes to the trigger.
  6. Click Update.

Delete trigger associated with an extension

  1. Navigate to Extensions, hover over your extension and click .
  2. Go to the Triggers tab.
  3. Click the (...) beside the corresponding trigger.
  4. Click Delete.

Trigger will be permanently deleted and can't be retrieved.

Add Custom Events 

Say you don’t want to use the predefined events, then use custom events to trigger your function. 
  1. Navigate to the  Extension module and hover over your extension and click
  2. Navigate to Triggers and click Add Trigger
  3. Enter a name for your trigger. 
  4. Click Add Custom Event.  You can also choose an existing one.
  5. Enter a name for your custom event and click the tick icon on the right.
  6. Associate a function to your trigger. You can associate up to 5 different functions.
  7. Select the corresponding version to be associated. 
  8. Click Create.         


Executing Custom Triggers using API

Custom Triggers are triggers associated with custom events in Sigma. Sigma allows you to execute triggers associated with custom events via API. This can further be used in the webhooks of third-party services.
 
The custom event must be called by the developer using the below Custom Trigger execution API:
  1. POST    https://<APP UUID>.sigmaexecution.com/workspace/invokecustomtrigger
 
To execute a Sigma function, use *.sigmaexecution domain.
Note: This functionality is currently supported only for Orchestly and Zoho Projects' extensions.

Business Case

Zoho Projects already hosts service events like create_bug, delete_bug, update_task etc. If you want to create additional events like create milestone or update timesheet, you can create custom triggers. The created trigger can be used to invoke webhooks to access information from or to third-party services.
 

Parameters

* refers to mandatory fields

Name
Type
Description
auth_type *
String
Authentication type.
encapiKey *
String
Encrypted API key. Note that this must be encoded if tried on Postman API.
sigma_custom_event_uuid *
String
ID of the custom event to be executed.
integ_scope_id *
Long
Portal ID of the Zoho Service.
app_install_id*
Long
Installation ID of the extension.

Request Body

Only JSON and XML content types are allowed in request body. The data passed in the request body will be passed to all functions associated in the Custom Trigger as a payload.  To get the payload inside the DRE function use the command data.get("payload") .
 

Response

Success
  1. {
  2.     "message": "Custom trigger has been added to the queue",
  3.     "status": true
  4. }
 
Failure
  1. {
  2.     "message": "Error in adding Custom Trigger to the queue",
  3.     "status": false
  4. }
 

How to construct Custom Trigger URL in DRE Function?

    Developers can construct Custom Trigger URL inside a DRE function and register it as a webhook in third party services.

  1. info "Constructing Custom Trigger URL in DRE function"
  2. cutsomEventUUID = "86ea3e04-6e0d-4b04-a434-1ee949712909";
  3. invokeCustomTriggerURL = "https://" + data.get("sigma_execution_domain") + "/workspace/invokecustomtrigger?sigma_custom_event_uuid="+cutsomEventUUID+"&integ_scope_id="+data.get("integ_scope_id")+"&app_install_id="+data.get("app_install_id")+"&auth_type=apikey&encapiKey="+data.get("encapiKey”);

  4. info "use the invokeCustomTriggerURL to register webhook on third-party tool"
 

How to execute Custom Trigger using DRE Function?

    Use the below sample Deluge function to execute the Custom Trigger using DRE.

  1. info "Invoking Custom Trigger";
  2. customTriggerExecutionURL = "https://" + data.get("sigma_execution_domain") + "/workspace/invokecustomtrigger";
  3. executeParams = Map();
  4. executeParams.put("sigma_custom_event_uuid", "86ea3e04-6e0d-4b04-a434-1ee949712909");
  5. executeParams.put("integ_scope_id", data.get("integ_scope_id"));
  6. executeParams.put("app_install_id", data.get("app_install_id"));
  7. executeParams.put("auth_type", "apikey");
  8. executeParams.put("encapiKey", data.get("encapiKey"));
  9. executionResponse = invokeurl
  10. [
  11.  url: customTriggerExecutionURL
  12.  type: POST
  13.  parameters: executeParams
  14. ];
  15. info "Custom Trigger execution Response : " + executionResponse;

Helpful?21
Updated: 1 year ago
Share :