Registers a boolean condition function and attaches it to triggers via condition_function_id so handlers only fire when the condition passes. Use when gating triggers on business rules, checking user permissions, validating data before processing, filtering high-value orders, rate-limiting events, or conditionally skipping handlers based on payload content.
Comparable to: Middleware guards, event filters
Use the concepts below when they fit the task. Not every trigger needs a condition.
true or false)truecondition_function_id in the trigger configWhen a trigger fires, the engine first invokes the condition function with the event data. If the condition returns true, the handler executes normally. If false, the handler is skipped silently with no error or retry.
| Primitive | Purpose |
|---|---|
registerFunction(id, handler) (condition) | Register the condition function (returns boolean) |
registerFunction(id, handler) (handler) | Register the handler function |
registerTrigger({ type, function_id, config: { condition_function_id } }) | Bind trigger with condition gate |
See ../references/trigger-conditions.js for the full working example — a condition-gated trigger where a business rule function filters events before the handler processes them.
Also available in Python: ../references/trigger-conditions.py
Also available in Rust: ../references/trigger-conditions.rs
Code using this pattern commonly includes, when relevant:
registerFunction('conditions::is-high-value', async (input) => input.new_value?.amount >= 1000) — condition functionregisterFunction('orders::notify-high-value', async (input) => { ... }) — handler functionregisterTrigger({ type: 'state', function_id: 'orders::notify-high-value', config: { scope: 'orders', key: 'status', condition_function_id: 'conditions::is-high-value' } }) — bind with conditiontrue — handler executesfalse — handler is skipped silentlyconditions:: prefix for condition function IDs to keep them organizedUse the adaptations below when they apply to the task.
trigger() internally to check state or other functionsiii-functions-and-triggers.iii-state-reactions.iii-trigger-actions.iii-trigger-conditions when the primary problem is gating trigger execution with a condition check.iii-trigger-conditions in the iii engine.