Chatbots using Whatsapp: How to set up Twilio

Official Content
This documentation is valid for:

Here we explain how to setup Twilio in order to use Whatsapp as a messaging platform for the Chatbot generator.

Twilio Sandbox for WhatsApp allows you to prototype with WhatsApp immediately, without waiting for your Twilio number to be approved for WhatsApp.

Summary

Creating the account

First, create a new account in Twilio.

image_201994155718_1_png

You'll be asked to verify your email:

image_20199513421_1_png

Then, you'll be asked to verify your phone number:

image_201995134351_1_png

Joining the sandbox

You'll have to go through some steps:

image_2019913162343_1_png

image_2019913162411_1_png

Here you can skip to dashboard:

image_2019913162437_1_png

Then go through  "All Product & Services" and select "Programmable Messaging". In a new window that appears, you have to select "WhatsApp" and it asks you if you want to activate the Sandbox.

To activate the sandbox, a page like this one appears:

image_2019913162539_1_png

Select a number from the available sandbox numbers:

WA_Sandbox.png

There's a learn tutorial which you can follow easily.

The sandbox is pre-provisioned with a Twilio phone number.
Send “join <your sandbox keyword>” to your Sandbox number in WhatsApp to join your Sandbox.

image_202091217408_1_png

After joining, you will receive a message from the sandbox:

image_201994161028_1_png

See here for more details.

Configuring inbound message webhooks

When customers send you a WhatsApp message, Twilio sends a web hook to your application.

On the sandbox page you have to configure the URL that Twilio sends a web hook to for inbound messages.

The Chatbot generator creates a webhook (see Howto: Chatbots using WhatsApp), under the instance's module. 

After building it, configure the URL as follows:

http://<server>/<baseURL>/<InstanceModule>.WhatsappWebhook.aspx (.NET) or http://<server>/<baseURL>/<InstanceModule>.WhatsappWebhook (Java)

This has to be configured going through "Programmable Messaging -> Settings -> Whatsapp sandbox settings". Note that the machine where the webhook is hosted, has to be visible from Internet:

image_2020912174838_1_png

Configuration Settings

In the console page, you have the Account SID and an Authorization Token. These credentials are needed to the interaction with Twilio.

Account SID - Used to identify yourself in API requests
Auth Token  - Used to authenticate REST API requests

image_20209121814_1_png

The Auth Token is the information needed when you send messages through Twilio. This is the information to be configured in the WebHook

Note:

If you have joined your Sandbox > 24 hours ago, you will need to send a fresh inbound message to your WhatsApp number in order to then send yourself a media message. Otherwise, you'll get the "ERROR - 63016
Failed to send freeform message because you are outside the allowed window. Please use a Template."