Previous
Export data
You can use triggers to send alerts by email or webhook when data syncs from a machine. For example, a trigger could alert you when a sensor detects a temperature greater than 100 degrees Celsius.
You can configure triggers to alert in the following scenarios:
Go to the CONFIGURE tab of your machine on the Viam app. Click the + (Create) button in the left side menu and select Trigger.
Enter a name and click Create.
In the Type dropdown, choose one of the following types:
Data has been synced to the cloud: Whenever your machine syncs data of any of the specified data types, the trigger sends an alert. Then, select the data types for which the trigger should send requests.
Conditional data ingestion: Whenever your machine syncs data that meets certain criteria, the trigger sends an alert.
Choose the target component and method for your condition.
Add a condition: specify a key in the synced data, an operator, and a value. When data from the target component and method syncs from your machine, the trigger uses the key as a path to look up a value in the synced data object. The trigger applies the operator to the extracted value and the value you specified in your condition.
For example, the following trigger sends an alert when the cpu-monitor
component’s Readings
method syncs cpu
usage greater than 50
:
For more information, see Conditional attributes.
To add a notification method, add an entry to the Webhooks or Email sub-panels:
To add an email notification:
Click Add Email.
Add the email you wish to be notified whenever this trigger is triggered.
Configure the time between notifications.
To add a webhook notification:
Click Add Webhook.
Add the URL of your cloud function.
Configure the time between notifications.
Write your cloud function to process the webhook. Use your cloud function to process data or interact with any external API, including Twilio, PagerDuty, or Zapier.
To configure your trigger in JSON mode, use the following JSON template:
{
"components": [
{
"name": "local",
"model": "pi",
"api": "rdk:component:board",
"attributes": {},
"depends_on": []
},
{
"name": "my_temp_sensor",
"model": "bme280",
"api": "rdk:component:sensor",
"attributes": {},
"depends_on": [],
"service_configs": [
{
"type": "data_manager",
"attributes": {
"capture_methods": [
{
"method": "Readings",
"additional_params": {},
"capture_frequency_hz": 0.017
}
]
}
}
]
}
],
"triggers": [
{
"name": "trigger-1",
"event": {
"type": "part_data_ingested",
"data_ingested": {
"data_types": ["binary", "tabular", "file"]
}
},
"notifications": [
{
"type": "webhook",
"value": "<https://1abcde2ab3cd4efg5abcdefgh10zyxwv.lambda-url.us-east-1.on.aws>",
"seconds_between_notifications": 0
}
]
}
]
}
For more information about triggers, see Trigger Configuration.
Was this page helpful?
Glad to hear it! If you have any other feedback please let us know:
We're sorry about that. To help us improve, please tell us what we can do better:
Thank you!