Switch Block
Route by exact value matching
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. Supports exact match, contains, starts/ends with, regex, and numeric comparisons with {{}} variable references in case values.
Overview
| Property | Value |
|---|---|
| Type | switch |
| Category | blocks |
| Color | #8B5CF6 |
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
- You want the fastest possible routing without any token spend
Configuration
Switch Value
The value to match against. This field is required. Supports {{}} block output references:
{{agent1.status}}
{{api.response.category}}
{{starter.input}}| Property | Detail |
|---|---|
| Sub-block id | value |
| Type | short-input |
| Required | Yes |
| Placeholder | Value to match against, e.g. {{agent1.status}} |
Match Mode
Controls how the switch value is compared against each case. Select from the dropdown. Defaults to Exact Match.
| Option Label | Option Id | Description |
|---|---|---|
| Exact Match (===) | exact | Case-sensitive exact string comparison (default) |
| Contains | contains | Case-insensitive substring search |
| Starts With | startsWith | Case-insensitive prefix check |
| Ends With | endsWith | Case-insensitive suffix check |
| Regex | regex | Regular expression pattern match (case-insensitive) |
| Numeric comparison | numeric | Numeric comparison with operators (>, <, >=, <=, ==, !=) |
| Property | Detail |
|---|---|
| Sub-block id | matchMode |
| Type | dropdown |
| Default | exact |
Cases
Define one or more match cases, each mapped to a separate output connection handle. Add cases using the + Add Case button in the editor.
| Property | Detail |
|---|---|
| Sub-block id | cases |
| Type | switch-case-input |
- Each case value supports
{{}}variable references resolved at execution time. - Cases are evaluated top-to-bottom — the first matching case wins.
- A default case is always present and catches any value that does not match a defined case.
- In Numeric mode, use operators like
> 100,<= 50,!= 0, or a plain number for equality. - In Regex mode, invalid patterns are treated as non-matching (no error thrown).
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 |
Inputs & Outputs
The Switch block has no declared input fields — its configuration (value, matchMode, cases) is set directly in the block editor. All routing is driven by the value sub-block referencing upstream outputs via {{blockName.field}}.
- Outputs:
matchedValue(string) — The value of the matched caseselectedCaseId(string) — Internal ID of the matched casematchMode(string) — The match mode that was used (e.g.exact,contains,regex)selectedPath(json) — Information about the selected execution path (blockId,blockType,blockTitle)inputValue(string) — The original input value (whitespace-trimmed before comparison)
Tools
This block uses no external tools (tools.access is empty). The Switch block executes entirely within the Zelaxy workflow engine with no API calls or LLM usage.
YAML Example
switch_1:
type: switch
name: "Switch"
inputs:
value: "{{api.status}}"
matchMode: "exact"
cases:
- id: case_1
value: "pending"
- id: case_2
value: "shipped"
- id: case_3
value: "cancelled"
connections:
outgoing:
- target: agent_process
case: case_1
- target: slack_notify
case: case_2
- target: gmail_alert
case: case_3
- target: response_unknown
case: defaultTips
- Exact Match is case-sensitive; Contains, Starts With, Ends With, and Regex are all case-insensitive
- Non-string values are coerced 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, cases are evaluated top-to-bottom — order from most specific to least specific
- Use the Router block if you need semantic or fuzzy matching via LLM