Outbound SMS Application

Short Message Service (SMS), is a simple text messaging service that allows mobile phone devices to exchange short text messages. SMS can have many different applications, including SMS notifications (e.g., bank balance), live information broadcasting (e.g., emergency alerts), two-factor authentication (i.e., requesting web access passwords via SMS), just to name a few.

The instructions below will teach you build your own simple SMS app that can: Send an outbound SMS message


1. Get a Free Plivo Trial Account

Sign up for a Free Developer account at Plivo.com.

2. Get a Heroku account and install the Heroku Toolbelt

Head over to the Heroku documentation, setup an account, and install the Heroku toolbelt. Note: you may also use your own servers, but to simplify things, we will use Heroku.

3. Install Flask (a Python microframework) and Plivo

Type the following into your console (i.e., Terminal for OS X, Command Prompt for Windows) . For more in-depth info, go to the Flask on Heroku tutorial. Note: If you don’t already have pip installed, you'll want to follow these guides: for Mac, Windows, and Linuxfirst.$ pip install flask plivo

Build the App

1. Tell Plivo where to send the SMS and what to send

Create a new file in your favorite text editor, copy the following code into it and save it as outbound_SMS.py. We essentially just created a route in flask which accepts the text and number from the web form.

import plivo

# Your PLIVO_AUTH_ID and PLIVO_AUTH_TOKEN can be found
# on your Plivo Dashboard https://manage.plivo.com/dashboard
PLIVO_AUTH_ID = "Enter your Plivo AUTH ID here"
PLIVO_AUTH_TOKEN = "Enter your Plivo AUTH TOKEN here"

# Enter your Plivo phone number. This will show up on your caller ID
plivo_number = "14153337777"

# Enter the phone number that you would like to receive your SMS
destination_number = "14153338888"

# Enter the SMS that you want to send
text = "Welcome to Plivo!"

message_params = {
print p.send_message(message_params)

2. Add your Plivo Credentials

Open the outbount_SMS.py file in your favorite text editor and add your PLIVO_AUTH_ID and PLIVO_AUTH_TOKEN (line 5 and 6 above). Get your PLIVO_AUTH_ID and PLIVO_AUTH_TOKEN from your Plivo Dashboard.

HipChat API Bot - Auth ID Token

Add any of your Plivo phone numbers found on your Numbers tab in the Plivo Dashboard to plivo_number (line 9). If you don't yet have a number, you can purchase one in the Numbers tab. Note: all phone numbers must precede with country and area code.

Add the destination_number (line 12) that you would like to receive your SMS

Add the message that you would like to send in text (line 15)

Finally run this script:$ python outbound_SMS.py and you're done.

Is anything on this page unclear? Suggest edits and help us improve our documentation!