Twilio WhatsApp Adapter

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

  • Configure your endpoint
  • Register a Twilio account
  • Purchase an WhatsApp-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 a whatsapp-enabled number.

Create a new Twilio WhatsApp Endpoint for your Bot

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

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-twiliowhatsapp",
  "OutboundBotReference": "MyWhatsAppBot",
  "InboundBotReference": "MyWhatsAppBot",
  "EngagementType": "TwilioWhatsApp",
  "Status": "online",
  "AllowedDomains": [
    "*.servisbot.com",
    "https://servisbot.com"
  ],
  "EngagementConfig": {
    "Secret": "srn:vault::myorganization:secretdoc:twiliokeys"
  },
  "Useragent": "useragent",
  "TargetBotReference": "MyWhatsAppBot",
  "Name": "MyWhatsApp"
}

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

Set up your phone number to be used with WhatsApp on Twilio

  • You will need to the following guide to enable your Twilio numbers to be used with WhatsApp https://www.twilio.com/docs/whatsapp/tutorial/connect-number-business-profile
  • Once you have a WhatsApp enabled number, make sure it matches the one in the secret.
  • Navigate to the configuration of the WhatsApp number you wish to use.
  • Set the following options:
    • Messaging endpoint (see below for more details) / HTTP POST

Active numbers

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": "ABC12337", //your-twilio-account-sid,
  "authToken": "uui1234dcu", //your-twilio-auth-token,
  "phoneNumber": "whatsapp:+141555555" //your-twilo-whatsapp-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

  • Card: Will display the image and title in the WhatsApp messenger.
  • StaticMap: Will display a map of the location in the WhatsApp messenger, with a clickthrough to the location on Google maps.
  • TextMsg or a Dialog node: Will display as a regular text message.