Widgets/Condition
Switch Widget
Switch Widget
A "Condition" type widget. Switch Widget evaluates incoming data against multiple conditions and routes it to different output ports based on which condition is met first. Think of it as a multi-way conditional router that can send data down different paths.
The Switch Widget is ideal for creating branching logic with more than two paths, allowing you to route data through multiple decision points in a single widget.
Inputs
- input (DataType: Anything)
The incoming value that will be evaluated against the configured conditions. This value can be accessed as
inputwithin expressions.
Outputs
When used in Single Output Mode:
-
out (DataType: Same as evaluation result) Transmits the evaluation result of the first matching condition. The output value can be a template expression (e.g.,
input * 2or"value: " + input). -
else (DataType: Same as input or expression result) Transmits data when none of the conditions are met. By default, passes through the original input.
When used in Multiple Outputs Mode:
-
1, 2, 3, ... (DataType: Same as evaluation result) Each condition gets its own numbered output port. When a condition is met, the evaluation result is sent to that condition's specific port.
-
else (DataType: Same as input or expression result) Transmits data when none of the conditions are met. By default, passes through the original input.
Custom Settings
-
Multiple Outputs Toggle between single output mode and multiple outputs mode.
-
Single Output Mode: All matching conditions send their results to the same
outport. Only the first matching condition executes. -
Multiple Outputs Mode: Each condition has its own numbered output port (1, 2, 3, etc.). Only the first matching condition executes.
-
Rows Set the number of conditions to evaluate (1-10). Each row represents a condition with its own expression and output value.
-

-
Condition Table Configure each condition by setting:
-
Expression: A JavaScript-like expression that evaluates to true or false. You can reference the input using the keyword
input. For example:input > 10,input === "active", orinput.status === "complete". Supports the same expression syntax as the Expression Eval Widget. -
Output: The value to output when the condition is met. This can be:
- A literal value:
"success",100,true - A template expression:
input * 2,input.toUpperCase(), or"Result: " + input - The keyword
inputto pass through the original value unchanged - Any expression supported by the Expression Eval Widget, including global variables (
$vars), secrets ($secrets), and helper functions
- A literal value:
-
-
Expression Syntax Both the Expression and Output fields support the same powerful expression evaluation as the Expression Eval Widget. This includes:
- Access the incoming data using the
inputkeyword - Use JavaScript operators:
>,<,>=,<=,===,!==,&&,|| - Access object properties:
input.name,input.status - Use string methods:
input.startsWith("test"),input.includes("keyword") - Perform math operations:
input * 2,input + 10 - Combine conditions:
input > 10 && input < 20 - Access global variables:
$vars.variableName - Access secrets:
$secrets.secretName - Use helper functions:
$capitalize(),$uppercase(),$json(),$length(), etc. - Access date/time helpers:
date.year,date.month,date.dayName, etc.
- Access the incoming data using the
For complete expression syntax and available helpers, see the Expression Eval Widget documentation.
📌 Important Notes
- Conditions are evaluated in order from top to bottom
- Only the first matching condition will execute - subsequent conditions are not evaluated
- If no conditions match, data is routed to the
elseport - The
elseport output can also be customized with template expressions - Variables can be highlighted outside of braces for easier readability in the expression editor
- Expressions support both comparison operations and template transformations
- You can access nested object properties using dot notation (e.g.,
input.user.name) - When switching between single and multiple output modes, connections to removed ports are automatically cleaned up
Examples
Basic Numeric Routing
This example demonstrates routing numbers to different outputs based on ranges:
Drag the example onto the workspace to explore and experiment!
In this example
- The Slider Widget outputs numbers from
0to100 - The Switch Widget evaluates three conditions:
- If
input < 30, outputs "Low" to port1, which sends to and displays in the Text Widget - If
input >= 30 && input < 60, outputs "Medium" to port2, which sends to and displays in the Text Widget - If
input >= 60 && input <= 70, outputs "High" to port3, which sends to and displays in the Text Widget
- If
- The
elseoutput port shows the original slider value when none of the conditions are met. In this example, theelseport displays values when:- The input is greater than
70(since the "High" condition only covers values up to70) - The input is less than
0(though the slider range is0-100)
- The input is greater than
String Pattern Matching
This example shows how to route data based on string patterns:
Drag the example onto the workspace to explore and experiment!
In this example
- Three Text Widgets provide log messages with different prefixes: "Error: something went wrong.", "Warning: check this before continuing.", and "Successful: everything is ready."
- The Button Widgets trigger each Text Widget to send its message to the Switch Widget
- The Switch Widget checks the message prefix:
- If it starts with "Error", routes to port
1→ Counter Widget - If it starts with "Warning", routes to port
2→ Counter Widget - Otherwise, routes to the "else" port → Counter Widget
- If it starts with "Error", routes to port
- Each Counter Widget tracks how many messages of each type have been processed
Result: Messages are categorized and counted based on their prefix
Object Property Routing
This example demonstrates routing based on object properties and transforming the output:
Drag the example onto the workspace to explore and experiment!
In this example
- The Text Widget provides the user name "John"
- The Slider Widget controls the status value
(0-3)for the user object - The Object Widget creates a user object with
name(from Text Widget) andstatus(from Slider Widget) properties - The Switch Widget evaluates the numeric status and creates formatted messages:
- If status is
1, outputs "{name} is online" - If status is
2, outputs "{name} is busy" - If status is
3, outputs "{name} is offline" - If status is
0, outputs empty
- If status is
- The formatted message is sent to and displayed in the Text Widget
Result: User status is converted to human-readable messages based on numeric status values
📌 Additional Notes
Comparison with Conditional Widget
The Switch Widget and Conditional Widget serve different purposes:
Use Switch Widget when:
- You need to evaluate multiple conditions (more than 2 paths)
- Each condition can produce a different transformed output
- You want conditions evaluated in a specific order (top to bottom)
- You need powerful expression evaluation for both conditions and outputs
Use Conditional Widget when:
- You only need a simple true/false branch (2 paths)
- You want to pass data unchanged based on a comparison
- You need pre-defined comparison operators (Equal, Greater, Less, etc.)
- Simpler configuration is preferred
Glossary
-
Expression
A JavaScript-like statement that evaluates to a value. Can include comparisons, calculations, string operations, and object property access.
-
Template Expression
An expression that transforms data to produce output. For example,
input * 2or"Result: " + input.