Node switch
The switch node is designed for routing messages based on their content, structure, or other conditions. It is a powerful tool for creating conditional logic in flows.
Settings for the switch node

1. Name
A field for specifying the name of the node.
The name is displayed in the workspace and helps easily identify the node.
If left empty, the node will be called switch.
Example:
- Node name:
check status
2. Property
Specifies which property of the message object msg will be used to check conditions. By default, it is payload.
Example:
msg.payloadmsg.topicmsg.device.temperature
Environment properties (flow, global) are also supported.
3. Check
- check all rules (default):
The message can be sent to multiple outputs if it meets multiple conditions. - stop after first match:
The message is sent only to the first output that meets the condition.
4. Rules
Define the routing logic. Each rule is tied to one of the node's outputs: as many rules as there are outputs. How many outputs the message will go to in case of multiple matches is determined by the Check field.
Each rule has two fields: Condition — the type of condition and Value — the value for comparison. For conditions equals true, equals false, equals null, not equals null, empty, and not empty, the Value field is not displayed.
Available condition types:
==: Checks for equality of value.!=: Checks for inequality.<: Checks if the value is less.<=: Checks if the value is less than or equal to.>: Checks if the value is greater.>=: Checks if the value is greater than or equal to.has key: Checks if the object contains the specified key.between: Checks if the value is within the specified range (inclusive).contains: Checks if the string or array contains the specified value.matches regex: Checks if the string matches the regular expression.equals true: Checks if the value is equal totrue.equals false: Checks if the value is equal tofalse.equals null: Checks if the value is equal tonull.not equals null: Checks if the value is not equal tonull.is of type: Checks if the value is of the specified type (e.g.,string,number,boolean).empty: Checks if the string, array, or object is empty.not empty: Checks if the string, array, or object is not empty.else: Executes if none of the other conditions are met.
Example:
- Condition:
>, Value:50
Input
The node accepts the msg object.
Which properties will be checked is specified in the Property field.
Output
The node sends the msg message to the output that matches the specified condition.
If the message does not meet any condition, it is not sent to the outputs.
Usage Examples
Example 1: Filtering Temperature Data
Task:
Categorize data into three categories: low, normal, and high temperature.
Flow:
[inject] ---> [function] ---> [switch] ---> [debug (low temp)]
| [debug (normal temp)]
| [debug (high temp)]
Settings for the switch node:
- Property:
msg.payload - Conditions:
is less than 10→ Output 1is between 10 and 30→ Output 2is greater than 30→ Output 3
Result:
Temperatures will be routed based on their value.