The Switch node evaluates a single expression once, then routes to the first case whose value matches. If nothing matches, it takes the Default branch.
Use Switch when you are routing on a value (status, type, decision). Use Condition when you need boolean checks (score >= 90, items.length > 0).
How it works
┌─ case "paid" → Branch A
Start → … → Switch ─┼─ case "pending" → Branch B
└─ default → Branch C
Each case (and Default) has its own output handle. Connect a downstream node to each path you care about.
Switch on
Switch on is a JavaScript expression. It is evaluated once in the same sandbox as Condition nodes, then compared to each case value.
Available in the expression:
| Name | Meaning |
|---|---|
lastOutput | Output of the previous node |
inputs | Original trigger / start payload |
variables | Workflow variables |
context | Prior node outputs keyed by node id |
You can also insert {{…}} templates (Variables button), same as elsewhere in the editor.
Examples
lastOutput.status
lastOutput.decision
inputs.eventType
context['ai-classify'].output.category
{{lastOutput.sentiment}}
The default when you add a Switch node is lastOutput (the whole previous output). Prefer a field path like lastOutput.status so case values stay simple strings.
Matching rules
- Evaluate Switch on → get a value.
- Coerce that value to a string (
null/undefined→""; objects →JSON.stringify). - Walk cases in order; first case where
String(caseValue) === String(switchValue)wins. - If none match, take Default.
Case values are plain text you type in the panel (e.g. paid, PASS, customer_action) — not expressions.
Configuring cases
| Field | Behavior |
|---|---|
| Case | Label (optional) + match value (required) |
| Default | Runs when no case matches |
Add cases with Add Case. Connect each handle on the canvas to the correct next step.
Example — route AI decision
After an AI node returns { decision: "PASS" | "HOLD" | "CUSTOMER_ACTION" }:
Switch on: lastOutput.decision
Case: PASS → Notify CSR for approval
Case: CUSTOMER_ACTION → Ask guest for missing docs
Case: HOLD → Escalate internally
Default: → Log unexpected value
Switch vs Condition
| Switch | Condition | |
|---|---|---|
| Input | One expression → one value | Boolean expressions per branch |
| Branches | Case values + Default | If / Else If / Else |
| Best for | Status / enum / fixed labels | Ranges, compound checks (a && b) |
Tips
- Always keep a Default branch for unexpected values.
- Match case strings exactly (case-sensitive) —
"PASS"≠"pass". - Put complex parsing in a Function or Transform node upstream, then switch on a clean field.
- Check Execution Data after a run to see the evaluated switch value and which branch was taken.