Using FlowMattic Variables to Generate Random Numbers
FlowMattic includes a powerful built-in variable system, accessible from a dedicated admin page called “Variables”. This page not only lists pre-defined system variables like random_number:<NUMBER>, but also allows users to create their own custom variables for reuse across workflows.
One of the most useful built-in variables is the random number generator, which helps you generate a dynamic number between 0 and your defined upper limit — perfect for things like OTPs, invoice IDs, or test data.
🔧 How It Works
To generate a random number, you use the following syntax:
{{random_number:<NUMBER>}}
random_number:is the variable type.<NUMBER>defines the upper limit.- It generates a random number between
0and<NUMBER>(inclusive of 0, exclusive of).
✅ Example:
{{random_number:100}}
Will generate a number like 72 (any number between 0 and 100).
🪜 Step-by-Step: How to Use Random Number Variable
- Open your workflow in FlowMattic.
- Add or select a step where you want to use a dynamic random number.
- Inside the input field, click the
+icon to open the Dynamic Fields popup. - The first section in the popup is FlowMattic Variables — search or scroll to find
random_number:<NUMBER>. - Select or modify the number to suit your range, e.g.,
random_number:1000for values between0and1000. - Insert the variable — it will appear as
{{random_number:1000}}. - You can now use this variable directly — for example, in number formatting, API calls, or creating dynamic content.
📦 Use Case Examples
1. 🔐 Generate 4-digit OTP
{{random_number:9999}}
- Used to create a random 4-digit One-Time Password.
- Example Output:
4832
2. 📦 Create a unique invoice suffix
INV-{{random_number:100000}}
- Used to create invoice codes like
INV-49832.
3. 🧪 Add a random delay in testing flows
{{random_number:10}}
- Used to randomly set wait times between 0 to 10 seconds for testing.
4. 🎟 Generate a short coupon code number
COUPON-{{random_number:1000}}
- Used to create short numeric codes like
COUPON-417.
5. 🧾 Generate customer reference number
REF{{random_number:1000000}}
- Example Output:
REF492837
💡 Tip
You can also use this inside Format Number, Conditions, API Calls, or Custom Email Templates, just like shown in the screenshot shared below — where it’s used inside a Format Number step to apply a comma separator for readability.