-
Notifications
You must be signed in to change notification settings - Fork 129
Adding SMS Messaging to Abot
Abot provides a simple HTTP interface to send messages across any service or protocol. In this guide, we'll focus on adding support for SMS text messaging.
Abot makes it easy to add support for multiple communication tools, including SMS, phone, email, Slack, etc. In this guide, we'll learn how to set up SMS, so we can communicate with this new digital assistant via text messages.
First we'll need an SMS provider. We'll use Twilio since we've already written a driver for that, but you can use any provider in the same way as here by fulfilling the interface defined in itsabot/abot/shared/interface/sms/driver
Sign up for Twilio here: https://www.twilio.com/. Take note of your assigned account SID, auth token, and Twilio phone number. You'll want to set the following environment variables in your ~/.bash_profile or ~/.bashrc:
export TWILIO_ACCOUNT_SID="REPLACE"
export TWILIO_AUTH_TOKEN="REPLACE"
export TWILIO_PHONE="REPLACE"
Be sure your TWILIO_PHONE
is in the form of +13105551234
. The leading plus symbol is required.
We'll also want to update our environment variables on Heroku, so run the following in your terminal:
$ heroku config:set TWILIO_ACCOUNT_SID=REPLACE \
TWILIO_AUTH_TOKEN=REPLACE \
TWILIO_PHONE=REPLACE
Now we'll add the Twilio driver. Since we've written a plugin for Twilio like any other, you can simply add it to your plugins.json like so:
{
"Name": "abot",
"Version": "0.1.0",
"Dependencies": {
"github.com/itsabot/plugin_onboard": "*",
"github.com/itsabot/twilio": "*"
}
}
Then from your terminal run:
$ abot plugin install
Installing 2 plugins...
Success!
The Twilio driver will automatically add a special POST /twilio route to Abot.
Let's also make sure that Twilio knows how to communicate with our app. Configure your Twilio account to POST to that route every time Twilio receives a message. To do that, go to (https://www.twilio.com/user/account/messaging/phone-numbers) and modify Request URL to be your-url.com/twilio set to HTTP POST. If you don't have a URL yet, learn how to deploy your Abot.
To try it out, let's first create an Abot account through the web interface. Go to your Abot domain (heroku open
) and click on Sign Up in the header at the top right. When entering your phone number, be sure to enter it in the format of +13105551234
, or Twilio will reject it.
Once you've signed up, send Abot a text at your TWILIO_PHONE
number from before. Sometimes responses via Twilio take a few seconds, but you should get a reply back shortly.
> Say hi
Hello World!
© Copyright 2015-2016 Abot, Inc.