Digital Developer Conference: Cloud Security 2021 – Build the skills to secure your cloud and data Register free

Update your chatbot on WhatsApp with IBM Watson Assistant

Chatbots are everywhere. Today, many businesses use them to increase productivity and to provide a better customer experience. Chatbots can perform or automate different tasks or functions, but also allow for the option to hand off the conversation or task to a human if needed. With IBM Watson Assistant, you can quickly build conversational interfaces into any application, device, or channel.

In this tutorial, learn how to extend a Watson Assistant chatbot’s capabilities by connecting it to WhatsApp using Twilio. The tutorial uses Twilio’s sandbox to show how this integration works.

Architecture diagram


To follow this tutorial, you need:

In this tutorial, it’s assumed that you are familiar with Watson Assistant and how it works. Therefore, the tutorial focuses only on integrating Watson Assistant with WhatsApp. If you’re not familiar with Watson Assistant, you can use the Get started with Watson Assistant learning path to get started.


Setting up and syncing accounts

  1. Navigate to your Watson Assistant service in IBM Cloud.

  2. Click Connect on the left side.

    Connect menu

  3. Click Add Channels.

    Adding channels

  4. Choose WhatsApp with Twilio, and then click Add.

    Selecting WhatsApp

  5. Set the Account SID and Auth token that you can get from Twilio. Go to your Twilio account (if you don’t have an account, you can create one), and copy your Account SID and Auth token that are in the home dashboard. Click Show to reveal the token.

    Account information

  6. Return to your Watson Assistant instance, and complete the Account SID and Auth token fields with the values that you got from Twilio.

    Watson Assistant Account SID Auth token

  7. Click Sync Account, and wait until you see that the account is synced. After it’s synced, you see a webhook URL generated in the WhatsApp Webhook field. Copy this URL, and return to Twilio.

    Webhook Sync account

Configuring and using Twilio sandbox

To set up and configure your Twilio sandbox to integrate it with Watson Assistant:

  1. In your Twilio Account, click the icon that represents all of the products and services (it’s below the home icon) on the left.

  2. Go to Programmable Messaging from the expanded menu, select TryWhatsApp, then select Send a WhatsApp message under the Try it out section.


  3. Send the given code/message to the number provided by Twilio from your WhatsApp.

    sending message

  4. You should see a message on Twilio similar to the following image.

    Twilio message

    This indicates that your phone number is connected to this Twilio-WhatsApp sandbox.

  5. Click Next: Send a One-Way Message. This screen lets you set a template if you’re working with a one-way message such as appointment reminders, order notifications, or verification codes. In these instances, only the service is talking to the user. You ignore this step in this tutorial, so click Next: Send a Two-Way Message.

  6. Two-way messaging lets both the user and the service send messages, which results in a conversation. The service triggers a 24-hour conversation window during which the conversation can take place. Send a reply to the message that you received on WhatsApp, and click Next: Configure Your Sandbox.

    Configure 2-way messaging

  7. Paste the Webhook URL that you have from Watson Assistant into the When a message comes in field. You should see your number in the sandbox participants, and others can enter this sandbox by sending the code mentioned to the sandbox WhatsApp number (in the following image, the code is join design-thumb). Click Save.

    Saving webhook

  8. Now, the Watson assistant is integrated with WhatsApp through Twilio. From your device, send a WhatsApp message to the WhatsApp sandbox number, and you receive the assistant’s response.

    Receiving message


This tutorial explained how to integrate your Watson assistant with WhatsApp through Twilio, using the WhatsApp-Twilio sandbox to show how this integration works.

If you want to use WhatsApp-Twilio with the assistant for a real use case, then you must have a premium Twilio Account, a Facebook Business Manager ID, and apply for permission. You can find more information about this. You can also watch the video for this tutorial.