Switch Node

Route workflow execution to one of several named branches based on a value match. Use Switch when you have more than two possible paths — for example, routing by event type, message type, or order status.

How It Works

  1. Set the Input Value — typically a {{variable}} from an upstream node
  2. Add Cases — each case has a match value and connects to a separate output branch
  3. Add a Default branch that runs when no case matches
  4. Downstream nodes on each branch only execute when that branch is selected

Configuration

NameTypeRequiredDefaultDescription
inputValuestringYesThe value to match against cases — e.g. {{razorpayTrigger.event}} or {{whatsappTrigger.type}}
casesarrayYesArray of {value, label} objects. Each becomes a separate output handle.
defaultBranchbooleanNotrueWhether to include a Default branch for unmatched values
Case matching is exact string comparison by default. The input value and case values are both converted to strings before comparison.

Complete Workflow Examples

Route Razorpay Events

Use case: Handle different Razorpay event types with separate downstream logic.

textWorkflow
Razorpay Trigger (all events)
→ Switch
    inputValue: {{razorpayTrigger.event}}
    Cases:
      "payment.captured"  → Shiprocket Create Order → WhatsApp "Order confirmed!"
      "payment.failed"    → WhatsApp "Payment failed, retry here: {{link}}"
      "refund.processed"  → Gmail "Your refund has been processed"
      Default             → Slack #dev-logs "Unhandled event: {{razorpayTrigger.event}}"

Handle WhatsApp Message Types

Use case: Different handling for text, image, and location messages in a WhatsApp bot.

textWorkflow
WhatsApp Trigger (all message types)
→ Switch
    inputValue: {{whatsappTrigger.type}}
    Cases:
      "text"        → AI Node (answer question from {{whatsappTrigger.text}})
                      → WhatsApp Send Message
      "image"       → Google Sheets Append Row (log complaint)
                      → WhatsApp "Image received, our team will review."
      "location"    → HTTP Request (nearest store lookup)
                      → WhatsApp "Nearest store: {{httpRequest.body.store}}"
      "interactive" → If/Else (check {{whatsappTrigger.buttonId}})
      Default       → WhatsApp "Sorry, I didn't understand that."

Route by Order Status

Use case: Send different messages based on Shiprocket shipment status.

textWorkflow
Shiprocket — Track Shipment
    awbCode: {{body.awb}}
→ Switch
    inputValue: {{shiprocket.current_status}}
    Cases:
      "Delivered"     → MSG91 Send SMS "Your order has been delivered!"
      "In Transit"    → MSG91 Send SMS "Your order is on the way. ETA: {{shiprocket.tracking_data.etd}}"
      "Out for Delivery" → MSG91 Send SMS "Your order will be delivered today!"
      Default         → Slack #ops "Unknown status: {{shiprocket.current_status}}"

Common Issues & Solutions

IssueCauseSolution
All cases fall to DefaultCase values have extra spaces or wrong casingCopy-paste exact string values from upstream node output — case-sensitive
Branch nodes not runningBranch not connected to a downstream nodeEvery branch needs at least one connected node — add a placeholder node if needed
Only one branch runs even with OR conditionsSwitch routes to first matching case onlySwitch exits on first match — use If/Else for OR logic within a branch