switch node provides multi-way branching. It evaluates an expression and matches against cases using exact values, numeric ranges, or regex patterns.
Configuration
Config Fields
| Field | Type | Required | Description |
|---|---|---|---|
expression | string | Yes | Template expression to evaluate |
cases | array | Yes | Array of case objects |
default | string[] | No | Node IDs if no case matches |
Case Object
Each case can use one of three match types:| Field | Type | Description |
|---|---|---|
value | any | Exact value match (string, number, boolean, or array of values) |
min | number | Minimum value for range match (inclusive) |
max | number | Maximum value for range match (inclusive) |
pattern | string | Regex pattern for pattern match |
then | string[] | Node IDs to execute if case matches |
Match Types
Exact Match
Match against a specific value:Range Match
Match numeric values within a range:| Config | Matches |
|---|---|
| min: 100 | Values 100 or greater |
| max: 99 | Values 99 or less |
| min: 100, max: 999 | Values between 100 and 999 (inclusive) |
Pattern Match
Match using regular expressions:Output
| Field | Type | Description |
|---|---|---|
matched | boolean | Whether any case matched |
matched_index | number | Index of matched case (-1 if default) |
matched_value | any | The value that was matched |
match_type | string | "exact", "range", "pattern", or "default" |
Examples
Route by HTTP Status
Categorize by Score
Route by URL Pattern
Boolean Switch
Evaluation Order
- Cases are evaluated in order
- Pattern match is checked first (if
patternis set) - Range match is checked next (if
minormaxis set) - Exact match is checked last (if
valueis set) - First matching case wins
- If no case matches,
defaultbranch executes
Type Coercion
The switch node performs smart type coercion:- String
"true"/"false"are converted to booleans - Numeric strings are parsed as numbers for range comparisons
- Array values allow matching against any element
Related
- Condition Node - Simple if/else branching
- Template Expressions - Expression syntax