Table of contents


Official Content

This document explains the steps needed to integrate your chatbot with WhatsApp. You can use any Whatsapp partner, but in this article Twilio will be the example used.

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

Step 1. Configure the partner's account

This step depends on the Whatsapp partner you use.

As an example, see HowTo: Set up Twilio for Chatbots using Whatsapp.

Step 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.

Considerations

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.

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.

Last update: February 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant