One-Time Passcodes (OTPs) are a simple and effective way to verify someone's phone number at sign up for ongoing login verification, preventing bots, ensuring deliverability to the right person, and more.
Phone number verification can decrease fraud and increase deliverability and trust. Luckily the Twilio Verify API makes it easy to send and check OTPs. Let's see how to get started with Verify in under 5 minutes.
Prerequisites for sending One-Time Passcodes
Before you can send an OTP you'll need:
- A Twilio account - sign up or sign in
- A Verify Service which you can create in the Twilio console. The Service Name will appear in the SMS body but you can always edit it later.
Copy your Service SID (starts with VA):
Quick Deploy a Twilio Verify application
Make sure you're logged in to Twilio and head over to Twilio's Code Exchange for the One-Time Passcode verification project and paste in your Verify Service SID:
Next, click "Deploy my application". After a few seconds you should see a button to launch the live application: click that to go to your new Verify application.
Enter your phone number and hit Verify
to test it out. It's really that easy!
How to use the Verify OTP Quick Deploy application
You might have noticed that this application doesn't actually protect anything, but if you're like me, you love having code to copy and modify. This application gives you the following building blocks:
- International telephone input (more details in this post)
- Sending an OTP
- Checking an OTP
You could use this as a basis for issuing a blue checkmark, sending secret messages to your loved ones, or as the basis to send and check verifications in your own application. The email channel requires a smidge more setup but all of the instructions are outlined in the documentation.
For a look at how to install and run this code with the Twilio CLI, check out this blog post or find the code on GitHub.
Check out these Quick Deploy projects for more inspiration:
- International telephone input
- Conference Line with Phone Verification
- Fast Checkout with SMS Verification
I can't wait to see what you build!