Build: HipChat API + Plivo Integration for Sales Line Bot
We've built a HipChat IVR Bot that sends real-time call information to our own "Sales Call" room to give our sales team caller and routing info. 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.
Follow the instructions below to build your own Sales Line Bot!
Build this Integration Yourself with $15 Free Plivo Credits! First 500 registered users get $15 worth of free credits on Plivo. Claim your credits here: https://manage.plivo.com/accounts/register/?promo=hipchat
Here's a demo video:
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.
- 1. Sign up for a Plivo account using this link and get $15 of credit to try out our APIs.
- 2. Head over to the Heroku documentation to get accquianted on how to setup an account and install the Heroku toolbelt.
- 3. Create a HipChat account which will be used to send out notifications of calls coming in to your Plivo number
- 4. Installed Python and Virtualenv. See this guide for guidance.
1. Sign in to your Plivo account dashboard, and buy a number. Enter a prefix or an area code, make sure 'SMS enabled' is checked and click on Search.
Click on Buy, choose the 'Demo Speak' app from the dropdown for now and click on 'Confirm'. To test it out, you can call your Plivo number which will appear after you click 'Confirm' and listen to the sample message.
2. 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
3. Open the file creds.py in this folder in your favorite text editor and add the Plivo and HipChat credentials.
Get the Plivo Auth ID and Auth Token from the dashboard.
PLIVO_AUTH_ID = "" PLIVO_AUTH_TOKEN = "" HIPCHAT_API_TOKEN = ""
Enable HipChat API Access by creating a token here
4. Open the file config.py in this folder in your favorite text editor. Create a HipChat room and 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
5. Commit your changes.
$ git add creds.py config.py $ git commit -m 'Adding credentials and config'
6. 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-chamber-7397.herokuapp.com/
$ heroku create 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
7. 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
8. We'll create a Plivo application and point it to the number you purchased in step 1. Open https://plivo.com/app/ in your browser.
Click on the New Application button to create an application. Give a name to your application, lets 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.
9. Go to the Plivo Number Page
Click on the number you purchased in Step 1. Choose the application 'Sales Line IVR' in the dropdown and click 'Update'
10. You are all set. Make a call to your Plivo Number and test it out.