Howto: Chatbots using WhatsApp

Official Content
This documentation is valid for:

This document explains the steps needed to integrate your chatbot with WhatsApp. Here we take the example of Twilio but you can use any Whatsapp partner.

The architecture is as follows: The Whatsapp partner (e.g: Twilio) receives the user messages and there is a webhook to process those messages (the webhook must be configured on the Whatsapp partner). It should interact with some procedures of the GeneXusChannels module so the messages are formatted, and sent to the chatbot.
At the end of the process, the response message is sent to the partner to be sent to the user's WhatsApp. 
In the webhook procedure, the Authorization Token given by the partner, should be set.

Below is the architecture schema and details on the solution.

image_2019102172258_1_png

1. Configure the partner's account

This step depends on the Whatsapp partner you use.

As an example, see Chatbots using Whatsapp: How to set up Twilio.

2. Creating the Webhook

The Webhook is automatically generated by configuring in the KB the following properties:

It's generated under the instance's module, and its name is WhatsappWebhook.

Warning: The URL to the web hook should include the module. I.e, in .NET: http://server/baseURL/moduleName.WhatsappWebhook.aspx.

The Auth Token of the partner is stored in the configuration file (GXCF_Chatbots.config).

Message data type

The following are some of the data types used, which are part of the GeneXusChannels Module.

The Message SDT belongs to the GeneXusChannels Module and allows you to specify the messages to send. Define messages of a specific type, such as grids, videos, images, etc. 
It supports sending a text message and a payload for multimedia.

image_201910216726_1_png

ChannelConfiguration data type

This SDT is used for storing the information returned by the channel.
It allows specifying the channel (Messenger, Whatsapp) and the configuration parameters (collection Key - Value pair).

image_201910216155_1_png

Troubleshooting

If the user receives no answer, please check:

  1. The partner logs. For example, the Twilio logs look as follows:

    image_2019103111122_1_png
     
  2. Generator trace. For instance, activate the ASP Net trace when using .NET.

See also

In order to add integrate to any Whatsapp partner that is not included in the list of partners given by the WhatsApp Partner property, you can do it following the Howto: Integrate a new WhatsApp partner into a GeneXus Chatbot document.

Note: Chatbot without NLP (command oriented)

If you want to have a chatbot that doesn't use NLP (Natural Language Processing), you don't need to call the SendMessageFromChannel procedure. You only need to use the WhatsappTwilioWebhook to load the ChannelConfiguration, then process the &Message received, and use the GeneXusChannels.Message.SendMessage procedure to send the response to the final user.

In this case you only need the GeneXusChannels module (you don't need to install the Chatbot module).

Since GeneXus 16 upgrade 10 the Chatbot generator generates automatically the kind of chatbots that do not use NLP. See Scripted Chatbots.

Sample

See Chatbots sample using WhatsApp.