Skip to content

Commit 56b1dc1

Browse files
committed
DOCS-4389: Add triggers examples to top
1 parent b26c748 commit 56b1dc1

File tree

7 files changed

+85
-55
lines changed

7 files changed

+85
-55
lines changed

docs/data-ai/_index.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ You can also monitor your machines through teleop, power your application logic,
3939
{{< cards >}}
4040
{{% card link="/data-ai/data/query/" noimage="true" %}}
4141
{{% card link="/data-ai/data/visualize/" noimage="true" %}}
42-
{{% card link="/data-ai/data/advanced/alert-data/" noimage="true" %}}
42+
{{% card link="/data-ai/data/alert-data/" noimage="true" %}}
4343
{{% card link="/data-ai/data/export/" noimage="true" %}}
4444
{{< /cards >}}
4545
{{< /how-to-expand >}}

docs/data-ai/data/advanced/_index.md

Lines changed: 0 additions & 9 deletions
This file was deleted.

docs/data-ai/data/advanced/alert-data.md renamed to docs/data-ai/data/alert-data.md

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
---
22
linkTitle: "Trigger on data events"
33
title: "Trigger on data events"
4-
weight: 60
4+
weight: 200
55
layout: "docs"
66
type: "docs"
77
description: "Use triggers to send email notifications or webhook requests when data from the machine is synced."
88
date: "2025-09-12"
9+
aliases:
10+
- /data-ai/data/advanced/alert-data/
911
---
1012

1113
You can use triggers to send webhooks or email alerts when data syncs from a machine.
@@ -74,7 +76,7 @@ You can configure triggers to fire in the following scenarios:
7476

7577
The following JSON configuration shows how to set up a trigger that fires when any data is synced to the cloud:
7678

