Creating a Token for WhatsApp Business

to get the WhatsApp account ID, and how to configure webhooks to be alerted about WhatsApp-related actions.

As one of the steps of creating a WhatsApp API stream, you need to enter a WhatsApp Business token and your WhatsApp Business ID.

This article will describe how to generate this token and where to get the WhatsApp account ID.

You will also learn how to configure Webhooks in your app to be alerted at WhatsApp-related actions.

Generating a WhatsApp Business Token

To create a token:

  1. In your Meta Business Suite account, navigate to the settings menu (the gear icon), expand Users, and select System Users. You can also use the following link: https://business.facebook.com/settings/system-users.

  2. Click Add.

    Screenshot of the Meta **System Users** section

    Meta System Users section

  3. In the window that pops up, enter the name for the user and select the Admin role.

  4. Click Create System User.​

    Screenshot of the **Create system user** dialog

    Create system user dialog

  5. On the system user page, click Generate token. ​​

    Screenshot of the **Generate token** button

    Generate token button

  6. A new window will pop up where you should specify token attributes:

    1. Select the app for which you are creating the token.

      Screenshot of the **Select app** step

      Select app step

    2. Select the token expiration option.

    📘

    NOTE

    Please make sure you select Never as you are creating a permanent token.

    Screenshot of the **Set expiration** step

    Set expiration step

    1. Assign permissions to the app: whatsapp_business_management and whatsapp_business_messaging.​​

      Screenshot of the **Assign permissions** step

      Assign permissions step

    2. Click the Generate token button.​

      Screenshot of the **Generate token** button

      Generate token button

  7. You will see your token on the screen. Copy it and click Done.​

    Screenshot of the **Done** step

    Done step

  8. You can now insert the token in the Auth token field when you create a WhatsApp stream.

Getting the WhatsApp Business ID

  1. Expand the Accounts section in the settings menu and select WhatsApp accounts. Alternatively, use the link: https://business.facebook.com/settings/whatsapp_account

  2. Copy the ID under the needed WhatsApp account.​

    Screenshot of the Meta **WhatsApp accounts** section

    Meta WhatsApp accounts section

Use this ID for the Business ID field.

Configuring Webhooks

Set up webhooks for your app to be alerted when you receive a message or when its status changes.

To set up webhooks:

  1. Go to your account at Meta for Developers, navigate to Apps (https://developers.facebook.com/apps/), and select the needed app.

  2. In the main menu on the left, expand the WhatsApp section and select Configuration.​

    Screenshot of the Meta **Configuration** section

    Meta Configuration section

  3. In the Webhook section, specify the webhook callback URL:

    1. Click Edit.

      Screenshot of editing configuration window

      Editing configuration

    2. In the pop-up window that appears, enter the needed details.​
      Callback URL: _https://textpeak-streams.commpeak.com/webhooks/whatsapp​_
      Verify token: SismaKala

    3. Click Verify and save.

  4. Select the webhook fields:

    1. Click Manage.

    2. In the window that pops up, select the following webhook fields:
      messages
      phone_number_name_update
      template_category_update

      Screenshot of the **Webhook fields** window

      Webhook fields window

    3. Click Done.

❗️

IMPORTANT

We recommend selecting v18.0 in the Subscription version column.

Screenshot of the **Webhook** section

Webhook section