Skip to main content

Send Verification Code

Sends a verification code (OTP - One-Time Password) to a phone number using Twilio Verify API. This node is essential for implementing two-factor authentication (2FA), phone number verification, and secure user authentication flows.

Common Properties

  • Name - The custom name of the node.
  • Color - The custom color of the node.
  • Delay Before (sec) - Waits in seconds before executing the node.
  • Delay After (sec) - Waits in seconds after executing node.
  • Continue On Error - Automation will continue regardless of any error. The default value is false.
info

If ContinueOnError property is true, no error is caught when the project is executed even if Catch node is used.

Prerequisites

Before using Twilio Verify, you need to:

  1. Create a Verify Service in your Twilio Console
  2. Obtain Verify Service SID - Found in the Verify service settings
  3. Configure Service Settings - Set code length, expiration time, and other parameters in Twilio Console
tip

Twilio Verify handles code generation, delivery, rate limiting, and security automatically. You don't need to generate codes manually.

Input

  • Connection Id - The Twilio connection identifier from the Connect node. This is optional if you provide credentials directly in the Options.
  • To Number - The phone number to send the verification code to. Must be in E.164 format (e.g., +14155552672).

Output

  • Response - The Twilio Verify API response containing verification details including:
    • sid - Unique verification identifier
    • service_sid - Verify Service SID
    • to - Recipient phone number
    • channel - Delivery channel used (sms or whatsapp)
    • status - Verification status (pending)
    • valid - Whether verification is valid (false until verified)
    • date_created - Timestamp when verification was created
    • date_updated - Timestamp of last update
    • lookup - Phone number lookup information
    • amount - Number of verification attempts

Options

  • Verify SID - Your Twilio Verify Service SID. This identifies which Verify service to use. Required for all verification operations.
  • Channel - The delivery channel for the verification code. Options:
    • whatsapp - Send code via WhatsApp (default)
    • sms - Send code via SMS
  • Account SID - Your Twilio Account SID. This is optional if you're using a Connection Id from the Connect node.
  • Auth Token - Your Twilio Auth Token. This is optional if you're using a Connection Id from the Connect node.
info

WhatsApp delivery is often preferred because it's more secure and typically has higher delivery rates than SMS. However, the recipient must have WhatsApp installed.

Examples

Example 1: User Registration with Phone Verification

Verify phone number during user registration:

Flow Structure:

  1. User enters phone number in registration form
  2. Send Verification Code - Send OTP to phone
  3. Display code entry form to user
  4. Check Verification Code - Verify the code entered by user
  5. If verified - Complete registration
  6. Else - Show error, allow retry

Configuration:

  • To Number: {{registration_phone}}
  • Channel: sms
  • Verify SID: VA1234567890abcdef1234567890abcdef (from Vault)

Output Example:

{
"sid": "VE1234567890abcdef1234567890abcdef",
"service_sid": "VA1234567890abcdef1234567890abcdef",
"to": "+14155552672",
"channel": "sms",
"status": "pending",
"valid": false,
"date_created": "2024-01-15T10:30:00Z"
}

Example 2: Two-Factor Authentication (2FA)

Add 2FA to login flow:

Flow Structure:

  1. User logs in with username/password
  2. Database Query - Get user's phone number
  3. Send Verification Code - Send OTP
  4. Display OTP entry screen
  5. Check Verification Code - Verify code
  6. If verified - Grant access
  7. Else - Deny access, log attempt

Configuration:

  • To Number: {{user.phone}}
  • Channel: whatsapp (more secure)
  • Verify SID: From Vault

Example 3: Password Reset Verification

Verify user identity during password reset:

Flow Structure:

  1. User requests password reset
  2. Database Query - Get user by email
  3. Send Verification Code - Send OTP to user's phone
  4. User enters code
  5. Check Verification Code
  6. If verified - Allow password change
  7. Else - Block reset attempt

Message to User:

We've sent a verification code to your phone number ending in {{last_4_digits}}.
Please enter the code to continue with password reset.

Example 4: Secure Transaction Confirmation

Verify high-value transactions:

Flow Structure:

  1. User initiates transaction (e.g., wire transfer)
  2. If amount > $10,000
    • Send Verification Code - Send OTP
    • Display confirmation screen
    • Check Verification Code
    • If verified - Process transaction
    • Else - Cancel transaction, alert security
  3. Else - Process normally

