Photo by McDobbie Hu on Unsplash

Integrate IBM Watson Assistant With WhatsApp Using Twilio

How To Setup Your Sandbox Environment Within Minutes

Introduction

A digital assistant, be it voice or chat based, needs to be surfaced via some kind of medium. The list of mediums are growing at a rapid pace, especially in the case of voice based assistants. In the case of chat assistants, there are a myriad of mediums all with varying degrees of design affordances.

Most popular global mobile messenger apps as of January 2021, based on number of monthly active users.

There are a few considerations when it comes to deciding on which chat medium to launch with.

The first consideration being user critical mass. There needs to be critical mass in terms of the number of users and continued adoption of the chat medium.

Apart for the number of users, there is also the question of geography. In certain regions, specific cat mediums or applications are more popular than others.

Countries with the highest growth of WhatsApp downloads from the Google Play Store as of 1st quarter 2021.

Hence knowing what domain your chatbot will address and what your target geography is plays a big role in your choice of chat application.

There has been growth in WatsApp, but also alternatives like Telegram and Signal.

For the purpose of this story we are going to focus on the deployment of a IBM Watson Assistant to WhatsApp. It needs to be noted that WhatsApp API access is tightly governed and controlled by Facebook and not readily accessible like other API’s; for instance Facebook, Telegram or Slack. Hence you will not see many tutorials on WhatsApp integration, as compared to…say for instance Slack.

Twilio has a sandbox environment which gives you quick access to a temporary WhatsApp API, allowing you to test via your phone all the features available on WhatsApp. This is the approach we are going to follow for this story.

IBM Watson Assistant Basic Architecture

First, a brief overview of IBM Watson Assistant’s architecture.

IBM Watson Assistant is constituted by two main component. An Assistant and one or more skills. This story is about how to orchestrate multiple skills, and multiple skill types within an Assistant.

Integrations of IBM Watson Assistant with various mediums.

The basic components of Watson Assistant. The basic architecture of Watson Assistant consists of two main parts; skills and an assistant.

The basic components of Watson Assistant. The basic architecture of Watson Assistant consists of two main parts; skills and an assistant.

Each skill type, of which there are three, has a specific use-case; this can be extended of course. However, used out of place, can seriously impede the scaling of your chatbot.

Let’s start with the difference between an Assistant and Skills

The assistant can be seen as the container of the conversational agent.

The assistant also houses the skills, and the assistant also facilitates the connectors to the integration mediums.

The Assistant direct requests down the optimal path for solving a customer problem.

By adding skills, your assistant can provide a direct answer to an in domain question or reference more generalized search results for requests more complex.

Sequence Of Events For Integration

In the Assistant section of IBM Watson Assistant, the integration type can be selected.

Integration options are available in the Assistant section.

The list op integration options here is growing, with chat integration options and also live agent handover integration options.

Obviously custom integration can also be performed, and a coded abstraction layer facilitating integration will be desirable in many enterprise environments. This will add to the ability of the integration to scale and adopt additional functionality.

In the Assistant section, you can choose a channel to deploy the assistant to.

We are going to select the button Add integration.

This takes us the the integration page, with amongst other things, third party integration options. In a previous story the SMS integration option was covered in detail.

Third party integration options available in IBM Watson Assistant.

In this scenario we are selecting the WhatsApp with Twilio option. The next page is the create page with information guiding you on the requirements. The integration is much easier than what I anticipated; which will be evident shortly.

WhatsApp with Twilio create page.

At this stage let’s jump over to the Twilio environment to buy our number. We are choosing to search in the Dallas locality as this is where the Watson Assistant is deployed to. SMS is selected, as this is what we are interested, for now.

Searching for a number to buy in the Dallas locality.

A list of numbers are listed which can be bought for a monthly fee of 1 USD. We click on the Buy button for any of the numbers.

A list of numbers are presented which can be bought for a monthly fee.

A screen confirming the price and the capabilities of the number is presented. From here the final commitment is made to buy the number.

A screen confirming the price and the capabilities of the number.

Once the number is secured programmable messaging can be selected where the Try WhatsApp option is available. This interface takes you through a neat step by step guide for setup.

This interface takes you through a neat step by step guide for setup.

You can link your Testing Sandbox by sending a key word to the number from your phone via WhatsApp. If successful, the interface will confirm the message was received successfully.

You can link your Testing Sandbox by sending a key word to the number.

The next step is to setup two-way messaging. You can reply to the WhatsApp notification on your phone.

Setting up two way messaging.

Now that we are this far in Twilio, let’s go back to IBM Watson Assistant. Starting with the Basic setup, paste the Twilio Account SID and Auth token visible from the Twilio dashboard view.

Entering these two values will activate the Sync account button which you can click on and allow the short Syncing account process to run.

Paste the Twilio Account SID and Auth token visible from the Twilio dashboard view.

After syncing the webhook address is show. Copy this unique webhook and paste it in the WhatsApp Sandbox Settings section, in the incoming message HTTP Post window.

Webhook address to be used in Twilio configuration

Keep the settings the same, but paste the Watson Assistant webhook in the incoming message HTTP post window and save this setting.

Inserting the webhook address from IBM Watson Assistant in the http post window on Twilio.

Below is our WhatsApp conversation before and after the inbound URL is changed. The response is fast and makes for a good demo or prototype environment.

A WhatsApp conversation before and aster the inbound URL is set.

Useful Features

There are a few other useful features for WhatsApp with Twilio within IBM Watson Assistant. One being click to chat. This feature gives you a URL which can be imbedded in an App or on the web. Users can simply click the link to start a conversation.

Adding WhatsApp click to chat url.

Add the WhatsApp phone number and an optional pre-filled message for when the conversation starts.

Advanced options are available as seen below.

Advanced options for error handling, agent connection and handling buttons.

Conclusion

These auto integration features are really useful, but I still have the notion that larger enterprise-like implementation will necessitate a mediation layer or sorts.

The moment you want to introduce some kind of intelligence in the integration layer, this type no-code integration will not suffice.

Still these integration options are useful and can serve as a starting point, IBM is catching up to Microsoft in terms of pre-built integration points available.

NLP/NLU, Chatbots, Voice, Conversational UI/UX, CX Designer, Developer, Ubiquitous User Interfaces. www.cobusgreyling.me