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
| From | To | Possible Output |
|---|---|---|
| 1 | 10 | 1, 2, 3, ... 10 |
| 0 | 0 | 0 to 100 (default range) |
| -5 | 5 | -5, -4, ... 4, 5 |
| 50 | 50 | 50 (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:
- Generate a random number from 1 to 100
- Use a condition to check if the number is less than or equal to 50
- Route customers to different experiences based on the result
Randomized Delays
Add variability to your workflows:
- Generate a random number (e.g., 5 to 30)
- Use the result with the "Wait" action to create variable delays
Random Selection
Select one item from a list:
- Generate a random number from 0 to (list length - 1)
- 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.