Skip to main content

Connect WhatsApp Business directly

To connect a bot to your WhatsApp Business account:

  1. Create an application in your developer account.
  2. Set up the application.
  3. Create a script in Aimylogic.
  4. Connect an inbound channel.
  5. Set up a webhook in the application.
  6. Test the bot.

Create an application

caution
To set up the integration, you need a developer account.
  1. Sign in to your developer account.
  2. Select My Apps from the tab bar.
  3. Click Create App.
  4. On the Type tab, select Business and click Next.
  5. On the Details tab, add information about the application:
    • an app name
    • your contact email
    • your business account
  6. Click Create App to save the information.

Set up the application

First, you need to generate a permanent token to continue the application setup.

caution
A permanent token is only available for applications in a live mode.

Generate a permanent token

To generate a permanent token:

  1. Go to the Business Settings page.
  2. In the Users section, select System Users and click Add.
  3. Enter System Username, System User Role and click Create System User.
  4. On the System Users page, click Add Assets.
  5. Go to Select Asset type → Apps → Select assets and select your app name.
  6. Enable the Manage App option in the Full Control section and click Save Changes.
  7. On the System Users page, click Generate New Token.
  8. Select your app from the dropdown list.
  9. Enable the whatsapp_business_management and whatsapp_business_messaging permissions from the list and click Generate Token.

Complete the application setup

To complete the application setup:

  1. Go back to the My apps page and select your app.
  2. On the Dashboard page, go to the Add products to your app section, select WhatsApp, and click Set up.
  3. 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.
  4. On the Configuration tab, copy Permanent token.
caution
You will need a Phone number ID and a Permanent token for an inbound channel connection in Aimylogic.

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:

  1. On the My chatbots tab, choose the bot you will connect to the messenger.
  2. Click Add screen → Create your own intent.
  3. Create a $TEXT intent.
  4. Click    to turn the sample phrase into a template.
  5. Activate the Make the block available from any script point option.
  6. Click Save.
  7. Connect a $TEXT intent to the welcome screen in your script.
caution
Do not connect the Other intents option to any other blocks.

To handle unpredictable messages from a user:

  1. Add another screen with a $TEXT intent. Do not activate the Make the block available from any script point option.
  2. 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:

  1. On the Channels tab, in the Connections → Messengers, social media and API section select the WhatsApp Business channel.
  2. Select the direct connection method.
  3. 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.
  4. 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:

  1. Select your app in the developer account.
  2. On the Products section in the sidebar, select WhatsApp → Configuration.
  3. On the Configuration tab, go to the Webhook section and click Edit.
  4. 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.
  5. Click Verify and save.
  6. In the Webhook fields section, select messages and click Subscribe for Webhooks messages.
  7. 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.