Routing messages using a switch node

You can route messages to different branches of a flow by evaluating rules against:

  1. Open Node-RED.
  2. Add a switch node from the function category to the workspace.
  3. Double-click the switch node to open the Edit node dialogue.
  4. In the Property drop-down list, select the property against which you want to evaluate rules.
  5. Add empty rules by clicking + add.
  6. notice

    For each rule, an output is added to the switch node that corresponds to that rule.

  7. Configure the rules by selecting a rule type from the respective drop-down list and defining the rule as necessary.
  8. Select from the drop-down list whether the node should evaluate each rule every time and forward the message to all matching outputs or whether to stop evaluating after the first match.
  9. If new message sequences should be generated for each matching rule, enable the recreate message sequences check box.
  10. Click Done to apply your changes.
  11. Connect the input of the switch node to the node that outputs the messages you want to route.
  12. Connect the outputs of the switch node to the matching branches of the flow.
  1. Once the flow is deployed, messages are routed according to the rules.