# Setting up WhatsApp webhooks for responses

> [!NOTE]
>
> For general setup and configuration documentation for WhatsApp, see the WhatsApp with Apteco documentation.

The WhatsApp webhook process works as follows:

- Meta sends WhatsApp events as JSON to the webhook.
- Responses stream to your Webhooks table in the social database.
- You then run the social response gatherer to pull data from the Webhooks table and place it in the `SO_` response tables.

## Create an Orbit Webhook Connector app in Meta

1. Go to [developers.facebook.com](<https://developers.facebook.com/>) and sign in.
2. Select **My Apps**, then select **Create App**.

   [![My Apps page on Facebook Developer portal](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/My_apps.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/My_apps.png>)
3. Select **Other**, then select **Next**.

   [![Other option selected](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Other.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Other.png>)
4. Select **Business**.

   [![Business option selected](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Business.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Business.png>)
5. Name your app **Orbit Webhook Connector** and verify by logging in again.

   [![App details form with Orbit Webhook Connector name](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/App_details.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/App_details.png>)

You should now have the Orbit Webhook Connector shell.

[![Orbit Webhook Connector app shell](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Webhook_connector_shell.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Webhook_connector_shell.png>)

## Get your app secret and privacy policy address

You need an app secret to set up the webhook successfully.

[![App Secret field in app settings](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/App_secret.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/App_secret.png>)

Use this app secret as your `AptecoOrbitSecret` in the configuration below. This ensures you only receive events from this app.

[![Privacy Policy URL field](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Privacy_policy_URL.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Privacy_policy_URL.png>)

## Configure the Orbit Responses API

> [!NOTE]
>
> Make sure you have access to the OrbitResponses API. Verify using Swagger.

Add the following configuration to your `appsettings.json` for the OrbitResponsesAPI:

JSON

```json
"WhatsApp": {
  "ConnectionString": "user id=faststats_service;password=xxx;initial catalog=SO_Develop;data source=192.0.2.1;pooling=true;max pool size=10000;",
  "ConfiguredToken": "some-whatsapp-token",
  "AptecoOrbitSecret": "some-whatsapp-secret",
  "VerifyPayloadAfterRoundtripThroughJsonParser": true
}
```

Where:

- `ConnectionString`: points to your social response database
- `ConfiguredToken`: the token you wish to use when validating your webhook in Meta (e.g. `00000000-0000-0000-0000-000000000000`)
- `AptecoOrbitSecret`: your app secret from Meta

## Get your webhook endpoint

Navigate to the Orbit Responses API Swagger page to find your endpoint.

[![WhatsApp webhook endpoints in Orbit Responses API](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/WhatsApp_webhook_endpoints.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/WhatsApp_webhook_endpoints.png>)

[![Request URL of the WhatsApp webhook](<https://help.apteco.com/assets/images/admin/configuration/webhooks/Request_URL.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/Request_URL.png>)

## Set up the webhook in Meta

1. In your Orbit Webhook Connector app, choose to add **Webhooks**.

   [![Add your Webhook option in Meta Developer portal](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Add_your_webhook.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Add_your_webhook.png>)
2. Select **Subscribe** to get to the verification page.
3. Enter the webhook URL found in the previous step.

   [![Callback URL and verify token fields](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Callback_URL.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Callback_URL.png>)

   > **Note**
   >
   > Enter the `ConfiguredToken` value (e.g. `00000000-0000-0000-0000-000000000000`) as the **Verify Token**.
4. Subscribe to the **messages** events.

   [![Subscription successful confirmation](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Subscription_successful.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Subscription_successful.png>)
5. Make sure your connector is now live.

   [![Live connector status](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Live_connector.png>)](<https://help.apteco.com/assets/images/admin/configuration/webhooks/whatsapp-webhooks/Live_connector.png>)

You can now send WhatsApp messages and Apteco will store the messages and replies in your response database.
