Configure Chatbot using WhatsApp
To configure WhatsApp integration for production scenarios, you must have a verified WhatsApp business portfolio. The process of creating and verifying your business is beyond the scope of this guide. Please refer to Meta's documentation: Create a business portfolio in Meta Business Suite and Business Manager
Cubu/WhatsApp integration contains two parts:
Configuring Cubu to send WhatsApp messages using the WhatsApp API.
Configuring WhatsApp to send messages received from customers using callbacks.
Configuring WhatsApp integration involves several steps:
Verify Business: You need to complete Facebook Business Verification through Business Manager.
Phone Number Approval
Build and Authenticate Your Application and get an API token
Setup Webhooks
This guide refers to 2 Meta portals:
Create a Facebook App
To create an app, go to Meta for developers / Apps (https://developers.facebook.com/apps) and click Create App.
Follow the instructions to create your app. Choose "Other" as the use case and "Business" as the app type.
Add the WhatsApp product to your application.
Set Phone Number ID
Go to the App Dashboard / WhatsApp / API Setup
Select a phone number from the dropdown menu (you will need a verified or test number generated by Meta).
Copy the Phone Number ID back to Cubu's Chatbot settings page:
Set the App Secret
Go to App Settings / Basic.
Copy the App secret from Facebook app settings into Cubu's "App secret" textbox:
Callbacks
In this step, you will configure WhatsApp callbacks. The callbacks are calls made by WhatsApp to notify Cubu when a customer sends a message to a chatbot.
In Meta for developers / App Dashboard, go to Webhooks.
Choose Whatsapp Business Account from the dropdown and click Edit Subscription.
Copy the callback URL provided by Cubu into the Callback URL textbox. Copy the Callback Verify Token you entered in Cubu, and click Verify and save.
In the table below, locate "messages," make sure v21.0 is selected, and click Subscribe.
Get an API Token
Please see Facebook documentation regarding access tokens.
When you create your App in meta, you can generate an access token by clicking Generate Access token in the App Dashboard / API Setup.
However, this token is short-lived and expires after a couple of hours.
To get a permanent token, follow the instructions in the next section.
Get a Permanennt API Token
You need to set up a system user as the admin of your app. Then, you can generate never-expiring access tokens for this system user.
Add a system user to your Facebook app
Go to Meta Business Suite, choose your business portfolio, and click Settings.
Go to Users / System users. Click Add to create a new user. Make sure ut has the Admin role.
On the same page, in the "Assigned Assets" section, check whether your app is listed here. If not, add your app via the "Add asset" button, granting "Full control" over your app.
Goto to Accounts / WhatsApp accounts. Choose your WhatsApp account, and click Assign people.
Add the system user to your Whatsapp account in the "People" section, granting "Full control" over your Whatsapp account
Go back to Users > System Users and select the user you've created in the previous step.
Click "Generate new token" which reveals a "Generate token" dialog. Follow the instructions, and select the 2 permissions:
whatsapp_business_management
andwhatsapp_business_messaging
and confirm.
A new access token will be presented as a link. Click it and store the generated token safely; Facebook will not store it for you. This token will not expire.
Copy the token into Cubu's Access Token textbox.
Last updated