Random Output icon

Random Output

Using JavaScript random, send input items to random output.

Random Output

AI-generated

Overview

The Random Output node distributes incoming input items randomly across a specified number of outputs. It uses JavaScript's random function to decide which output each item should be sent to. This node is useful in scenarios where you want to simulate random distribution of data or events, such as load testing, random sampling, or splitting data streams unpredictably.

Use Case Examples

  1. In a workflow processing customer requests, use this node to randomly assign requests to different processing paths for load balancing.
  2. During testing, send all items to a specific output to verify downstream processing behavior.

Properties

Name Meaning
Number of Outputs Specifies how many outputs the node will have to send items to. The node randomly assigns each input item to one of these outputs.
Output Element Determines what is sent to the outputs. It can either send the original input item or an object containing the output index.
Options.forceOutput Overrides the random behavior to send all items to a specific output index. Useful for testing.
Options.forceOutputInProduction Allows the forceOutput option to be used even when the workflow is not in test mode.

Output

JSON

  • outputIndex - When 'Output Element' is set to 'Output Index', this property indicates the index of the output to which the item was sent.

Troubleshooting

  • If no outputs are configured or the number of outputs is set to zero, the node will not function correctly. Ensure 'Number of Outputs' is set to at least 1.
  • If 'Force All Items to Output' is used in production without enabling 'Allow Force All Items to Output in Production', the forced output behavior will be ignored unless the workflow is in test mode.
  • Random distribution means some outputs may receive more items than others in any given execution, which is expected behavior.

Discussion