Everyone has experienced IVRs (interactive voice response). It sounds something like this: “press 1 if you’re a developer, press 2 if you’re an awesome developer”. Here, we will show you how to build an IVR system that use’s HipChat APIs and post details of incoming calls, recordings and voicemails on your Plivo number to HipChat. After each call is complete, our bot also sends the URL of the call recording to the Chat room so that our sales team can have access anywhere anytime.
This app is essentially simliar to Google Voice. Think about Google Voice as an app that uses a single phone number that does routing/fowarding, transcription, email, SMS, IVR, and voicemail, which is exactly what we’re building here. This means that with a few changes to this HipChat API integration, you can build your own app that essentially emulates Google Voice. Be sure to look out for our follow up post that will feature this hack and include a GUI as well.
We are going to build our app using Flask, Heroku and Plivo. The goal of this tutorial is to get you started with Plivo APIs and XML and quickly prototype and deploy apps on heroku. We will be leveraging three Plivo XML elements, GetDigits, Dial and Speak to create this application.
Plivo Number, your
Plivo Auth ID, and your
Plivo Auth Token.
Get the latest source code by typing the following in the terminal and hit Enter.
$ git clone https://firstname.lastname@example.org/tsudot/wrench.git $ cd wrench
Open the file creds.py in this folder in your favorite text editor and add the Plivo and HipChat credentials.
PLIVO_AUTH_ID = “” PLIVO_AUTH_TOKEN = “” HIPCHAT_API_TOKEN = “”
Get the Plivo Auth ID and Auth Token from the dashboard.
Enable HipChat API Access by creating a token here
Open the file config.py in this folder in your favorite text editor. Create a HipChat roomand add it to the VOICEMAIL_HIPCHAT_ROOMS list.
# The first phone number the call needs to be forwarded to FIRST_CONTACT = ‘’ # Eg. 15555555555. Make sure you add the country code. # Needs to be a list of numbers the call will be broadcasted # if it does not get answered by the FIRST_CONTACT BROADCAST_CONTACTS = [’’] # Eg. 15555555555. Make sure you add the country code. # Add the Plivo Number you purchased in step 1. SMS_SOURCE_NUMBER = ‘’ # Needs to be a list of numbers. The SMS with the voicemail recording # will be sent to these numbers. VOICEMAIL_SMS_RECEIVERS = [’’] # Eg. 15555555555. Make sure you add the country code. # All notifications will be sent the HipChat Rooms. VOICEMAIL_HIPCHAT_ROOMS = [’’] #Add HipChat Room Names
Commit your changes.
$ git add creds.py config.py $ git commit -m ‘Adding credentials and config’
Create a heroku app by typing the following command in your terminal. Take a note of your app url, in this case it’s http://pacific-chh47397.herokuapp.com/
|$ heroku create Creating pacific-chamber-7397… done, stack is cedar http://email@example.com:pacific-chamber-7397.git Git remote heroku added|
Deploy your code to heroku and add the redistogo add on.
$ git push heroku master $ heroku scale web=1 $ heroku scale worker=1 $ heroku addons:add redistogo
Note: For each application, Heroku provides 750 free dyno-hours. To run more than 1 dyno, you may have to verify your heroku account. Make sure you scale down the dynos when you are done testing.
Click on the New Application button to create an application. Give a name to your application, let’s call it ‘Sales Line IVR’. Click on ‘Create’ upon done. Use the answer URL as http://(heroku app url)/response/forward/. Choose the GET method. Leave the other fields as it is for now. Note: Replace “heroku app url” with the the url returned when creating the heroku app in Step 6.
PLIVO_NUMBER. If you don’t yet have a number, you can claim your free local US phone number in the Numbers tab when you click on the “Claim your free local US number” link.
Click on the Plivo phone number you wish to associate with your new app, choose the application ‘Sales Line IVR’ in the dropdown and click ‘Update’
You are all set! Make a call to your Plivo Number and test it out.
Is anything on this page unclear? Suggest edits and help us improve our documentation!