# WhatsApp

Here's a step-by-step guide on how to integrate Yada with WhatsApp in five simple steps. We've tied as much as possible to take this otherwise confusing process and create a sequence of steps which can be easily followed to integrate Yada with WhatsApp

{% hint style="info" %}
The Yada <> WhatsApp integration only works with WhatsApp for Business
{% endhint %}

This guide assumes you haven't done anything yet to set up a whatsapp for business account. If you've already done some of this, please feel free to skip to the most relevant section.

## Step 1 - Verify your Business with Facebook

In order to connect your WhatsApp to yada, your business needs to be verified on Facebook. Detailed instructions on how to do that are available on [Facebook’s Business Help Center page](https://www.facebook.com/business/help/2058515294227817?id=180505742745347). You will be required to provide additional information about your business and wait for the verification to be completed.

## Step 2 - Create a WhatsApp Business App

While your business is being verified you can go ahead and start setting up the rest of the information needed to connect yada with WhatsApp.&#x20;

Head over to [developers.facebook.com/apps](https://developers.facebook.com/apps), click on Create App and follow the steps to create a developer app.

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2FUXHf0XhVZKwKDPQvzxaH%2Fwhatsapp_create_developer_app.png?alt=media&#x26;token=429f9bea-0f07-429a-876a-cd22ede4666d" alt=""><figcaption><p>You can select either "None" or "Business"</p></figcaption></figure>

Once you've created the developer app, you will need to add some details.

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2Fs840rTXAc7feYKgcpq6y%2Fwhatsapp_create_app_detail.png?alt=media&#x26;token=881c7514-2604-48e0-b087-10604a74dff0" alt=""><figcaption><p>Provide app name, contact email address and select your Business Account</p></figcaption></figure>

## Step 3 - Configure the Developer App

You will need to add the *WhatsApp* and *Webhooks* products

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2FZWe3Zu8bIamrL6NLmtyz%2Fwhatsapp01.png?alt=media&#x26;token=b9b7eb05-c2d4-480f-a934-633e6a57871f" alt=""><figcaption><p>Make sure to add WhatsApp and Webhooks</p></figcaption></figure>

Once these two products have beed added, they'll show up in the left bar

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2Fg8K5jLF250LLsZdq140j%2Fwhatsapp02.png?alt=media&#x26;token=ac6711ed-0c6a-4699-86cf-f35d8efddfae" alt=""><figcaption><p>Notice that Webhooks and Whatsapp have now been made available</p></figcaption></figure>

Select your **business phone number** in *WhatsApp Quickstart* settings. That’s the number through which your guests will be contacting your busienss on WhatsApp. If you don’t know how to add a phone number to WhatsApp, you can follow this [official tutorial](https://www.facebook.com/business/help/456220311516626?id=2129163877102343).

{% hint style="info" %}
Make sure to copy the AccountID somewhere - you will need it to integrate with yada
{% endhint %}

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2FgRBRXx2c2t9Za6bwvkaj%2Fwhatsapp03.png?alt=media&#x26;token=db524a8a-8bf8-411d-b4c5-a8dd058dc001" alt=""><figcaption><p>Copy and store the WhatsApp Accunt ID somewhere</p></figcaption></figure>

As a next step, go to your app’s basic settings and set your *Privacy policy URL*, *Contact email* and *Category*. Once you’ve done that, set your app to *live* at the top.

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2Fy8oKGyY33wuMmC7WHlHn%2Fwhatsapp04.png?alt=media&#x26;token=3b7a7cd8-9344-466e-8361-f0a1436017e5" alt=""><figcaption><p>You're ready to go live now!!</p></figcaption></figure>

While on this page, also take note of your **App secret and App ID** which you will also need to paste into the [Yada Dashboard](https://app.yada.ai)

{% hint style="info" %}
This App Secret is really important and you'll need it to connect WhatsApp to the Yada API
{% endhint %}

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2FkO0bufNWDEMhtGghVUut%2Fwhatsapp05.png?alt=media&#x26;token=d83816c4-2e5c-421f-9adc-1030756a64a9" alt=""><figcaption><p>Copying the App Secret</p></figcaption></figure>

## Step 4 - Generating WhatsApp Access Token

To generate an *access token* required to integrate with WhatsApp you will need to go to [business.facebook.com/settings/system-users](https://business.facebook.com/settings/system-users). Make sure you are looking at the correct business account.

First, you need to create a user with admin permissions. Keep in mind that there can be only *one* admin account.

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2Ff6lEC7d9HEWiJthNuUVU%2Fwhatsapp06.png?alt=media&#x26;token=40db00aa-23a8-4534-9203-3c8d458db44c" alt=""><figcaption><p>Crating a facebook system user</p></figcaption></figure>

Once the admin user is created, select **Add assets** under the **Assigned Assets** section.

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2F2BwGslFErgBBeRDQNIFz%2Fwhatsapp07.png?alt=media&#x26;token=a018a6a6-2dce-4281-bd4f-a6508d469241" alt=""><figcaption><p>You will need to add WhatsApp ass an asset to this system user</p></figcaption></figure>

Select **Apps**, choose your app with WhatsApp integration and give it full control to **Manage App**.

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2F96y6ZYtI30cApYIqrhy5%2Fwhatsapp09%20(1).png?alt=media&#x26;token=b880b1a3-c755-431a-810e-790e112dec8b" alt=""><figcaption><p>Select the app and make sure "Manage App" is active</p></figcaption></figure>

Next, you will need to generate a new token. Press the **Generate new token** button and select your app. In the **Available Permissions** section select two permissions: `whatsapp_business_messaging` and `whatsapp_business_management`.

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2Feg1fYIU4AyYWymhu6GGO%2Fwhatsapp10.png?alt=media&#x26;token=582820f0-c7bb-4fb4-8f27-0a4ada958a55" alt=""><figcaption><p>Make sure all the whatspp fields are clicked</p></figcaption></figure>

Finally, copy the generated access token.

{% hint style="info" %}
MAKE SURE TO COPY THE TOKEN. It is not stored by facebook so if you don't copy it you'll have to generate the token again.
{% endhint %}

### Video Tutorial

{% embed url="<https://www.youtube.com/watch?v=gqiBzFlF44c>" %}

## Step 5 - Connect WhatsApp to Yada

In the previous steps you've gotten these three fields

* Account ID
* App Secret
* Permanent Access Token

Once you've gotten these three fields, you are ready to connect WhatsApp to Yada

{% hint style="info" %}
You need to have a paid Yada account to connect to WhatsApp
{% endhint %}

First, Head to the Powerups page and click on the WhatsApp card. Once you're in here you'll need to copy the above fields into their corresponding inputs

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2FHFZ5tXEoWJ2YhIrECHzb%2FScreenshot%202023-03-30%20at%209.56.23%20PM.png?alt=media&#x26;token=efb23148-9026-46fa-b3a9-17ed88ae33a4" alt=""><figcaption></figcaption></figure>

Once yada has been integrated with WhatsApp, you'll get the Webhook Callback URL and the verification secret. Copy these as you'll need them to connect the WhatsApp webhook to Yada and start receiving messages

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2F06pd8OCayC1Frxp67ZLh%2FScreenshot%202023-03-30%20at%209.59.24%20PM.png?alt=media&#x26;token=d425c4ad-3f93-4980-8f79-b573743509d0" alt=""><figcaption></figcaption></figure>

##

## Step 6 - Connect the WhatsApp Webhook to Yada

The final step will be to integrate and verify the Quickchat webhook endpoint which will receive your message events. Go back to [developers.facebook.com/apps](https://blog.quickchat.ai/post/how-to-build-a-gpt3-ai-whatsapp-chat-bot/developers.facebook.com/apps), select your app and open your app’s WhatsApp Quickstart settings. Click on the **Edit** button for webhooks.

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2FGY2PLKnj153IrYs3li0A%2Fwhatsapp11.png?alt=media&#x26;token=80e7622d-b0bb-4537-ac6c-fb35f55102c3" alt=""><figcaption><p>Edit the callback URL</p></figcaption></figure>

Paste in the **callback URL** and **verify token** into the following fields

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2FxT1dTX9fXcmLuRW3lAdb%2Fwhatsapp12%20(1).png?alt=media&#x26;token=dc07536b-21d0-4cf7-8977-626ec99f73e8" alt=""><figcaption></figcaption></figure>

Once the Callback URL has been correctly added, click on the Manage webhook fields button.

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2Fg8nbJmVoJY9Q2oiTf9vt%2Fwhatsapp13%20(1).png?alt=media&#x26;token=e6fb8e0a-194c-42cb-8261-68cf99253350" alt=""><figcaption></figcaption></figure>

Subscribe to the **messages** fields and select Done to continue.

{% hint style="info" %}
Make sure to select version **v15.0 or v16.0** --- *NOT v9.0*
{% endhint %}

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2FnexP9apa8e0VElZbO9Yl%2Fwhatsapp14.png?alt=media&#x26;token=9798eec8-5099-4128-9234-1d672ddae0eb" alt=""><figcaption><p>Select v14, v15, or v16</p></figcaption></figure>

Once correctly configured and saved, your Webhooks sections is going to look something like this:

<figure><img src="https://112898604-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FAtZGXRaOVDks4wm8zpn3%2Fuploads%2FJMRVK7h5ljmrXQVFcxtR%2Fwhatsapp15.png?alt=media&#x26;token=e2db4f09-455b-4f9a-aa0d-8f0f93e41745" alt=""><figcaption></figcaption></figure>
