How to use WhatsApp Business API in my chatbot
Automate your WhatsApp conversation by using our flow builder in the Kata Platform. Create bots to reply to end-users with several bot action types:
- Text
- Image and Image with Caption
- 🎉 NEW 🎉 List Message
- 🎉 NEW 🎉 Reply Button
Bot response types
Text
About
Reply to your chatbot users (“end-users”) by sending them text as a primary response.
Here is an example of a text response to end-users.
How to Use
- Go to the Kata Platform and select your project.
- Click to Flow > Conversation Flow > State > Action List.
- Choose Textand enter the text you want to send.
- Click Create Action to finalize your action.
Image and Image with Caption
About
Send images to your users on WhatsApp. You can also add a caption for the image.
Here is an example of image response and using caption to end-users.
How to Use
- Go to the Kata Platform and select your project.
- Click to Flow > Conversation Flow > State > Action List.
- Choose Image and enter the Image and Thumbnail URL.
- The image caption is optional.
- Click Create Action to finalize your action.
🎉 NEW 🎉 List Message
About
Send a list of options your users can choose. You can provide up to 10 options (“rows”) from a List Message.
Here is an example of a List Message response to end-users.
Composition
- Header type
- Header composition
- Section and Row
How to Use
Follow these steps to create a new List Message
-
Go to the Kata Platform and select your project.
-
Click to Flow > Conversation Flow > State > Action List.
-
Choose**List Message.**This action type only works on WhatsApp. Adding this on other channels will result in an error.
-
Fill in the fields.
-
You should know some critical notes on List Message: (1) “Section” has no limit. You can add as many sections as you want; (2)You can create up to 10 rows; (3) “Row ID” in the same section must be unique. For example:
- You make a section called “FAQ Topics.”
- Inside FAQ Topics, you have 3 rows.
- Those 3 rows inside FAQ Topics can’t use the same ID.
6. Click Create Action to finalize your action
After end-users click any options, the bot must execute a response based on the clicked option. You can map the selected option by end-users using row title or row id.
-
Using row
title
. For example:context.chosen == payload.postback.title
-
Using row
id
. For example:context.chosen == payload.postback.id
🎉 NEW 🎉 Reply Button
About
The reply button allows users to send a reply to the chatbot quickly. In addition, you can create up to 3 buttons.
Here are examples of Reply Button responses to end-users.
How to Use
Follow these steps to create a new Reply Button.
-
Go to the Kata Platform and select your project.
-
Click to Flow > Conversation Flow > State > Action List.
-
Choose**Reply Button.**This action type only works on WhatsApp. Adding this on other channels will result in an error.
-
Fill in the fields. Some critical notes on the Reply button that you should know:
- “Button ID” must be unique when creating action.
- The maximum number of buttons is 3 buttons.
- Header type video only allows .mp4 extension, and we recommend the size is < 5 MB because end-users may experience slow connection when loading the video.
- Header types image, video, and document must use HTTP/HTTPS link.
- Click Create Action to finalize your action.
After end-users click any button, the bot must execute a response based on the clicked button. You can map the selected button by end-users using button title
or button id
.
-
Using button
title
. For example:context.chosen == payload.postback.title
-
Using button
id
. For example:context.chosen == payload.postback.id
How to deploy
You can create a simple bot using text by following this bot tutorial: Start your first chatbot.
You can deploy your bot by following these steps.
Create a deployment
- Click the Deploy menu in the left sidebar.
- On the Deploy page, click on the New Deployment button in the top right corner. It will open up the Create Deployment menu.
- Choose any deployment version you want to deploy and fill in the changelog.
- Click Submit to finish the deployment.
Create a new environment
If you already have an environment created, skip these steps.
- Go to the Deployments > Environment menu.
- Click the Create Environment button in any environment. You will see a drawer to create a new environment.
- Choose the development version you want (in this tutorial, we use the 1.0.0 version)
- Fill in the environment URL. This environment URL is used for CMS.Learn more about CMS.
- Click Create to create the environment.
- Created environment now has a Create Channel button.
Create WhatsApp business account
You can only deploy bots to a verified WhatsApp Business number. To get the number, you have to:
- Go to https://business.kata.ai
- Create a business dashboard account
- Register your new WhatsApp number
Then, you’re ready to get the access token from your WhatsApp business account.
- In Business Dashboard, go to the Whatsapp Numbers menu.
- Then, click the WhatsApp number you want to deploy. You will redirect to the Manage WhatsApp Number page.
- In the Manage WhatsApp Number page, scroll down to API Credential.
-
Next, you will need to downloadPostman to hit the WhatsApp API.
-
Copy the username and password from the API Credential section in the Business Dashboard into Postman.
-
Open Postman and fill in the URL as follows::
URL: POST [https://api-whatsapp.kata.ai/v1/users/login](https://api-whatsapp.kata.ai/v1/users/login)
-
Enter the username and password from Business Dashboard to the Body. Examples:
Body:: { “username”: “amanda123” “password”: “Q1w2e3r4#kata” }
-
Click Send in Postman. You will get the access token as shown.
- Copy the access token in the API result and save it next.
Finalize deployment WhatsApp channel
- Log in to Kata Platform (https://platform.kata.ai)
- Click your project that already had a chatbot and deployed
- Then, go to the menu: Deploy > Environment.
- Click the Create Channel button to start adding channels to the environment. It will open up the Channel menu within the environment.
- Click the ”+ Create Channel” button in the channel table list. It will show a menu to set up the channel.
- Choose WhatsApp in Channel Type
- Paste the access token into the field, and enterhttps://api-whatsapp.kata.ai in the URL field.
- Click Save to deploy your bot.
You’re all set! Now you can start chatting with your WhatsApp bot.
It is the end of the guidance. You can contact support@kata.ai if you have any difficulties when implementing this.