Setting up WhatsApp webhooks for responses

This guide walks you through setting up WhatsApp webhooks to gather responses.

Note: For general set up and configuration documentation for WhatsApp, see WhatsApp with Apteco.

This is how the webhook process works:

  • Meta sends the WhatsApp events as JSON to the webhook.

  • The responses stream to your Webhooks table in the social database.

  • You can then run the social response gatherer to pull the data from the Webhooks table and place in the SO_ response tables.

Creating an Orbit webhook connector

To create an Orbit Webhook Connector:

  1. Go to developers.facebook.com and sign in.

  2. Click My Apps, then click Create App.

  3. Select Other, then click Next.

  4. Select Business.

  5. Name your app Orbit Webhook Connector.

    You are asked to verify by logging in again.

You should now have your Orbit Webhook Connector shell.

Getting your app secret and setting your privacy policy

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

  1. Under App settings, select the Basic option, and reveal the App secret.

    Later in the process, you should use this as your AptecoOrbitSecret to ensure that we only receive events from this app.

  2. While you are in the basic settings, you need to set your Privacy Policy URL.

Setting up your Orbit Responses API

Note: Make sure that you have access to the OrbitResponses API. You can check this with swagger.

To set up your Orbit Responses API:

  1. Go to cloudtest.faststats.co.uk/Develop/OrbitResponsesAPI/swagger/ui/index.

  2. Update your appsettings.json to configure the WhatsAppWebhook: C:\inetpub\wwwroot\Develop\OrbitResponsesAPI\appsettings.json

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

    The connection string should point at your response database.

    Note: The ConfiguredToken is the token you wish to use when you validate your webhook in Meta (in our example we will use 5ebfd954-6cba-4a36-aae7-385dd83fbeec)

    Note: The AptecoOrbitSecret is your WhatsApp secret (remember that we found this when we created our connector) and is used to validate any messages are coming from your account.

Getting your webhook endpoint

Go to the Orbit Responses API to see your endpoint.

Setting up the webhook within your meta environment

You now need to apply the webhook within Meta to gather responses to your messages.

To set up the webhook in Meta:

  1. Choose to add your Webhooks.

  2. Choose a WhatsApp Business Account.

  3. Subscribe to get your verification page.

  4. You now need to enter the callback URL that we found earlier.

    Note: 5ebfd954-6cba-4a36-aae7-385dd83fbeec is what we choose as our ConfiguredToken.

  5. Choose to subscribe to the messages events.

  6. Make sure your Connector is now live.

You can now send WhatsApp messages, and Apteco stores the messages (and replies) in your response database.