Dynamic Switch icon

Dynamic Switch

Single-node switch with dynamic outputs and efficient routing: maintained by Swiftwing.fr

Dynamic Switch

AI-generated

Overview

The Dynamic Switch node routes incoming data items to multiple outputs based on dynamic criteria. It supports two modes: Expression mode, where each item is sent to an output index determined by an expression; and Rules mode, where items are routed to outputs based on matching rules defined for different data types (Boolean, Date & Time, Number, String). This node is useful for workflows requiring conditional branching, such as directing customer data to different processing paths based on attributes or filtering events by date or status.

Use Case Examples

  1. Routing customer support tickets to different teams based on priority level (Number rules).
  2. Sending log entries to different outputs based on log level strings (String rules).
  3. Filtering events that occurred before or after a certain date (Date & Time rules).
  4. Routing items based on a Boolean flag, e.g., active/inactive status.

Properties

Name Meaning
Number of Outputs Specifies how many output branches (ports) the node will create, with a minimum of 1 and maximum of 50.
Output Labels Optional comma-separated custom labels for each output branch to improve readability.
Mode Determines how the node routes items: either by evaluating an expression to get the output index or by applying matching rules to send items to one or more outputs.
Output Index In Expression mode, the zero-based output index to send each item to. Supports expressions like {{$json.routeIndex}}.
Data Type In Rules mode, specifies the type of data to compare in routing rules (Boolean, Date & Time, Number, or String).
Match Strategy In Rules mode, determines whether to send items to the first matching rule's output or to all matching rules' outputs.
Left Value The left-hand value used in the routing rule comparison, type depends on the selected Data Type.
Routing Rules A collection of rules defining operations and right-hand values to compare against the left value, each associated with an output index.
Case Insensitive For string data type rules, whether to ignore case when comparing strings (except for regex operations).
Fallback Output Output index for items that do not match any rule (in Rules mode) or have an invalid index (in Expression mode). Use -1 to drop non-matching items.

Output

JSON

  • json
    • error - Error message included in the output item if processing fails and continueOnFail is enabled.

Troubleshooting

  • Ensure the number of outputs is between 1 and 50; otherwise, an error will be thrown.
  • In Expression mode, the output index must be within the valid range; invalid indices will route items to the fallback output or drop them if fallback is -1.
  • In Rules mode, the data type and rules must be consistent; mismatched types or invalid operations can cause errors.
  • Regex patterns must be valid; invalid regex will cause the rule to fail matching.
  • If continueOnFail is disabled, any error during processing will stop execution; enabling it will route error info to the first output.

Discussion