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:
-
Go to developers.facebook.com and sign in.
-
Click My Apps, then click Create App.
-
Select Other, then click Next.
-
Select Business.
-
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.
-
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.
-
While you are in the basic settings, you need to set your Privacy Policy URL. We have used the Apteco privacy policy as an example.
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:
-
Go to https://<WebServerURL>/OrbitResponsesAPI/swagger/ui/index.html.
-
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 need to apply the webhook within Meta to gather responses to your messages.
To set up the webhook in Meta:
-
Choose to add your Webhooks.
-
Choose a WhatsApp Business Account.
-
Subscribe to get your verification page.
-
You now need to enter the webhook URL that we found earlier.
Note:
5ebfd954-6cba-4a36-aae7-385dd83fbeec
is what we choose as our ConfiguredToken. -
Choose to subscribe to the messages events.
-
Make sure your Connector is now live.
You can now send WhatsApp messages, and Apteco stores the messages (and replies) in your response database.