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
- Set the Input Value — typically a
{{variable}}from an upstream node - Add Cases — each case has a match value and connects to a separate output branch
- Add a Default branch that runs when no case matches
- Downstream nodes on each branch only execute when that branch is selected
Configuration
| Name | Type | Required | Default | Description |
|---|---|---|---|---|
inputValue | string | Yes | — | The value to match against cases — e.g. {{razorpayTrigger.event}} or {{whatsappTrigger.type}} |
cases | array | Yes | — | Array of {value, label} objects. Each becomes a separate output handle. |
defaultBranch | boolean | No | true | Whether 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
| Issue | Cause | Solution |
|---|---|---|
| All cases fall to Default | Case values have extra spaces or wrong casing | Copy-paste exact string values from upstream node output — case-sensitive |
| Branch nodes not running | Branch not connected to a downstream node | Every branch needs at least one connected node — add a placeholder node if needed |
| Only one branch runs even with OR conditions | Switch routes to first matching case only | Switch exits on first match — use If/Else for OR logic within a branch |
Related Nodes
- If / Else — binary TRUE/FALSE branching
- Razorpay Trigger — use Switch on
{{razorpayTrigger.event}} - WhatsApp Trigger — use Switch on
{{whatsappTrigger.type}}