Input & Output
Dynamic output port structure, data flow, and how to connect the Switch node in your workflow.
Dynamic ports: Unlike most nodes with fixed output ports, the Switch node creates output ports dynamically based on the port names defined in your
cases dictionary and the optional default_port. Each unique port name in your configuration becomes an available connection point in the workflow designer.
Output Ports
| Port | When Triggered | Description |
|---|---|---|
case port name (e.g., pending) |
Expression result matches the corresponding case key | Each case in the cases dictionary produces a named port. Exactly one case port fires per execution. The full execution context is forwarded unchanged to downstream nodes on this port. |
| default_port name (if configured) | Expression result does not match any configured case key | The fallback port fires when no case key matches. Receives the same execution context as any case port, plus the switch_result metadata field indicating the unmatched value. |
Output Data
The Switch node appends two metadata fields to the execution context, available to all downstream nodes regardless of which port fires:
| Field | Type | Description |
|---|---|---|
switch_expression_value |
string | The resolved string value of the expression after evaluation. Useful for logging and debugging — tells you exactly what value was used for case matching. |
switch_matched_port |
string | The name of the port that was fired (matched case port name or default port name). Allows downstream nodes to know which routing decision was made without re-evaluating the expression. |
| All input fields | as received | All incoming execution context data is passed through unchanged to every output port. |
Data Flow Example
// === Incoming Execution Context ===
{
"variables": {
"orderStatus": "approved",
"orderId": "ORD-2024-009"
},
"input": {
"customer_id": "C-442",
"total": 875.00
}
}
// === Switch Node Configuration ===
{
"expression": "$var.orderStatus",
"cases": {
"pending": "pendingPath",
"approved": "approvedPath",
"rejected": "rejectedPath",
"shipped": "shippedPath"
},
"default_port": "unknownStatusPath"
}
// === Evaluation ===
// $var.orderStatus resolves to "approved"
// Lookup "approved" in cases → found → port "approvedPath"
// === Output on "approvedPath" port ===
{
"variables": {
"orderStatus": "approved",
"orderId": "ORD-2024-009"
},
"input": {
"customer_id": "C-442",
"total": 875.00
},
"switch_expression_value": "approved",
"switch_matched_port": "approvedPath"
}
// === All other ports ===
// pendingPath, rejectedPath, shippedPath, unknownStatusPath
// → none fired for this execution pass
Port Naming Conventions
Port names can be any valid identifier string. Recommended conventions:
- Use camelCase or snake_case consistently within a workflow
- Use descriptive names that reflect the business meaning, not just the value (e.g.,
highPriorityPathrather thanport1) - Prefix with the category when cases are part of a larger grouping (e.g.,
region_uk,region_eu) - Name the default port
fallbackorunhandledto make its purpose immediately clear