Twilio SMS Adapter

To enable Twilio SMS as an engagement adaptor, a number of steps need to be followed :

  • Configure your endpoint
  • Register a Twilio account
  • Purchase an sms-enabled Twilio number
  • Configure Twilio in your ServisBOT organization

Prerequisites

  • You will need a working bot. Use our getting started tutorials if you need one. Make sure it is working by testing it using the default endpoint before proceeding.
  • Access to Twilio services with the ability to purchase an sms-enabled number

Create a new Twilio SMS Endpoint for your Bot

  • Set the endpoint target to be for your working bot
  • Change the endpoint type to Twilio SMS and save it.
  • A secret containing the following properties should be present:
    • Twilio accountSid
    • Twilio authToken
    • Twilio phone number

Example Endpoint Configuration

An Endpoint can be configured to allow communication between Twilio and ServisBOT. To do so, the EngagementType and EngagementConfig must be configured:

{
  "Address": "myorganization-twiliosms",
  "OutboundBotReference": "MySmsBot",
  "InboundBotReference": "MySmsBot",
  "EngagementType": "TwilioSms",
  "Status": "online",
  "AllowedDomains": [
    "*.servisbot.com",
    "https://servisbot.com"
  ],
  "EngagementConfig": {
    "Secret": "srn:vault::flowit:secretdoc:twiliokeys"
  },
  "Useragent": "useragent",
  "TargetBotReference": "MySmsBot",
  "Name": "MySms"
}

You will need the URL to your endpoint in order to configure your bot in Twilio.

Set up your phone number on Twilio

  • Login into the Twilio portal and search or navigate to the Phone Numbers section. Phone numbers
  • Login into the Twilio portal and search or navigate to the Phone Numbers section.
  • If you haven’t already, make sure to purchase an SMS-ready phone number in your preferred Country
  • Click on the number you would like to use from your Active Numbers list Active numbers
  • Scroll down to the Messaging sub-section Active numbers
  • Set the following options:
    • Configure with: Webhooks
    • A message comes in: Webhook / Messaging endpoint (see below for more details) / HTTP POST

The Messaging endpoint

The Messaging endpoint takes the form:

https://engagement.<sb-region>.servisbot.com/picard/v1/engage/<endpoint-address>

Example for the current public ServisBot Regions :

  • https://engagement.eu-1.servisbot.com/picard/v1/engage/myorganization-ClaimsBot
  • https://engagement.us-1.servisbot.com/picard/v1/engage/myorganization-ClaimsBot

Setup Twilio Secret

Get Twilio Credentials

  • Navigate back to the Twilio dashboard
  • Under “Project Info”, copy your Account SID and Auth Token.

Create ServisBOT Secret

  • Create a new ServisBOT secret of type Custom JSON

Here’s what the secret should look like:

{
  "accountSid": <your-twilio-account-sid>,
  "authToken": <your-twilio-auth-token>,
  "phoneNumber": <your-twilo-phone-number>
}
  • Edit the endpoint and assign your Twilio secret to it

Test your Bot

  • Send a text message to your Twilio number
  • A response will come back to you from your Bot

Supported Timeline Elements

Given the limitations of the SMS interface, only simple text messages (e.g. Dialogue node) and inputs are supported for this engagement adapter. Any other timeline element used in your bot will be discarded.