Documentation Index
Fetch the complete documentation index at: https://plivo.com/docs/llms.txt
Use this file to discover all available pages before exploring further.
Overview
This guide shows how to use a voice one-time password (OTP) to verify a mobile number. We first make a call to the phone number to be verified and use text-to-speech to read a random sequence of digits to the call recipients. The user then confirms the digits by entering them using dialpad keypresses. Voice OTP is commonly used to verify new user registrations for an app or website. You can send a voice OTP either by using our PHLO visual workflow builder or our APIs and XML documents. Follow the instructions in one of the tabs below.- Using XML
Here’s how to use Plivo APIs and XML to implement voice OTPs.It generates a controller named plivo_controller in the app/controllers/ directory and a respective view in app/views/plivo. We can delete the view as we don‘t need it.Replace the auth placeholders with your authentication credentials from the Plivo console. Replace the phone number placeholder with an actual phone number in E.164 format (for example, +12025551234).toYou should see your basic server application in action as below:
Prerequisites
To get started, you need a Plivo account — sign up with your work email address if you don’t have one already. If this is your first time using Plivo APIs, follow our instructions to set up a Ruby development environment.Create a Rails controller
Change to the project directory and run this command to create a Rails controller for the voice OTP application.Create a voice OTP application
Edit app/controllers/plivo_controller.rb file and add this code.Note:
We recommend that you store your credentials in the
auth_id and auth_token environment variables, to avoid the possibility of accidentally committing them to source control. If you do this, you can initialize the client with no arguments and Plivo will automatically fetch the values from the environment variables. You can use ENV to store environment variables and fetch them when initializing the client.