Skip to main content

Logic And Routing

What this category is for

Use these nodes to make branching decisions, validate payloads, choose route-specific behavior at runtime, and iterate over collections.

Node list table

Node typePurposeKey inputsBranch outputs
condition_nodeEvaluates ordered JavaScript boolean expressions and picks the first matching output.Config conditions[] (condition, output), default_outputdynamic (configured), typically default fallback
validate_nodeValidates a value against JSON Schema and routes by validity.Config schema (required), input valuevalid, invalid
switch_nodeMatches a single evaluated value against cases and routes to case output.Config value_expression, cases[], default_outputdynamic (configured), typically default fallback
loop_nodeEvaluates an array expression; Loop output runs the body once per element; Done runs after all iterations.Config array_expression, optional max_iterations (current element is always item / $json['$item'])Edges: sourceHandle loop / done; output results, count

Common patterns

1) Request contract gate

  • http_trigger -> validate_node
  • valid -> business flow
  • invalid -> response_node with 400 and validation_errors

2) HTTP status routing

  • proxy_node or http_request_node -> switch_node
  • value_expression = {{ $json['node_id'].response.status_code }}
  • Cases: 200, 404, 429 to separate handling branches

3) Business policy routing

  • condition_node with ordered rules:
    • High-risk path
    • Privileged client path
    • Default standard path
  • Stop evaluation on first true condition

4) Multi-step validation

  • Schema validation in validate_node
  • Then condition_node for semantic checks that JSON Schema cannot express easily

5) Batch per-item work

  • http_triggerloop_node with array_expression pointing at request.body.items (or similar)
  • Loop → http_request_node (or set_node, code_node) using $json['$item'] / $json['$index'] in inputs
  • Loop → response_node returning {{ $json['loop_1'].results }} (replace node id)

Common mistakes and how to debug

  • Expression format mismatch: switch_node.value_expression uses wrapped expressions ({{ ... }}), while condition_node.condition is plain JavaScript expression text.
  • No branch connected for selected output: node may set matched_output, but workflow has no edge for that source handle. Verify edge handles exactly match output names.
  • Invalid schema object: validate_node returns invalid with schema compile errors. Validate schema independently first, then paste.
  • Case typing confusion in switch_node: comparison is string-based (fmt.Sprint). Match literal values as strings in cases.
  • Default branch overused: if all traffic goes to default, inspect evaluated value and upstream node IDs referenced in expressions.
  • Loop node: array_expression must evaluate to an array; exceeding max_iterations fails the run. Inside the body, use $json['$item'] / $json['$index'] / $json['$loop'] (see Loop Node).