Whatsapp is one of the most used messaging platforms in the world, replacing SMS in many cases. Setting up a Whatsapp channel is slightly more complex than some other channels but it can be a great way to get in touch with your audience!
There are two prerequisites for installing a Whatsapp bot in the CSML Studio.
you MUST have a verified Meta Business account
you MUST have a Meta Developer account
And more generally, you must be able to follow this guide to setup a Meta app correctly: https://developers.facebook.com/docs/whatsapp/business-management-api/get-started.
In your bot in CSML Studio, go to Channels > Connect a new channel, then select Whatsapp.
In the next screen, enter a name and description for your channel (it is purely informational and can be changed later) and add the required credentials.
The App ID and App Secret can be found in the app's Basic Settings page:
The User Access Token, Phone Number ID (and not the actual phone number!) and WhatsApp Business Account ID can be foud under Whatsapp > Getting Started. You can start with one of the Test numbers provided by Facebook, but in production you will want to change that to your own phone number once it is properly configured.
Then, click Save to setup the channel. In the following page, you will also receive your Webhook configuration parameters:
Use these parameters in the Whatsapp > Configuration page under Callback URL and Verify token. Make sure to also subscribe to the messages
Webhook field.
The final step before you can deploy this app to production is to verify your business (if not already done), and obtain the whatsapp_business_management
permissions.
Whatsapp supports the following components:
Simple texts
Wait()
and Typing()
Medias: Image(), Video(), Audio(), File()
Url()
Question()
and QuickReply()
Markdown is partially supported (only bold, italic and strikethrough).
Whatsapp provides an easy way to generate QR codes that let users reach your chatbot easily. You can read more about it here: https://developers.facebook.com/docs/whatsapp/business-management-api/qr-codes
As a security measure, user access tokens expire after about 60 days. If your Whatsapp chatbot remains unused for a longer time, the token will be automatically expired and you will need to reconnect your app to restore it.
Whatsapp has a very limited set of interactive components. Buttons for example are textual only, and your users will have to type the actual text of the button
The mapping of Question()
and Button()
components to text is performed automatically. However you need to set the right title
and accepts
values in order to correctly match the user's input.
The title of a button must be between 1-20 characters long. You can however manually set a longer payload if needed:
say Button("Click here!", payload="MY_BUTTON_CLICK_HERE_PAYLOAD")
The Url()
component does not support any alternative text or title. Only the given url will be shown as is.
For instance, the following code:
Has the following output:
You must upload videos in mp4 format. Videos hosted on platforms such as Youtube, Dailymotion or Vimeo will not display (use the Url()
component).
You must upload audio files in mp3 format. Audio files hosted on platforms such as Spotify, Deezer or Soundcloud will not display (use the Url()
component).
There is a hard limit of 25MB for all uploaded files (including image, video and audio files).
In a File()
component, not all file types are supported. A list of supported file types could not be found, but it is safe to recommend using very common file types only.
The file upload process happens asynchronously on Whatsapp, so messages might show out of order if there is a large upload with not enough time left for its upload before sending the next message.
Carousel()
and Card()
components are not supported.