Docs / Strand / workflow-editor/conditional-logic

Conditional Logic

Create branching, filtering, and iteration with the Logic node.

Branching lives in the Logic node, not on edges

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

  1. Add a Logic node to your workflow
  2. Set mode to "If/Else"
  3. Enter a Jinja2 condition (e.g., payload.temperature > 25)
  4. Connect the if output (blue, bottom-left) to the "true" path
  5. Connect the else output (purple, bottom-right) to the "false" path
code

                ┌─────────────┐
     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:

  1. Add a Logic node
  2. Set mode to "Filter"
  3. Write Python code that returns True or False
  4. Events that return True continue; 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:

jinja

{{ payload.success }}

Route the if handle (success) and else handle (failure) to different paths.

A raised failure halts the branch

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:

jinja

payload.user.role == 'admin' and steps.auth_check.output_payload.verified
jinja

(steps.api_call.output_payload | jsonpath('$.items[?(@.active == true)]')) | length > 0

Best Practices

  1. Branch with Logic nodes - all conditional routing happens here, never on edges
  2. Use clear, descriptive conditions
  3. Test both branches
  4. Handle edge cases (null values, missing fields)
  5. Use the default filter for safe access: (payload.value | default(0)) > 25