Configuration:

  • To Number: {{user.primary_phone}}
  • Channel: sms

Example 5: Multi-Channel Verification with Fallback

Send via WhatsApp with SMS fallback:

Flow Structure:

  1. Try
    • Send Verification Code (Channel: whatsapp)
  2. Catch (if WhatsApp fails)
    • Send Verification Code (Channel: sms)
  3. Display code entry form
  4. Check Verification Code

This ensures delivery even if user doesn't have WhatsApp.

Example 6: Account Recovery

Verify account ownership during recovery:

Flow Structure:

  1. User claims account ownership
  2. Send Verification Code to registered phone
  3. User enters code + answers security question
  4. Check Verification Code
  5. If verified AND security answer correct
    • Grant account access
  6. Else
    • Block attempt, notify user via email

Tips

  • Phone Number Format - Always use E.164 format: +[country code][number]. Example: +14155552672.
  • Service Configuration - Configure code length, expiration time, and attempts in Twilio Console Verify settings.
  • Channel Selection - WhatsApp is more secure and has higher open rates, but requires WhatsApp installation. SMS works universally.
  • Code Expiration - Verify codes expire after 10 minutes by default (configurable in Verify service settings).
  • Rate Limiting - Twilio Verify automatically rate limits to prevent abuse. Don't implement your own rate limiting.
  • Max Attempts - By default, users get 5 attempts to verify. Configure this in Verify service settings.
  • Response Handling - Store the sid from Response if you need to track verification status separately.
  • User Experience - Inform users which channel (SMS/WhatsApp) the code will arrive through.
  • Security - Never log or store verification codes. Let Twilio Verify handle security.
  • Cost - Verify API pricing is separate from regular SMS/WhatsApp pricing. Check Twilio pricing for your region.
  • Testing - Use verified phone numbers during development to avoid costs.

Common Errors

Empty To Number

Error: "ErrInvalidArg: To Number cannot be empty"

Solution:

  • Ensure the To Number field is populated
  • Check that your data source contains a valid phone number
  • Verify the variable name matches your flow data

Invalid Phone Number Format

Error: "ErrSendCode: Error sending Code: Invalid 'To' Phone Number"

Solution:

  • Use E.164 format: +[country code][number]
  • Remove spaces, dashes, or parentheses from phone numbers
  • Ensure country code is included (e.g., +1 for US/Canada)
  • Example: +14155552672 (correct), 415-555-2672 (incorrect)

Invalid Verify SID

Error: "ErrInvalidArg: No SID Value"

Solution:

  • Ensure Verify SID is configured in Options
  • Verify the Verify SID is stored correctly in Vault
  • Check that the SID starts with "VA" (Verify Service SID)
  • Create a Verify Service in Twilio Console if you haven't already

Service Not Found

Error: "The requested resource was not found"

Solution:

  • Verify the Verify SID is correct
  • Ensure the Verify Service exists in your Twilio account
  • Check you're using the Verify Service SID (starts with "VA"), not a verification SID
  • Verify your Account SID and Auth Token are for the correct Twilio account

Max Send Attempts Exceeded

Error: "Max send attempts reached"

Solution:

  • User has requested too many codes in a short time
  • Wait before sending another code (default: 10 seconds between sends)
  • This is a security feature to prevent abuse
  • User must wait or verify with an existing valid code

Invalid Channel

Error: Invalid channel or channel not available

Solution:

  • Use only supported channels: sms or whatsapp
  • Ensure your Verify Service has the channel enabled
  • For WhatsApp, verify your Twilio account has WhatsApp enabled
  • Check channel name is lowercase

Phone Number Not Reachable

Error: "Phone number is not reachable" or delivery failed

Solution:

  • Verify the phone number is correct and active
  • Check the phone has service and is turned on
  • For WhatsApp channel, ensure recipient has WhatsApp installed
  • Try SMS channel as fallback
  • Verify the number is not blocked or blacklisted

Verify Service Not Configured

Error: Verify service configuration error

Solution:

  • Complete Verify Service setup in Twilio Console
  • Configure code length, expiration, and other settings
  • Ensure Verify Service is in active status
  • Check service has sufficient configuration for your use case

Authentication Failed

Error: Authentication or credential errors

Solution:

  • Verify your Connection Id is valid (from Connect node output)
  • If using direct credentials, check Account SID and Auth Token are correct
  • Ensure credentials are stored properly in Vault
  • Verify your Twilio account is active and in good standing