With DataSet's webhook trigger, we can trigger IoT workflows using DataSet's alerting engine. This will allow you to trigger just about anything imaginable from patterns within TBs of event data.
Though this technique is not limited to a single platform, and should work on a multitude of platforms that catch webhooks, this article will teach you how to do this in Zapier.
In this article, we will:
- Setup a DataSet alert. https://www.youtube.com/watch?v=dUIwVyrF33I
- Connect it to a Zapier workflow
- Trigger an IoT workflow that will send a text message to a user
Prerequisites:
- DataSet account (paid)
- Zapier account (paid)
Steps:
1. Zapier
- Create a new Zap
- Set the trigger to "Webhooks by Zapier"
- Set the "Trigger Event" option to "Catch Raw Hook"
- Take note of the "Webhook URL" this will be our DataSet Alert webhook address
- Skip to the DataSet section (2) and continue those instructions. Resume Step 6 AFTER you have completed the DataSet section (2).
-
Continue If you successfully triggered an alert and sent it to the Webhook URL, click "Continue" and "Test Trigger"
- If the alert fired, you will see test data.
- Press "Continue" then set an action.
- From here you can pretty do whatever you want. Read, Write, Update or Delete data from or to other systems. In this example we will process the JSON response with a bit of python, then send an SMS
- Set "Action" to "Code by Zapier" and Event to "Run Python"
- Run a basic script to process the JSON
- The output will convert the string to objects interpreted by Zapier.
- Send your data somewhere. In this case I am just using "SMS by Zapier" but you can do pretty much whatever you want here.
2. DataSet
- Create a new alert. (Check out our alerting series if you want a deep dive into the alerting engine)
- We can modify the alert via the UI or JSON. For this example, we will use JSON. See the following JSON. (this will alert if the latency defined in timeMs exceeds 7500ms)
{
alertAddress: "webhook-trigger:POST URL[[BODY]]",
description: "Delays over 7.5s",
renotifyPeriodMinutes: 60,
resolutionDelayMinutes: 5,
trigger: "count:2 minutes(timeMs > 7500) > 0",
gracePeriodMinutes: ""
}, - For the alertAddress add the webhook address we copied from step 1.4
{
alertAddress: "webhook-trigger:POST https://hooks.zapier.com/hooks/catch/xxxxxxxxx/yyyyyyyyyy/[[\"key\":\"value1\",\"trigger\":\"#trigger#\",\"description\":\"#description#\", \"title\":\"#title#\", \"link\": \"#link#\", \"id\": \"#id#\"]]",
description: "Delays over 7.5s",
renotifyPeriodMinutes: 0,
resolutionDelayMinutes: 5,
trigger: "count:2 minutes(timeMs > 7500) > 0",
gracePeriodMinutes: ""
}, - In the [[BODY]] section add static data like "key":"value" or dynamic data including Template Parameters or Substitution Tokens. You can send text, but I am formatting JSON
Token Replaced by #trigger# The trigger expression that determines when the alert fires. #description# The description you've specified for the alert. If absent, the trigger expression is used. #title# The first line of the description. #link# A link to the alert. #id# A short token identifying the alert. - Trigger the alert. - You need to trigger to provide Zapier test data. In my test I just changed the trigger to something that will always be true like timeMs > 1 to get test data then changed it to the original threshold. We need test data to continue in zapier
- Finish in Zapier. Go to step 1.6
Comments
0 comments
Please sign in to leave a comment.