Generate Random
Create random values on the fly in your HubSpot workflows. Generate unique identifiers, create test data, assign random numbers for A/B testing, or produce secure tokens—all without leaving the workflow editor.
Overview
Section titled “Overview”Use Generate Random when you need unpredictable values in your automation workflows. Perfect for creating unique reference numbers, generating temporary passwords, assigning contacts to random test groups, or producing unique identifiers for tracking.
Configuration
Section titled “Configuration”Input Fields
Section titled “Input Fields”Random Type (Required)
Section titled “Random Type (Required)”Choose the type of random value to generate. The UI automatically reveals additional inputs based on your selection.
Available Types:
- Random Number - Generate random integers within a specified range
- UUID v4 - Generate universally unique identifiers (version 4)
- Random String - Generate random strings with configurable length and character sets
Conditional Inputs (automatic)
Section titled “Conditional Inputs (automatic)”Depending on the random type you select, you may see additional fields:
| Random Type | Extra fields |
|---|---|
number | minValue, maxValue (both optional, defaults: 0-100) |
uuid | No additional fields |
string | length (required), characterSet (optional, defaults to alphanumeric) |
Output Fields
Section titled “Output Fields”randomValue (String)
Section titled “randomValue (String)”The generated random value. All values are returned as strings for consistency, even random numbers.
Type: Random Number (min=1, max=1000)Output (randomValue): 427
Type: UUID v4Output (randomValue): 550e8400-e29b-41d4-a716-446655440000
Type: Random String (length=8, characterSet=alphanumeric)Output (randomValue): aB3xK9mPRandom Types
Section titled “Random Types”Random Number
Section titled “Random Number”Generates a random integer within a specified range (inclusive).
Fields:
- Minimum Value (optional): The smallest number that can be generated. Defaults to 0 if left empty.
- Maximum Value (optional): The largest number that can be generated. Defaults to 100 if left empty.
Example:
Min: 1Max: 100Possible outputs: 1, 42, 73, 100, etc.Use Cases:
- A/B test group assignment (1-10)
- Random order processing priority
- Lottery or contest selection
- Random delay intervals
UUID v4
Section titled “UUID v4”Generates a universally unique identifier using version 4 (random) specification. UUIDs are 36-character strings in the format xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx.
No additional configuration required.
Example Output:
550e8400-e29b-41d4-a716-4466554400007c9e6679-7425-40de-944b-e07fc1f90ae7a3bb189e-8bf9-3888-9912-ace4e6543002Use Cases:
- Unique order or ticket reference numbers
- External system correlation IDs
- Unique tracking codes
- Database foreign keys
Random String
Section titled “Random String”Generates a random string with configurable length and character set. Perfect for creating temporary passwords, unique codes, or test data.
Fields:
- String Length (required): How many characters to generate. Must be greater than zero.
- Character Set (optional): The types of characters to include. Defaults to alphanumeric.
Character Set Options:
- Alphanumeric (default): A-Z, a-z, 0-9 (62 possible characters)
- Alphabetic: A-Z, a-z (52 possible characters)
- Numeric: 0-9 (10 possible characters)
- Alphanumeric + Symbols: A-Z, a-z, 0-9, !@#$%^&*() (72 possible characters)
Example:
Length: 12Character Set: AlphanumericPossible outputs: aB3xK9mPqR2n, Zx4Yt9Km3Pq1, etc.Use Cases:
- Temporary password generation
- Promo code creation
- Unique coupon codes
- Verification tokens
Examples
Section titled “Examples”1. Assign contacts to test groups (1-5)
Section titled “1. Assign contacts to test groups (1-5)”- Random Type:
Random Number - Minimum Value:
1 - Maximum Value:
5 - Output:
3
Save the output to a custom property like test_group_number and use it in workflow branches.
2. Generate unique order reference
Section titled “2. Generate unique order reference”- Random Type:
UUID v4 - Output:
a3bb189e-8bf9-3888-9912-ace4e6543002
Use this as a unique reference number for orders, tickets, or any record that needs a guaranteed unique identifier.
3. Create promo codes for campaign
Section titled “3. Create promo codes for campaign”- Random Type:
Random String - String Length:
8 - Character Set:
Alphanumeric - Output:
K9mP3xQz
Combine with a prefix using the Text Transform action: PROMO-K9mP3xQz
4. Generate temporary password
Section titled “4. Generate temporary password”- Random Type:
Random String - String Length:
16 - Character Set:
Alphanumeric + Symbols - Output:
aB3!xK9@mP#qR2$n
Security Note: While this generates a random password, remember that HubSpot workflows should not be used for production password management. Use established authentication systems for user passwords.
5. Random priority assignment
Section titled “5. Random priority assignment”- Random Type:
Random Number - Minimum Value:
1 - Maximum Value:
10 - Output:
7
Assign random priority levels to deals or tickets for load balancing across team members.
Common Use Cases
Section titled “Common Use Cases”A/B Testing & Experiments
Section titled “A/B Testing & Experiments”- Randomly assign contacts to test groups
- Create balanced cohorts for campaigns
- Random sampling for surveys
Unique Identifiers
Section titled “Unique Identifiers”- Generate order reference numbers
- Create unique tracking codes
- Produce correlation IDs for external systems
- Unique ticket or case numbers
Promotional Campaigns
Section titled “Promotional Campaigns”- Generate unique promo codes
- Create one-time use voucher codes
- Random discount percentages
Load Balancing
Section titled “Load Balancing”- Randomly assign records to team members
- Distribute leads evenly across queues
- Random priority assignment
Best Practices
Section titled “Best Practices”For Numbers
Section titled “For Numbers”- Use appropriate ranges: Keep ranges realistic (e.g., 1-100 for percentages, 1-10 for groups).
- Document your ranges: Note what different number ranges mean in your workflow descriptions.
- Consider distribution: Random numbers are uniformly distributed, so all values in the range are equally likely.
For UUIDs
Section titled “For UUIDs”- Perfect for uniqueness: UUIDs are statistically unique and ideal for reference numbers.
- Database friendly: Great for foreign keys or correlation IDs when integrating with external systems.
- Case sensitive: UUIDs include lowercase letters; normalize casing if needed.
For Strings
Section titled “For Strings”- Length matters: Longer strings are more unique. For promo codes, 8-12 characters is typical.
- Choose the right character set:
- Use numeric for PIN codes
- Use alphanumeric for general codes
- Add symbols only when extra security is needed
- Avoid confusion: Consider using Text Transform to remove ambiguous characters (0/O, 1/l) if codes will be manually entered.
General
Section titled “General”- Store the original: Save random values to properties immediately so you can reference them later.
- Handle duplicates gracefully: While random values are usually unique, for strings and numbers there’s always a theoretical chance of collision. UUIDs are the safest choice when uniqueness is critical.
- Test your workflows: Run test executions to verify the random values meet your requirements.
Randomness Quality
Section titled “Randomness Quality”All random generation uses cryptographically secure random number generation (crypto.getRandomValues() and crypto.randomUUID()), ensuring high-quality randomness suitable for security-sensitive applications like token generation.
Random Type Reference
Section titled “Random Type Reference”| Type | Output Example | Typical Length | Uniqueness |
|---|---|---|---|
| Random Number (0-100) | 42 | 1-3 chars | Low |
| Random Number (1-1000000) | 384729 | 1-7 chars | Medium |
| UUID v4 | 550e8400-e29b-41d4-a716-446655440000 | 36 chars | Extremely High |
| String (8, alphanumeric) | aB3xK9mP | 8 chars | High |
| String (16, alphanumeric+symbols) | aB3!xK9@mP#qR2$n | 16 chars | Very High |
Related Actions
Section titled “Related Actions”- Text Transform — Format or combine random values with prefixes/suffixes
- Webhook — Send random values to external systems for validation or storage