Docs / Strand / workflow-editor/conditional-logic
Conditional Logic
Create branching, filtering, and iteration with the Logic node.
Edges are always traversed: they have no conditions or relationship types. All conditional routing is done with a Logic node's handles.
Using the Logic Node#
The Logic node provides built-in conditional branching with visual outputs:
If/Else Mode#
- Add a Logic node to your workflow
- Set mode to "If/Else"
- Enter a Jinja2 condition (e.g.,
payload.temperature > 25) - Connect the if output (blue, bottom-left) to the "true" path
- Connect the else output (purple, bottom-right) to the "false" path
┌─────────────┐
Input --> │ Logic │
│ (If/Else) │
└──────┬──────┘
│
┌────────┴────────┐
│ │
[if] [else]
│ │
▼ ▼
[Send Alert] [Log Normal]
Filter Mode#
Use Filter mode to allow or block events based on a Python condition:
- Add a Logic node
- Set mode to "Filter"
- Write Python code that returns
TrueorFalse - Events that return
Truecontinue; others are dropped
See Logic Node for full documentation.
Branching on Connector Results#
Connectors don't raise an error on a failed call; they return a { success, status, data } envelope (see Connector Output Structure). Branch on it with an If/Else Logic node:
{{ payload.success }}
Route the if handle (success) and else handle (failure) to different paths.
A node that raises a hard failure is logged, marked failed, and its downstream edges are not traversed. There is no "on error" route; that branch simply stops. Most nodes return an envelope instead of raising: the HTTP Request node returns success: false on a 4xx or 5xx and lets the run continue, so route on payload.success rather than expecting a failure. It only raises for statuses you list in its response.error_on_status.
Complex Conditions#
You can use complex Jinja2 expressions in Logic node conditions:
payload.user.role == 'admin' and steps.auth_check.output_payload.verified
(steps.api_call.output_payload | jsonpath('$.items[?(@.active == true)]')) | length > 0
Best Practices#
- Branch with Logic nodes - all conditional routing happens here, never on edges
- Use clear, descriptive conditions
- Test both branches
- Handle edge cases (null values, missing fields)
- Use the
defaultfilter for safe access:(payload.value | default(0)) > 25
Related#
- Logic Node - Full Logic node documentation
- Jinja2 Syntax - Expression syntax
Tendrl