RandomizerPnpm icon

RandomizerPnpm

Randomly directs input to multiple outputs based on given percentage or randomly

Overview

This node, named "RandomizerPnpm," is designed to randomly direct incoming data from two inputs (labeled A and B) into a single output. It supports two selection methods:

  • Random: The node randomly selects either all data from input A or all data from input B with equal probability.
  • Percentage: The node uses a user-defined percentage to bias the selection towards input A, selecting input A's data approximately that percentage of the time and input B's data the remainder.

This node is useful in scenarios where you want to split or route data streams probabilistically, such as A/B testing workflows, load balancing between two processes, or sampling data subsets for different processing paths.

Practical Examples

  • A/B Testing: Randomly send 60% of data to one process (input A) and 40% to another (input B) to compare outcomes.
  • Load Distribution: Distribute workload randomly or by percentage between two services or APIs.
  • Data Sampling: Randomly select data from two sources for downstream analysis.

Properties

Name Meaning
Selection Method Choose how to select input data:
- Random: Selects either input A or B randomly with equal chance.
- Percentage: Selects input A based on a specified percentage; input B gets the remainder.
Input Percentage for Input A (Only Numbers) When using the "Percentage" method, defines the percentage chance (0-100) that input A will be selected. For example, 60 means input A is selected 60% of the time and input B 40%.

Output

The node outputs a single array of items (json field) which contains the data selected from either input A or input B according to the chosen selection method.

  • If the Random method is used, the output contains all items from either input A or input B.
  • If the Percentage method is used, the output may contain items from input A, input B, or both depending on random chance and the specified percentage.
  • If no data is available or selected, the node returns null.

The node does not output binary data.

Dependencies

  • No external services or API keys are required.
  • The node requires two input connections labeled A and B, each providing data arrays.
  • No special environment variables or n8n configurations are needed beyond standard node setup.

Troubleshooting

  • Error: "No input data found. Make sure to connect two inputs and that they contain data."

    • Occurs if either input A or B is missing or empty.
    • Solution: Ensure both inputs are connected and provide data.
  • Error: "Use Random option instead of Percentage with 49-59%"

    • The node disallows setting the percentage between 49% and 59% to avoid ambiguous behavior.
    • Solution: Choose a percentage outside this range or switch to the Random selection method.
  • Error: Invalid selectionMethod parameter value

    • Happens if an unsupported selection method is configured.
    • Solution: Use only "random" or "percentage" as selection methods.

Links and References

  • n8n Documentation – General resource for creating and managing nodes.
  • Concepts related to A/B testing and load balancing can help understand practical use cases for this node.

Discussion