In this blog, we will see how to handle event triggers using formulas in Open connectors.
Use Case: To get an email update whenever an message is posted in a specific Slack Channel. We can reuse this formula steps to any events using open connectors.
Step 1: Create Connector Instance
Create and authenticate Slack Instance from Open connectors and enable “Events” to enable Event web hooks.
Step 2: Create Formulas to handle event.
- From “Formulas” in open connectors lets create a formula to handle the events triggered by the above connector instance.
- Enter a formula name and click “Create”
- Create “Variables” so that we can reuse the same formula for various instances.
Type : Connector instance
- Click on the “trigger” to add trigger details and Select “Event Trigger”. In the Connector Instance Variable, select the variable we created in previous step. Click “Save” and “confirm”.
- In next step, we must collect the data related to the event trigger . To collect data, we must connect to the connector and get the data for that “particular event”. Add Step and select “Connector API Request”.
- Give Appropriate name for the step
- Select the connector variable created and above step
- As we are collecting data for the trigger, we can select “GET”.
- For Connector resource URL, We can get the URL from the “API Docs” of the connector instance.
- As we want to events related a specific channel, we can choose the appropriate URL.
- The connector instance url should be as shown in image below.
- Save step and add it to the formula flow.
- Create a “Variable” to pass the required email IDs for the mail.
Type “ String”
- We will use Java script step to send email to the required contacts.
Data : Pick data from the “getEventData” step.
Subject : Create variable to use expressions to dynamically decide the subject.
IDs : use the variable created in above step.
The final formula will have 3 steps.
Step 3 : Create Formula Instance
Once all the required steps are added in the formula, we must create Formula instance to allow the formula to run . Assign the Slack Instance to the Connector variable and add the required email details to email variable.
Step 4 : Debug
We can debug our formula using the “Try it out” option.
- Select the “Instance” and “Trigger” details to run the data. We can view the trigger details from “Event Logs” option under “Activity”.
- Click “Run” to see the data flow and we can see the various variables associated with the flow too.
Now, we will get an email notification whenever someone post a message in our specific channel.
Note : An app should be created in SLACK and Event API should be enabled to push data from SLACK to the Web Hook URL mentioned in the Open Connector instance.