Switch Case
Overview
The Switch Case Node enables conditional logic within your workflow. It evaluates an input value and directs the workflow to the appropriate branch based on the defined conditions. If no condition matches, the workflow continues through the Default path, ensuring uninterrupted execution.
This node is ideal for creating workflows that require multiple decision points, such as routing data, performing different actions based on user input, or managing alternative outcomes.
Description
Route workflow execution based on values.
The Switch Case Node functions like a decision gate. It checks an incoming value—such as a number, text, or boolean—and determines which branch of the workflow should be executed next.
Matched Case
If the input matches a defined case (e.g., "1"), the workflow follows that specific path.
Default Path
If no cases match, the workflow follows the Default path to handle the fallback.
For example:
- If input is "1" → Go to "Add Data".
- If input is "2" → Go to "Delete Data".
- Else → Go to "Default" (e.g., Return Error).
Input Parameters
The Switch Case node accepts the value to evaluate and the list of cases.
ParameteranyRequired"2"CasesarrayRequired["1", "2", "3"]DefaultstringRequired"default-path-id"Parameter TypestringRequired"integer"Output Parameters
The node outputs details about the matched case and the next step.
parameteranyOptional1parameterTypestringOptional"integer"matchedCasestringOptional"Add Data"nextNodestringOptional"add-data-3"Output Type
Output Type: JSON
The output provides structured data about the decision made, which is useful for debugging or logging the workflow path.
Example Usage
Example 1: Case Match
Routing based on user selection.
{ "input": { "number": "1" }}
{ "parameter": 1, "parameterType": "integer", "matchedCase": "Add Data", "nextNode": "add-data-3"}
Explanation: Input "1" matched the "Add Data" case.
Example 2: Default Fallback
Handling an invalid option.
{ "input": { "number": "5" }}
{ "parameter": 5, "parameterType": "integer", "matchedCase": "default", "nextNode": "return-error-node"}
Explanation: Input "5" did not match any case, so it went to Default.
How to Use in a No-Code Workflow
Add the Node
Drag and drop the Switch Case Node into your workflow.
Select Input
Connect a trigger or previous node and select the Parameter to evaluate (e.g., user_choice).
Define Cases
Add cases for each expected value (e.g., "1", "2", "3").
Connect Branches
Connect each Case Output to the appropriate next node (e.g., Case "1" → Add Data).
Set Default
Connect the Default Output to a fallback node (e.g., Send Error Message) to handle unmatched inputs.
Run Workflow
Test with different inputs to ensure correct routing.
Best Practices
- Always include a Default branch to prevent workflow interruptions.
- Ensure the data type of your input matches the defined case values.
- Use clear names for your cases.
Do / Don’t
- ✔️ Use Switch Case for multiple options (3+), use If/Else for binary (True/False).
- ✔️ Handle the Default path gracefully (e.g., return a helpful error message).
- ✔️ Verify input types (string "1" is not equal to integer 1).
- ❌ Don’t leave the Default branch disconnected.
- ❌ Don’t create duplicate cases for the same value.
- ❌ Don’t use complex logic inside a Switch Case; keep it to simple value matching.
Common Errors
Goes to DefaultWarningOptionalStops UnexpectedlyErrorOptionalWrong Node TriggeredErrorOptionalExample Workflow Integration
Use Case 1: Order Status Routing
Process orders based on their current status.
- Trigger: Order Updated.
- Switch Case: Check
status.- Case "Pending": Route to Send Reminder.
- Case "Shipped": Route to Notify Customer.
- Case "Delivered": Route to Ask for Review.
- Default: Log unknown status.
Workflow Data Flow:
{{order.status}} → {{switchCase.parameter}}
Use Case 2: User Role Access
Redirect users based on their role.
- Trigger: User Login.
- Switch Case: Check
role.- Case "Admin": Go to Admin Dashboard.
- Case "Editor": Go to Content Panel.
- Case "Viewer": Go to Home Page.
- Default: Go to Login Page (Access Denied).
Workflow Data Flow:
{{user.role}} → {{switchCase.parameter}}
