Skip to main content

Building Triggers

Triggers can be either built manually or using Data Orchestrator Dashboard's Trigger Editor. Trigger Editor dynamically loads installed Interfaces in the Realm and eases trigger creation by providing not only linting and validation, but also dynamic resolution of Interface names.

Trigger Editor works in a very similar fashion to Interfaces Editor, and shares the same User Interface.

Format​

A trigger is described using a JSON document. Each trigger is defined by two main parts: condition and action.

This is a JSON representation of an example trigger:

{
"name": "example_trigger",
"action": {
"http_url": "https://example.com/my_hook",
"http_method": "post"
},
"simple_triggers": [
{
"type": "data_trigger",
"on": "incoming_data",
"interface_name": "org.astarte-platform.genericsensors.Values",
"interface_major": 0,
"match_path": "/streamTest/value",
"value_match_operator": ">",
"known_value": 0.4
}
]
}

The condition is represented by the simple_triggers array. In this release, Data Orchestrator supports only a single entry in the simple_triggers array, but support for multiple simple triggers (and different ways to combine them) is planned for future releases.

The condition in the example specifies that when data is received on the org.astarte-platform.genericsensors.Values interface on /streamTest/value path, if the value of said data is > 0.4, then the trigger is activated. For more information about all the possible conditions, check out the Conditions section.

The action object describes what the result of the trigger will be. In this specific case, an HTTP POST request will be sent to https://example.com/my_hook, with the payload:

{
"timestamp": "<event_timestamp>",
"device_id": "<device_id>",
"event": {
"type": "incoming_data",
"interface": "org.astarte-platform.genericsensors.Values",
"path": "/streamTest/value",
"value": <some_value>
}
}

To know more about all possible actions, check the Actions section.