Workflow actions

Get random number (integer)

This Flow Companion action generates a random number (integer) within a specified range. It's useful for A/B testing, randomized delays, or any scenario where you need unpredictable values in your workflow.

Configuration

Action Parameters

  • From: Lower bound of the range (inclusive). Defaults to 0 if not provided.
  • To: Upper bound of the range (inclusive). Defaults to 100 if not provided or if both bounds are 0.

Default Behavior

If both From and To are set to 0 or left empty, the action will generate a random number between 0 and 100.

Examples

FromToPossible Output
1101, 2, 3, ... 10
000 to 100 (default range)
-55-5, -4, ... 4, 5
505050 (always)

Output

The action returns the following field:

  • randomNumber: The generated random number within the specified range.

Use Cases

A/B Testing

Use the random number to split customers into groups:

  1. Generate a random number from 1 to 100
  2. Use a condition to check if the number is less than or equal to 50
  3. Route customers to different experiences based on the result

Randomized Delays

Add variability to your workflows:

  1. Generate a random number (e.g., 5 to 30)
  2. Use the result with the "Wait" action to create variable delays

Random Selection

Select one item from a list:

  1. Generate a random number from 0 to (list length - 1)
  2. Use the result to access an item at that index

Error Handling

The action will return an error in the following cases:

  • From greater than To: If the lower bound exceeds the upper bound.
  • Value out of bounds: If either parameter exceeds safe integer limits (±9007199254740991), the action returns a error.