Random Number
Generate a cryptographically secure random number between a minimum and maximum value. The result is stored and can be referenced in any following action using placeholder syntax - making it perfect for randomized delays, dynamic overlay text, variable increments, and more.
What You Need
- Nothing extra - this action works standalone.
Quick Start
- Create or edit an alert.
- Click Add Action and select Random Number.
- Set your Minimum and Maximum values.
- Note the action's key (e.g.
random_number_1) shown in the action header - you'll use this to reference the result. - In any later action, type
{{ random_number_1.result }}wherever you want to use the number. - Save and test.
Configuration Options
Range
| Setting | Description | Default |
|---|---|---|
| Minimum | The lower bound of the range (inclusive). | 1 |
| Maximum | The upper bound of the range (inclusive). | 100 |
- Both
MinimumandMaximumsupport placeholder syntax - you can use event data (e.g.{{ amount }}) to set the range dynamically. - For integers: both bounds are inclusive (e.g. a range of 1–6 can produce 1, 2, 3, 4, 5, or 6).
Minimummust be less than or equal toMaximum, or the action will fail with an error.
Float Mode
| Setting | Description | Default |
|---|---|---|
| Float Mode | When enabled, generates a decimal number instead of a whole integer. | Off |
| Decimal Precision | Number of decimal places in the result (0–10). Only visible when Float Mode is on. | 2 |
- Integer mode (default): uses a cryptographically secure integer generator. Both bounds inclusive.
- Float mode: generates a cryptographically secure decimal. For example, with a range of
1.0–2.0and precision2, you might get1.47. Decimal Precisionsupports placeholder syntax.
Using the Result in Other Actions
When a Random Number action runs, its output is stored under the action's key and made available to all subsequent actions via placeholders.
| Placeholder | Value |
|---|---|
{{ random_number_1.result }} | The generated number |
{{ random_number_1.min }} | The minimum bound that was used |
{{ random_number_1.max }} | The maximum bound that was used |
{{ random_number_1.float_mode }} | true or false |
{{ random_number_1.precision }} | The precision setting (float mode only) |
The key (random_number_1, random_number_2, etc.) is shown in the action's header inside the alert editor. If you have multiple Random Number actions, each gets its own numbered key.
Example Use Cases
Randomized Delay
Add a Random Number action (range 1000–5000), then a Delay action set to {{ random_number_1.result }} ms. The pipeline will pause for a random amount of time between 1 and 5 seconds.
Dynamic Overlay Text
In a Stream Overlay action's text field, type:
"You rolled a
{{ random_number_1.result }}!"
Variable Increment
In a Global Variable action set to Add, use {{ random_number_1.result }} as the value to add a random amount to a counter.
Random Intensity
Feed the result into a PiShock or OpenShock intensity field to randomize shock/vibration strength.
Tips
- Place Random Number early in your action list - its result is only available to actions that come after it.
- Integer mode is best for dice rolls, counts, and anything where whole numbers matter.
- Float mode is best for percentages, probabilities, or when you want finer granularity.
- The generator is cryptographically secure - it uses Node.js's
cryptomodule, so results are truly unpredictable and not affected by a predictable seed.