Connect WhatsApp Business directly
To connect a bot to your WhatsApp Business account:
- Create an application in your developer account.
- Set up the application.
- Create a script in Aimylogic.
- Connect an inbound channel.
- Set up a webhook in the application.
- Test the bot.
Create an application
- Sign in to your developer account.
- Select My Apps from the tab bar.
- Click Create App.
- On the Type tab, select Business and click Next.
- On the Details tab, add information about the application:
- an app name
- your contact email
- your business account
- Click Create App to save the information.
Set up the application
First, you need to generate a permanent token to continue the application setup.
Generate a permanent token
To generate a permanent token:
- Go to the Business Settings page.
- In the Users section, select System Users and click Add.
- Enter System Username, System User Role and click Create System User.
- On the System Users page, click Add Assets.
- Go to Select Asset type → Apps → Select assets and select your app name.
- Enable the Manage App option in the Full Control section and click Save Changes.
- On the System Users page, click Generate New Token.
- Select your app from the dropdown list.
- Enable the
whatsapp_business_management
andwhatsapp_business_messaging
permissions from the list and click Generate Token.
Complete the application setup
To complete the application setup:
- Go back to the My apps page and select your app.
- On the Dashboard page, go to the Add products to your app section, select WhatsApp, and click Set up.
- On the Getting started tab:
- Go to Step 1: Select phone numbers and choose a phone number connected to your WhatsApp Business account. ! > If you do not have a number yet, go directly to Step 5: Add a phone number, create a profile and verify the number.
Then go back to Step 1: Select phone numbers and choose the number from the dropdown list. - Copy a Phone number ID.
- Go to Step 1: Select phone numbers and choose a phone number connected to your WhatsApp Business account. ! > If you do not have a number yet, go directly to Step 5: Add a phone number, create a profile and verify the number.
- On the Configuration tab, copy Permanent token.
Create a script in Aimylogic
Now you need to create a bot script in your Aimylogic account.
Aimylogic script features
In WhatsApp, users themselves start a dialog with the bot.
Add a global $TEXT
intent to the first screen of your script so that a user can start a dialog:
- On the My chatbots tab, choose the bot you will connect to the messenger.
- Click Add screen → Create your own intent.
- Create a
$TEXT
intent. - Click to turn the sample phrase into a template.
- Activate the Make the block available from any script point option.
- Click Save.
- Connect a
$TEXT
intent to the welcome screen in your script.
To handle unpredictable messages from a user:
- Add another screen with a
$TEXT
intent. Do not activate the Make the block available from any script point option. - Connect the Other intents option to a block that contains an answer to an unpredictable phrase.
Connect an inbound channel
To connect an inbound channel in Aimylogic:
- On the Channels tab, in the Connections → Messengers, social media and API section select the WhatsApp Business channel.
- Select the direct connection method.
- Fill out the fields:
- Channel name — enter a name for the inbound channel. It will be visible only for you in the Channels section.
- Token — insert Permanent token you have saved.
- Phone number ID — insert an ID you have saved. It is a set of numbers which looks like
102678009166123
.
- Click Connect.
In the Connections section, you will see a published WhatsApp Business channel.
Click Get webhook. You will need this webhook to complete the integration setup in your developer account.
Set up a webhook
To finish the integration set up in the application:
- Select your app in the developer account.
- On the Products section in the sidebar, select WhatsApp → Configuration.
- On the Configuration tab, go to the Webhook section and click Edit.
- Fill out the fields in the Edit webhook’s callback URL window:
- Callback URL — insert the webhook from Aimylogic channel settings.
- Verify token — insert
justai_verify_token
.
- Click Verify and save.
- In the Webhook fields section, select
messages
and click Subscribe for Webhooks messages. - Click Verify and save.
Test the bot
The integration setup is now complete. To test the bot, send a message to your WhatsApp Business account.