Generate OTP
Last updated 3 weeks ago
The Generate OTP workflow action creates a secure one-time password (OTP) code for a contact. Use it to add verification steps to your HubSpot workflows -- for example, confirming a contact's identity before processing a sensitive request.
How It Works
Add the Generate OTP action to any contact workflow in HubSpot. When a contact reaches this step, the app generates a unique code based on your configured settings (code type, length, and expiry). The generated code and its expiration time are returned as output values that you can use in subsequent workflow steps -- for example, copying the code to a contact property or branching based on success/failure.
If email delivery is enabled in your app settings, the code is also emailed to the contact automatically. If HubSpot property storage is enabled, the code is written to the configured contact property so you can use it in HubSpot email templates via personalization tokens.
Action Inputs
When adding the Generate OTP action to your workflow, you configure the following fields:
| Field | Required | Description |
|---|---|---|
| Email Property | Yes | The contact property containing the email address used to identify the contact for OTP generation. |
| Preferred Language Property | No | The contact property for the contact's preferred language (e.g., hs_language). Determines the language of the OTP email. Falls back to English if empty. |
| Override App Settings | No | Enable to customize code length, expiry, and code type for this specific action instead of using the app defaults. |
| Code Length | No | Length of the OTP code. Only shown when Override App Settings is enabled. Options: 4 characters, 6 characters (default), 8 characters. |
| Expires In (Minutes) | No | How many minutes until the OTP expires. Only shown when Override App Settings is enabled. Options: 5, 10, 15, 30, or 60 minutes. |
| Code Type | No | Type of characters used in the OTP code. Only shown when Override App Settings is enabled. Options: Numeric (123456), Alphanumeric (A1B2C3), Alpha Only (ABCDEF). |
Action Outputs
After the action runs, the following values are available for use in subsequent workflow steps:
| Output | Type | Description |
|---|---|---|
| OTP Code | Text | The generated one-time password code |
| Expires At | Date | The date and time when the OTP code expires |
| Reference ID | Text | The email address (reference identifier) used for this OTP |
| Success | Yes/No | Whether the OTP was generated successfully |
| Error Message | Text | If something went wrong, this contains a description of the problem |
Tip: To learn how to use these output values in later workflow actions (e.g., copy to a property, use in branching logic), see Using workflow action outputs in the HubSpot Knowledge Base.
Usage Examples
Identity Verification Before a Sensitive Action
When a contact requests access to account information or submits a high-value form, verify their identity first.
- Trigger your workflow when a contact submits a sensitive form (e.g., "Request Account Data")
- Add the Generate OTP action and select the contact's Email property
- The OTP is generated and emailed to the contact (if email delivery is enabled)
- Use a delay + branch to check whether the contact verified the code before proceeding
Standard 6-Digit Verification Code
Use the app's default settings to generate a standard numeric code -- no overrides needed.
- Add the Generate OTP action to your workflow
- Select the Email property as the reference
- Leave Override App Settings disabled -- the action uses your app's configured defaults
- Use a "Copy property value" action to store the OTP Code output in a contact property for use in HubSpot emails
High-Security Alphanumeric Code
For scenarios requiring a stronger code (e.g., password reset, financial verification), override the defaults with a longer alphanumeric code.
- Add the Generate OTP action to your workflow
- Select the Email property as the reference
- Enable Override App Settings
- Set Code Length to 8 characters, Expires In to 15 minutes, and Code Type to Alphanumeric
- Branch on Success to handle errors gracefully
Tips
- Use Override App Settings sparingly. Most workflows work well with your app defaults. Only override when a specific workflow needs different parameters.
- Combine with property storage. If you plan to include the OTP in a HubSpot email template, enable "Store OTP in HubSpot Property" in your app settings so the code is available as a personalization token.
- Branch on Success. Always add a branch after the Generate OTP action to handle cases where generation fails (e.g., missing email address).
- Set the Preferred Language Property. If your contacts span multiple languages, map the
hs_languageproperty so OTP emails are sent in the contact's language.
Thank you for your feedback!
Your input helps us improve our documentation.
Was this page helpful?
Great! What worked best for you? How can we improve our product?
- Previous
- Use Cases
- Next
- Generate Otp