Phone Menu App
An IVR (Interactive Voice Response) system is also known as phone menu system. It is an automated phone system that interacts with a caller via pre-recorded or dynamic text-to-speech messages and inputs, via the keypad.
IVR systems are popular as they can handle large call volumes and help reduce the costs associated with customer service. With our app, you can build an entire phone menu system on the Plivo platform (in any computer language), without relying on expensive physical infrastructure.
The instructions below will teach you how to build your own IVR system that can:
- read a random joke (from Reddit) if ‘1’ is pressed
- play a song if ‘2’ is pressed
- say “Sorry, I didn’t catch that. Please hang up and try again later.” if nothing is pressed
The app will operate in the following sequence:
- The user dials the Plivo IVR phone number.
- The user is prompted with the message “Welcome to the Plivo IVR Demo App. Press 1 to hear a random joke. Press 2 to listen to a song.”
- During the call, if the user presses ‘1’, then Plivo reads a random joke from Reddit. If the user presses ‘2’, then Plivo plays a song.
- If anything else is pressed or if the user does nothing, then Plivo says “Sorry, I didn’t catch that. Please hang up and try again later.” and hangs up.
Note: We use Python in this tutorial, but you can write your apps in any programming language. Check out Plivo’s pre-built Helper Libraries for details.
Sign up for a free developer trial account at Plivo.com.
Note: You may also use your own servers, but to simplify things, we will use Heroku.
Get the application source code
Clone the source files from github by typing the following command into your console:
git clone https://github.com/plivo/phone-ivr-python.gitNote: If you don’t already have pip installed, you'll want to follow this guide.
Run the app locally. In your console, navigate to the folder
phone-ivr-pythonand run the app, by typing the following into your console:
cd phone-ivr-python virtualenv --distribute venv source venv/bin/activate pip install -r requirements.txt python app.py
Understand the XML
When a call comes in, the XML is what controls the call and
tells Plivo what to do with that call. The two XML elements we use here
<GetDigits> recognizes the digits
pressed during the call as an HTTP request to perform the action specified
in the action URL, while
<Speak> reads the text that’s specified.
Click http://localhost:5000/response/ivr/ to access your app XML and verify it the same XML as shown below.
Deploy your app on Heroku
Create a Heroku app by typing the following commands into your console:
heroku create git push heroku master heroku scale web=1
Creating pacific-chamber-7397... done, stack is cedar http://pacific-chamber-7397.herokuapp.com/ | email@example.com:pacific-chamber-7397.git Git remote heroku added
Type your Heroku app URL in your web browser to verify that your app is working.
Create a new Plivo application
Sign into your Plivo account.
Create a Plivo application by clicking on the ‘New Application’ button in the Applications tab.
Give a name to your application (next to Application Name), lets call it ‘Phone IVR’.
Fill in the Answer URL field with your Heroku app URL appended by /response/ivr/
For example, our Answer URL will look like this:
Choose the GET Answer method and leave all other fields as is. Click on ‘Create’ to save.
Assign a Plivo phone number to your app
Then select ‘Phone IVR’ (name of the app) from the Plivo App dropdown list.
Click ‘Update’ to save.
Call your Plivo phone number to see how the IVR application works.
Is anything on this page unclear? Suggest edits and help us improve our documentation!