Skip to main content

Events: Creating a Context-Based Alert

Learn how to trigger an event using the context of a variable.

Written by Sergio M

Take full advantage of your operation’s data by setting up events that trigger based on the context of your variables.

Requirements

  • Account with an active plan.

1. Creating an event with a context-based trigger

1.1. Triggers

To begin, head to the “data” tab →"Events" and hover over the “+” button, located at the upper right corner of the screen, and create a conditional event, global event, or scheduled event depending on your needs.

Once the event modal pops up, you’ll find yourself in the first stage of configuration, where you’ll set up the logic of the triggers. This is where we’ll configure our context-based alert.

1. Click on the “+ add trigger” or “+ add OR group” buttons and select “context based”. By default, a newly created event loads with a value-based trigger created, but you can either delete or configure it as well if it fits your needs.

2. Select one variable per conditional expression. Multiple variables can be added using AND (“+ add trigger”)/OR (“+ add OR group”) conditionals.

3. Enter the context key you want to track. Keep in mind that this field is case sensitive, so make sure you enter the exact key that is sent to your variable’s context.

4. Select the data type of the context key value. The "Data type" dropdown lets you specify how the key's value should be interpreted:

  • String (default): Values are compared as plain text. This is the behavior for all existing events.

  • Number: Values are parsed as numeric (integer or decimal). Use this when your context payload carries sensor readings or counts.

  • Boolean: Values are matched as true/false. Use this for on/off flags or binary states.

5. Define the condition of the trigger. These vary depending on the "data type" selected in the previous step.

String:

  • Is: Triggers if the value exactly matches.

  • Contains: Triggers if the value partially contains the text.

  • Is not: Triggers if the value is anything other than the text defined.

Number:

  • Is: Triggers if the parsed numeric value equals the configured number.

  • Is not: Triggers if the parsed numeric value differs from the configured number.

  • Greater than: Triggers if the value is strictly above the configured number.

  • Greater than or equal to: Triggers if the value is equal to or above the configured number.

  • Less than: Triggers if the value is strictly below the configured number.

  • Less than or equal to: Triggers if the value is equal to or below the configured number.

Boolean:

  • Is: The only available condition. Matching is case-insensitive ("true", "True", and "TRUE" all match True; same for False). Values like "1", "0", "yes", or "on" do not match.

6. Enter the key value that will dictate the triggering of the event.

  • String: Free-text input, case-sensitive.

  • Number: Numeric input only.

  • Boolean: The free-text field is replaced by a dropdown with True and False (True pre-selected).

Note: If your selected data type is "string", then this field is case sensitive, so make sure you enter the exact value that is sent to your variable’s context. This is true even when the condition is set to “contains”.

7. Finally, define after how long the event will activate if the previously configured conditions continue to be true.

If you leave this option at the default “0”, then, as soon as your device receives a context payload that matches your trigger configuration, the event will be activated. If, for example, you choose 5 minutes here, then the event will only activate if the last context payload received still matches your conditions; on the other hand, if the device receives a context payload with a different key value to the one defined after 4 minutes, the event won’t be activated.

Based on the previous idea, it makes sense to define this time according to the rate at which the variable is updated.

1.2. Actions

After finishing all the steps in the “triggers” tab and clicking on “next”, you’ll move onto the “actions” tab. There, you’ll be able to select and configure the action that will be triggered when the event is activated.

  1. Click on the “+ add action” button to start this process. These are the options you can choose from:

For a detailed explanation on how each of the actions work and how to configure them, visit their respective article (linked above).

1.3. Settings

After completing the action configuration and clicking on “next”, you’ll proceed to the final step, the “settings” tab. There, you’ll identify your event and define its active windows.

  1. Start this stage by naming your event and, optionally, giving it a description so that it’s easy to distinguish from other events later on.

  2. Another optional step is to use a tag on the event. This is a great tool to control what your end users see in your app. In this case, for instance, you could decide that your end user sees one event, but not another, using tags. Learn more about tags here.

  3. Determine the activity window in which the events should be executed. An event can have multiple active windows by clicking on the “+ add window button” and configuring them correspondingly. To learn more about how and when an event is activated, head to this guide.

Did this answer your question?