Skip to main content

Goal

Run a condition Function before a Trigger runs, and only execute the handler Function when the condition passes.

Steps

1. Register the handler and condition Functions

Register a normal handler Function and a condition Function that returns true or false.
Both Functions are declared in the same way. They only differ in how they are used.
conditions-functions.ts

2. Register triggers with the correct condition key

Create a Trigger and specify its condition with condition_function_id. Example (state trigger):
state-trigger-with-condition.ts

Result

When the trigger fires, iii calls the condition Function first. The handler Function runs only when the condition passes.