77-
```json {class="line-numbers linkable-line-numbers" data-line="32-49"}
79+
```json {class="line-numbers linkable-line-numbers" data-line="32-54"}
7880
{
7981
"components": [
8082
{

docs/data-ai/reference/triggers-configuration.md

Lines changed: 77 additions & 40 deletions
Original file line numberDiff line numberDiff line change
@@ -6,29 +6,45 @@ type: "docs"
66
tags: ["data management", "trigger", "webhook"]
77
description: "Detailed information about how to configure triggers and webhooks."
88
date: "2025-05-05"
9+
updated: "2025-09-18"
910
---
1011

11-
Triggers can alert you by email or webhook when the following events occur:
12+
Triggers can alert you by email or webhook when any of the following events occur:
1213

1314
- [machine telemetry data syncs from your local device to the Viam cloud](/manage/troubleshoot/alert/)
14-
- [data syncs from a machine](/data-ai/data/advanced/alert-data/)
15+
- [data syncs from a machine](/data-ai/data/alert-data/)
1516
- [service detects a specified object or classifies a specified label](/data-ai/ai/alert/)
1617

17-
## Trigger attributes
18+
This page provides a reference for the Trigger attributes.
19+
For step-by-step configuration information, see the links above instead.
1820

19-
Triggers support the following attributes:
21+
## JSON configuration templates
2022

21-
<!-- prettier-ignore -->
22-
| Name | Type | Required? | Description |
23-
| ---- | ---- | --------- | ----------- |
24-
| `name` | string | **Required** | The name of the trigger |
25-
| `event` | object | **Required** | The trigger event object, which contains the following fields: <ul><li>`type`: The type of the event to trigger on. Options: `part_data_ingested`, `conditional_data_ingested`.</li><li>`data_types`: Required with `type` `part_data_ingested`. An array of data types that trigger the event. Options: `binary`, `tabular`, `file`, `unspecified`. </li><li> `conditional`: Required when `type` is `conditional_data_ingested`. For more information about this field, see [Conditional attributes](/data-ai/reference/triggers-configuration/#conditional-attributes). </li></ul> |
26-
| `notifications` | object | **Required** | The notifications object, which contains the following fields: <ul><li>`type`: The type of the notification. Options: `webhook`, `email`</li><li>`value`: The URL to send the request to or the email address to notify.</li><li>`seconds_between_notifications`: The interval between notifications in seconds.</li></ul> For more information on webhooks, see [Webhook attributes](#webhook-attributes). |
27-
| `notes` | string | Optional | Descriptive text to document the purpose, configuration details, or other important information about this trigger. |
23+
### Part status trigger template
24+
25+
The following template demonstrates the structure of a JSON configuration for a trigger that alerts when a part is online or offline:
26+
27+
```json {class="line-numbers linkable-line-numbers"}
28+
"triggers": [
29+
{
30+
"name": "<trigger name>",
31+
"event": {
32+
"type": "part_online|part_offline"
33+
},
34+
"notifications": [
35+
{
36+
"type": "webhook|email",
37+
"value": "<webhook URL or email address>",
38+
"seconds_between_notifications": <number of seconds>
39+
}
40+
]
41+
}
42+
]
43+
```
2844

2945
### Data sync trigger template
3046

31-
The following template demonstrates the form of a JSON configuration for a trigger that alerts when data syncs to the Viam cloud:
47+
The following template demonstrates the structure of a JSON configuration for a trigger that alerts when data syncs to the Viam cloud:
3248

3349
```json {class="line-numbers linkable-line-numbers"}
3450
"triggers": [
@@ -51,31 +67,9 @@ The following template demonstrates the form of a JSON configuration for a trigg
5167
]
5268
```
5369

54-
## Conditional attributes
55-
56-
The `conditional` object for the `conditional_data_ingested` trigger type includes the following attributes:
57-
58-
<!-- prettier-ignore -->
59-
| Name | Type | Required? | Description |
60-
| ---- | ---- | --------- | ----------- |
61-
| `data_capture_method` | string | **Required** | The method of data capture to trigger on. <br> Example: `sensor:<name-of-component>:Readings`. |
62-
| `conditions` | object | Optional | Conditions that, when true, fire the trigger. Evaluated each time data syncs from the linked component. When this object is empty or not present, the trigger fires each time data syncs from the linked component. <br> Options: <ul><li>`evals`:<ul><li>`operator`: Logical operator for the condition. </li><li>`value`: An object containing a single field and value. The field specifies the path, in the synced data, to the left operand of the conditional. For nested fields, use periods as separators or define the nested structure in JSON. The value specifies an object, string, boolean, regular expression, or integer used as a right operand in the conditional. </li></ul></li></ul> |
63-
64-
The `operator` attribute supports the following values:
65-
66-
| Name | Description |
67-
| ------- | -------------------------- |
68-
| `lt` | less than |
69-
| `gt` | greater than |
70-
| `lte` | less than or equal to |
71-
| `gte` | greater than or equal to |
72-
| `eq` | equal to |
73-
| `neq` | not equal to |
74-
| `regex` | matches regular expression |
75-
7670
### Conditional trigger template
7771

78-
The following template demonstrates the form of a JSON configuration for a conditional trigger:
72+
The following template demonstrates the structure of a JSON configuration for a conditional trigger:
7973

8074
```json {class="line-numbers linkable-line-numbers"}
8175
"triggers": [
@@ -106,6 +100,40 @@ The following template demonstrates the form of a JSON configuration for a condi
106100
]
107101
```
108102

103+
## Trigger attributes
104+
105+
Triggers support the following attributes:
106+
107+
<!-- prettier-ignore -->
108+
| Name | Type | Required? | Description |
109+
| ---- | ---- | --------- | ----------- |
110+
| `name` | string | **Required** | The name of the trigger |
111+
| `event` | object | **Required** | The trigger event object, which contains the following fields: <ul><li>`type`: The type of the event to trigger on. Options: <ul><li>`part_data_ingested`: fire when data syncs</li> <li>`conditional_data_ingested`: fire when data that meets a certain condition syncs</li> <li>`part_online`: fire when the part is online</li> <li>`part_offline`: fire when the part is offline</li></ul></li><li>`data_types`: Required with `type` `part_data_ingested`. An array of data types that trigger the event. Options: `binary`, `tabular`, `file`, `unspecified`. </li><li> `conditional`: Required when `type` is `conditional_data_ingested`. For more information about this field, see [Conditional attributes](/data-ai/reference/triggers-configuration/#conditional-attributes). </li></ul> |
112+
| `notifications` | object | **Required** | The notifications object, which contains the following fields: <ul><li>`type`: The type of the notification. Options: `webhook`, `email`</li><li>`value`: The URL to send the request to or the email address to notify.</li><li>`seconds_between_notifications`: The interval between notifications in seconds.</li></ul> For more information on webhooks, see [Webhook attributes](#webhook-attributes). |
113+
| `notes` | string | Optional | Descriptive text to document the purpose, configuration details, or other important information about this trigger. |
114+
115+
## Conditional attributes
116+
117+
The `conditional` object for the `conditional_data_ingested` trigger type includes the following attributes:
118+
119+
<!-- prettier-ignore -->
120+
| Name | Type | Required? | Description |
121+
| ---- | ---- | --------- | ----------- |
122+
| `data_capture_method` | string | **Required** | The method of data capture to trigger on. <br> Example: `sensor:<name-of-component>:Readings`. |
123+
| `conditions` | object | Optional | Conditions that, when true, fire the trigger. Evaluated each time data syncs from the linked component. When this object is empty or not present, the trigger fires each time data syncs from the linked component. <br> Options: <ul><li>`evals`:<ul><li>`operator`: Logical operator for the condition. </li><li>`value`: An object containing a single field and value. The field specifies the path, in the synced data, to the left operand of the conditional. For nested fields, use periods as separators or define the nested structure in JSON. The value specifies an object, string, boolean, regular expression, or integer used as a right operand in the conditional. </li></ul></li></ul> |
124+
125+
The `operator` attribute supports the following values:
126+
127+
| Name | Description |
128+
| ------- | -------------------------- |
129+
| `lt` | less than |
130+
| `gt` | greater than |
131+
| `lte` | less than or equal to |
132+
| `gte` | greater than or equal to |
133+
| `eq` | equal to |
134+
| `neq` | not equal to |
135+
| `regex` | matches regular expression |
136+
109137
### Example
110138

111139
The following condition defines a trigger that fires based on the value of the `cpu` field of synced data:
@@ -168,7 +196,7 @@ The following sensor reading fires the trigger, since `40 < 50` is `true`:
168196

169197
### Request types
170198

171-
When an event occurs, Viam sends a HTTP request to the URL you specified for the trigger:
199+
When an event occurs, Viam sends an HTTP request to the URL you specified for the trigger:
172200

173201
<!-- prettier-ignore -->
174202
| Trigger type | HTTP Method |
@@ -189,7 +217,7 @@ The request includes the following headers:
189217
| `Organization-Name` | The name of the organization that triggered the request. | `part_online`, `part_offline` |
190218
| `Location-Id` | The location of the machine that triggered the request. | all |
191219
| `Location-Name` | The location of the machine that triggered the request. | `part_online`, `part_offline` |
192-
| `Part-Id` | The part of the machine that triggered the request. | all |
220+
| `Part-Id` | The part of the machine that triggered the request. | all |
193221
| `Machine-Name` | The name of the machine that triggered the request. | `part_online`, `part_offline` |
194222
| `Robot-Id` | The ID of the machine that triggered the request. | all |
195223

@@ -205,11 +233,10 @@ The request body includes the following data:
205233
| `method_name` | The name of the method from which data was ingested. | `part_data_ingested`, `conditional_data_ingested` |
206234
| `min_time_received` | Indicates the earliest time a piece of data was received. | `part_data_ingested` |
207235
| `max_time_received` | Indicates the latest time a piece of data was received. | `part_data_ingested` |
208-
| `method_name` | The name of the method that triggered the request. | `conditional_data_ingested` |
209236
| `machine_name` | The name of the machine that triggered the request. | `part_data_ingested`, `conditional_data_ingested` |
210237
| `location_name` | The location of the machine that triggered the request. | `part_data_ingested`, `conditional_data_ingested` |
211238
| `org_name` | The name of the organization that triggered the request. | `part_data_ingested`, `conditional_data_ingested` |
212-
| `file_id` | The id of the file that was ingested. | `part_data_ingested` |
239+
| `file_id` | The ID of the file that was ingested. | `part_data_ingested` |
213240
| `trigger_condition` | The condition that triggered the request. | `conditional_data_ingested` |
214241
| `data` | The ingested sensor data. Includes `metadata` with `received_at` and `requested_at` timestamps and `data` in the form `map[string]any`. | `part_data_ingested`, `conditional_data_ingested` (sensor data) |
215242

@@ -222,7 +249,7 @@ The following example function prints the received headers:
222249
{{< tabs >}}
223250
{{% tab name="Flask" %}}
224251

225-
```python {class="line-numbers linkable-line-numbers" }
252+
```python {class="line-numbers linkable-line-numbers"}
226253
from flask import Flask, request
227254

228255
app = Flask(__name__)
@@ -309,3 +336,13 @@ def hello_http(request):
309336

310337
{{% /tab %}}
311338
{{< /tabs >}}
339+
340+
### Troubleshooting
341+
342+
If the HTTP request Viam sends results in an error, you can see this error logged in the machine logs.
343+
344+
For example:
345+
346+
```txt
347+
9/18/2025, 12:52:59 PM error app.trigger.trigger-1     Trigger failed to notify https://testurl.com for robotPartId abc1234d-1a23-1a23-123a-1abc23d45e67. Component: N/A, Method: N/A, TriggerType: part_online, NotificationType: webhook, Error: received unretryable status code: 404 in webhook response, ResponseCode: 404
348+
```

docs/dev/reference/changelog.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -736,7 +736,7 @@ You can visualize any data, such as sensor readings, that you have [synced](/dat
736736

737737
{{% changelog date="2024-01-31" color="added" title="Use triggers to trigger actions" %}}
738738

739-
You can now configure [triggers](/data-ai/data/advanced/alert-data/) (previously called webhooks) to execute actions when certain types of data are sent from your machine to the cloud.
739+
You can now configure [triggers](/data-ai/data/alert-data/) (previously called webhooks) to execute actions when certain types of data are sent from your machine to the cloud.
740740

741741
{{% /changelog %}}
742742

docs/operate/mobility/use-input-to-act.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ Other common inputs include the methods of a [board](/dev/reference/apis/compone
5353
You can also use camera input, for example to detect objects and pick them up with an arm.
5454
See [Act based on inferences](/data-ai/ai/act/) for relevant examples.
5555

56-
If you want to send alerts based on computer vision or captured data, see [Alert on inferences](/data-ai/ai/alert/) or [Alert on data](/data-ai/data/advanced/alert-data/).
56+
If you want to send alerts based on computer vision or captured data, see [Alert on inferences](/data-ai/ai/alert/) or [Alert on data](/data-ai/data/alert-data/).
5757

5858
{{% /tablestep %}}
5959
{{% tablestep %}}

netlify.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@
5757
[plugins.inputs]
5858

5959
# change this key to a new one any time you need to restart from scratch
60-
cacheKey = ["Sep102025"]
60+
cacheKey = ["Sep182025"]
6161
# either "warn" or "error"
6262
failBuildOnError = true
6363

0 commit comments

Comments
 (0)