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
- Navigate to the Extension module and hover over your extension and click .
- Navigate to Triggers and click Add Trigger.
- Enter a name for your trigger and select the event to trigger.
- Associate a function to your trigger.
- Choose the corresponding version.
- Click Create.
Edit trigger associated with an extension
- Navigate to Extensions , hover over your extension and click .
- Go to the Triggers tab.
- Click (...) beside the corresponding trigger.
- Click Edit.
- Make necessary changes to the trigger.
- Click Update.
Delete trigger associated with an extension
- Navigate to Extensions, hover over your extension and click .
- Go to the Triggers tab.
- Click the (...) beside the corresponding trigger.
- 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.
- Navigate to the Extension module and hover over your extension and click .
- Navigate to Triggers and click Add Trigger .
- Enter a name for your trigger.
- Click Add Custom Event. You can also choose an existing one.
- Enter a name for your custom event and click the tick icon on the right.
- Associate a function to your trigger. You can associate up to 5 different functions.
- Select the corresponding version to be associated.
- 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:
- 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
- {
- "message": "Custom trigger has been added to the queue",
- "status": true
- }
Failure
- {
- "message": "Error in adding Custom Trigger to the queue",
- "status": false
- }
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.
- info "Constructing Custom Trigger URL in DRE function"
- cutsomEventUUID = "86ea3e04-6e0d-4b04-a434-1ee949712909";
- 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”);
- 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.
- info "Invoking Custom Trigger";
- customTriggerExecutionURL = "https://" + data.get("sigma_execution_domain") + "/workspace/invokecustomtrigger";
- executeParams = Map();
- executeParams.put("sigma_custom_event_uuid", "86ea3e04-6e0d-4b04-a434-1ee949712909");
- executeParams.put("integ_scope_id", data.get("integ_scope_id"));
- executeParams.put("app_install_id", data.get("app_install_id"));
- executeParams.put("auth_type", "apikey");
- executeParams.put("encapiKey", data.get("encapiKey"));
- executionResponse = invokeurl
- [
- url: customTriggerExecutionURL
- type: POST
- parameters: executeParams
- ];
- info "Custom Trigger execution Response : " + executionResponse;