Switch Block
Deterministic multi-branch routing with multiple match modes
Switch Block
The Switch block routes workflow execution to one of multiple paths based on value matching — similar to JavaScript's switch statement. Unlike the Router block (which uses an LLM), Switch is deterministic, fast, and free — no AI calls needed.
Overview
| Property | Value |
|---|---|
| Type | switch |
| Category | Core Block |
| Color | #8B5CF6 (Purple) |
When to Use
- You need to branch on a known set of values (status codes, categories, types)
- You want deterministic routing without LLM cost or latency
- You need multi-way branching (more than true/false)
- You're routing based on API response fields, user selections, or computed values
- You need pattern matching (contains, starts with, regex) or numeric comparisons
Switch vs Router vs Condition
| Feature | Switch | Router | Condition |
|---|---|---|---|
| Method | Multi-mode value match | LLM selection | Boolean expression / LLM judge |
| Branches | Unlimited | Unlimited | 2 (true/false) |
| Speed | Instant | Slow (LLM call) | Fast (expression) or Slow (LLM) |
| Cost | Free | Token cost | Free (expression) or Token cost |
| Best for | Known values / patterns | Semantic routing | Conditional logic |
Configuration
Switch Value
The value to match against. Supports {{}} block references:
{{agent.status}}
{{api.response.category}}
{{starter.input}}Match Mode
Controls how the switch value is compared against each case. Select from the dropdown:
| Mode | Description | Example |
|---|---|---|
| Exact Match | Case-sensitive exact string comparison (default) | "pending" matches "pending" |
| Contains | Case-insensitive substring search | "Hello World" matches case "world" |
| Starts With | Case-insensitive prefix check | "order-123" matches case "order" |
| Ends With | Case-insensitive suffix check | "file.pdf" matches case ".pdf" |
| Regex | Regular expression pattern match (case-insensitive) | "abc-123" matches case "^[a-z]+-\d+$" |
| Numeric | Numeric comparison with operators (>, <, >=, <=, ==, !=) | Input "75" matches case ">= 50" |
Cases
Define one or more cases, each with a match value. Add cases dynamically using the + Add Case button. Each case creates a separate output connection handle.
Case values support {{}} variable references — type {{ in a case value input to see a dropdown of available variables from upstream blocks.
A default case is always present and catches any value that doesn't match a defined case.
| Setting | Description |
|---|---|
| Case Value | The string/pattern to match against the switch value (supports {{}} references) |
| Default | Catches all unmatched values (always present, cannot be removed) |
Outputs
| Field | Type | Description |
|---|---|---|
matchedValue | string | The value of the matched case |
selectedCaseId | string | Internal ID of the matched case |
matchMode | string | The match mode that was used |
selectedPath | json | Information about the selected path (blockId, blockType, blockTitle) |
inputValue | string | The original input value (trimmed) |
Examples
Order Status Router (Exact Match)
Goal: Route order processing based on status field.
Workflow:
[Starter] → [API: Get Order] → [Switch] → [Agent: Process] (status = "pending")
→ [Slack: Notify] (status = "shipped")
→ [Gmail: Alert] (status = "cancelled")
→ [Response: Unknown] (default)Configuration:
- Switch Value:
{{api.status}} - Match Mode: Exact Match
- Cases:
- Case 1:
pending - Case 2:
shipped - Case 3:
cancelled - Default: catches everything else
- Case 1:
File Type Router (Ends With)
Goal: Route file processing based on extension.
Configuration:
- Switch Value:
{{starter.filename}} - Match Mode: Ends With
- Cases:
.pdf→ PDF processor.csv→ CSV parser.json→ JSON handler- Default → Unsupported format response
Score Grading (Numeric)
Goal: Grade a numeric score into categories.
Configuration:
- Switch Value:
{{api.score}} - Match Mode: Numeric
- Cases:
>= 90→ A grade handler>= 80→ B grade handler>= 70→ C grade handler- Default → Failing grade handler
In numeric mode, cases are evaluated top to bottom — the first matching case wins. Order your cases from most specific to least specific.
Content Filter (Regex)
Goal: Route content based on pattern matching.
Configuration:
- Switch Value:
{{agent.output}} - Match Mode: Regex
- Cases:
^error:→ Error handler\b(urgent|critical)\b→ Priority handler^success→ Success handler- Default → General handler
Language Router (Exact Match with Variables)
Goal: Route content to language-specific processors using dynamic case values.
Configuration:
- Switch Value:
{{starter.language}} - Match Mode: Exact Match
- Cases:
en→ English pipelinees→ Spanish pipelinefr→ French pipeline- Default → Fallback translation pipeline
Tips
- Exact Match is case-sensitive; Contains, Starts With, Ends With, and Regex are case-insensitive
- Non-string values are converted to strings before matching
- Input values are whitespace-trimmed before comparison
- Case values support
{{}}variable references — resolved at execution time - If no case matches and the default case has no connection, the block will error
- In Numeric mode, use operators like
> 100,<= 50,!= 0, or just a plain number for exact comparison - In Regex mode, invalid patterns are treated as non-matching (no error thrown)
- Cases are evaluated top-to-bottom — the first match wins (like JavaScript's
switch) - Use the Router block if you need semantic/fuzzy matching via LLM