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.
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:
- Create a Verify Service in your Twilio Console
- Obtain Verify Service SID - Found in the Verify service settings
- Configure Service Settings - Set code length, expiration time, and other parameters in Twilio Console
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 identifierservice_sid- Verify Service SIDto- Recipient phone numberchannel- Delivery channel used (sms or whatsapp)status- Verification status (pending)valid- Whether verification is valid (false until verified)date_created- Timestamp when verification was createddate_updated- Timestamp of last updatelookup- Phone number lookup informationamount- 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.
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:
- User enters phone number in registration form
- Send Verification Code - Send OTP to phone
- Display code entry form to user
- Check Verification Code - Verify the code entered by user
- If verified - Complete registration
- 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:
- User logs in with username/password
- Database Query - Get user's phone number
- Send Verification Code - Send OTP
- Display OTP entry screen
- Check Verification Code - Verify code
- If verified - Grant access
- 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:
- User requests password reset
- Database Query - Get user by email
- Send Verification Code - Send OTP to user's phone
- User enters code
- Check Verification Code
- If verified - Allow password change
- 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:
- User initiates transaction (e.g., wire transfer)
- If amount > $10,000
- Send Verification Code - Send OTP
- Display confirmation screen
- Check Verification Code
- If verified - Process transaction
- Else - Cancel transaction, alert security
- 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:
- Try
- Send Verification Code (Channel:
whatsapp)
- Send Verification Code (Channel:
- Catch (if WhatsApp fails)
- Send Verification Code (Channel:
sms)
- Send Verification Code (Channel:
- Display code entry form
- Check Verification Code
This ensures delivery even if user doesn't have WhatsApp.
Example 6: Account Recovery
Verify account ownership during recovery:
Flow Structure:
- User claims account ownership
- Send Verification Code to registered phone
- User enters code + answers security question
- Check Verification Code
- If verified AND security answer correct
- Grant account access
- 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
sidfrom 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:
smsorwhatsapp - 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
Related Nodes
- Check Verification Code - Verify the code sent to the user
- Connect - Create a Twilio connection for authentication
- Send SMS - Send regular SMS messages
- Send WhatsApp Message - Send WhatsApp messages