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.
Some nodes raise a hard failure instead of returning an envelope; for example, the HTTP Request node treats a 4xx/5xx response as a node failure. A raised failure is logged, the node is marked failed, and its downstream edges are not traversed. There is no "on error" route; that branch simply stops. To branch on an HTTP result instead of halting, call the API through a connector that returns the success/status envelope.
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