New260+ blocks and 240+ tools are now fully documented
DocumentationReferenceCore BlocksFlow Control
Block

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

PropertyValue
Typeswitch
Categoryblocks
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}}
PropertyDetail
Sub-block idvalue
Typeshort-input
RequiredYes
PlaceholderValue 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 LabelOption IdDescription
Exact Match (===)exactCase-sensitive exact string comparison (default)
ContainscontainsCase-insensitive substring search
Starts WithstartsWithCase-insensitive prefix check
Ends WithendsWithCase-insensitive suffix check
RegexregexRegular expression pattern match (case-insensitive)
Numeric comparisonnumericNumeric comparison with operators (>, <, >=, <=, ==, !=)
PropertyDetail
Sub-block idmatchMode
Typedropdown
Defaultexact

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.

PropertyDetail
Sub-block idcases
Typeswitch-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

FeatureSwitchRouterCondition
MethodMulti-mode value matchLLM selectionBoolean expression / LLM judge
BranchesUnlimitedUnlimited2 (true/false)
SpeedInstantSlow (LLM call)Fast (expression) or Slow (LLM)
CostFreeToken costFree (expression) or Token cost
Best forKnown values / patternsSemantic routingConditional 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 case
    • selectedCaseId (string) — Internal ID of the matched case
    • matchMode (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: default

Tips

  • 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