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.
This step depends on the Whatsapp partner you use.
As an example, see HowTo: Set up Twilio for Chatbots using Whatsapp.
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).
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.
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).
If the user receives no answer, please check:
- The partner logs. For example, the Twilio logs look as follows:
- Generator trace. For instance, activate the ASP Net trace when using .NET.
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.
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.
See Chatbots sample using WhatsApp.