Skip to main content

Switch node

The Switch node allows creating multiple branchings based on the value of a variable.

Parameters​

ParameterTypeRequiredDefaultDescription
VariableHandlebars variable✅—Value to evaluate to route to a branch.
CasesList✅—List of the matching cases and their associated branches.
If the variable matches none of the casesChoice✅—Mandatory choice: An error is thrown or Setting up a default path.

Variable​

Variable to evaluate:

  • Context variable: {{status}}
  • Property of an object: {{order.status}}
  • Result of a node: {{lastResponse.data.type}}

The reference is written with or without double braces (context.status or {{context.status}}) New. Handlebars highlighting is shown in both cases.

Cases​

Define the different cases:

  • Case 1: Value to compare (e.g. "pending")
  • Case 2: Another value (e.g. "processing")
  • Case 3: Another value (e.g. "completed")

If the variable matches none of the cases​

Required field with two choices:

  • An error is thrown
  • Setting up a default path — by default, a default branch is created

Input​

The node receives the value of a variable from the workflow context — trigger data, an object property or the result of a previous node — and compares it to the defined cases.

Output​

The node produces no value in the context: it routes the execution to the corresponding branch.

  • The branch whose case matches the variable value is executed
  • If no match: either an error is thrown, or the default path branch is executed

Errors​

If the variable matches none of the cases and the An error is thrown option is chosen, an error interrupts the workflow execution. To handle the failure cleanly, add an On Error node to the workflow.

Example​

The node is used to:

  • Route to different branches according to a value
  • Implement a switch/case type logic
  • Handle several scenarios
  • Create dynamic workflows

Example 1: Route according to the status​

Variable: {{order.status}}

Cases:

  • "pending" → Process pending orders
  • "processing" → Track the processing
  • "completed" → Finalize
  • If the variable matches none of the cases → An error is thrown

Example 2: Route according to the type​

Variable: {{event.type}}

Cases:

  • "order.created" → Create the order
  • "order.updated" → Update
  • "order.cancelled" → Cancel
  • If the variable matches none of the cases → Setting up a default path (ignore)

See also​