Skip to main content

WhatsApp Business

WhatsApp Business event integrations receive webhook notifications from the WhatsApp Business Cloud API and trigger handler functions as messages arrive and account, template, or phone number state changes occur. Use them to build chatbots, automate customer replies, and track message delivery and template quality in real time.

note

The WhatsApp Business webhook listener must be reachable from the internet. For local development, use a tunneling tool such as ngrok to create a public URL for your local port. In production, deploy the integration to a publicly accessible host.

After starting the integration, configure the webhook in the Meta App Dashboard under WhatsApp → Configuration → Webhooks: set the Callback URL to your listener's public URL, set a Verify token matching verifyToken, and subscribe to the fields you want to receive.

Creating a WhatsApp Business listener​

  1. Click + Add Artifact in the canvas or click + next to Entry Points in the sidebar.

  2. In the Artifacts panel, select WhatsApp Business under Event Integration.

  3. In the creation form, fill in the following fields:

    Create WhatsApp Business form showing the Listener Name, Port, Verify Token, and App Secret fieldsCreate WhatsApp Business form showing the Listener Name, Port, Verify Token, and App Secret fields
    FieldDescriptionDefault
    Listener NameIdentifier for the listener created with this service.businessListener
    PortThe port on which the webhook listener accepts incoming HTTP requests.8090
    Verify TokenThe verification token configured in the Meta App dashboard.Required
    App SecretThe Meta app secret, used to verify inbound webhook notifications via X-Hub-Signature-256.Required
  4. Click Create.

  5. WSO2 Integrator opens the service in the Service Designer. The canvas shows the attached listener pill and an empty Event Handlers section.

  6. Click + Add Handler to define how incoming events are processed.

Service configuration​

Service configuration controls the service name and the WhatsApp Business listener it is attached to.

In the Service Designer, click Configure to open the WhatsApp Business Configuration panel.

The panel shows a Service Configuration field for the service's acknowledgement behavior, and an Attached Listeners list. Pick a listener under Attached Listeners to configure its connection settings.

WhatsApp Business Configuration panel showing the empty Service Configuration record editor, and the Attached Listeners list with the Name, Listen To, Verify Token, and App Secret fieldsWhatsApp Business Configuration panel showing the empty Service Configuration record editor, and the Attached Listeners list with the Name, Listen To, Verify Token, and App Secret fields

Service configuration​

FieldDescription
Service ConfigurationAdvanced acknowledgement settings as a @business:ServiceConfig record expression (e.g., { autoAck: false }). Defaults to autoAck: true, acknowledging automatically. See Manual acknowledgement.

Main configurations​

FieldDescription
NameThe name of the listener. Required.
Listen ToA port number to bind a new http:Listener to, or an existing http:Listener. Required.
Verify TokenThe verification token configured in the Meta App dashboard. Required.
App SecretThe Meta app secret, used to verify inbound webhook notifications. Required.

Click Attach Listener to attach an additional listener to the same service.

Click Save Changes to apply updates.

Event handlers​

An event handler is a remote function that WSO2 Integrator calls for each WhatsApp Business Cloud webhook event received.

Adding an event handler​

In the Service Designer, click + Add Handler. A Select Handler to Add panel opens on the right listing the available event types.

Select Handler to Add drawer listing the WhatsApp Business event handlersSelect Handler to Add drawer listing the WhatsApp Business event handlers

Pick On Messages, then click Save. This opens the Flow Designer for onMessages.

Flow canvas for the WhatsApp Business onMessages handlerFlow canvas for the WhatsApp Business onMessages handler

Use the flow canvas to add integration steps such as database writes, HTTP calls, and transformations. Repeat these steps to add the other handlers you need.

Manual acknowledgement​

By default, the listener acknowledges (200 OK) each notification automatically, before any handler runs. Meta requires a fast 2xx and retries otherwise, so this is the safe default for slow handlers. Annotate the service @business:ServiceConfig {autoAck: false} to decide exactly when a notification is acknowledged instead, and declare a handler's optional second parameter as a business:Caller:

@business:ServiceConfig {
autoAck: false
}
service business:WhatsAppService on businessListener {

remote function onMessages(business:MessagesNotification notification, business:Caller caller) returns error? {
check persistNotification(notification);
check caller->complete();
}
}

With autoAck: false, if a handler never calls caller->complete(), the listener responds 500 Internal Server Error for that request, and Meta treats it like any other failed delivery and may retry it. With the default autoAck: true, the notification is already acknowledged before the handler runs, so calling caller->complete() is a no-op. Meta may redeliver a notification if the acknowledgement is slow, dropped, or never sent, under either autoAck setting, not just false, so make handler processing idempotent, or deduplicate using InboundMessage.messageId (wamid) for messages, or MessageStatusUpdate.messageId plus status for status updates.

Handler types​

The listener supports ten WhatsApp Business Cloud webhook fields, one per WhatsAppService handler, plus an eleventh onError handler that fires whenever one of the ten returns an error while being dispatched. Declare only the handlers you need. Notifications for any other webhook field, or for a field whose handler you didn't declare, are logged and dropped.

HandlerWebhook fieldTriggered when
onMessagesmessagesAn inbound message or an outbound message status update arrives. Narrow the MessagesNotification parameter with notification is Messages to tell the two apart.
onAccountReviewUpdateaccount_review_updateA WhatsApp Business Account (WABA) review decision changes.
onAccountUpdateaccount_updateAn account-lifecycle or compliance change occurs.
onBusinessCapabilityUpdatebusiness_capability_updateA WABA's messaging or phone-number capability limits change.
onMessageTemplateQualityUpdatemessage_template_quality_updateA message template's quality score changes.
onMessageTemplateStatusUpdatemessage_template_status_updateA message template's status changes (approved, rejected, disabled, and so on).
onPhoneNumberNameUpdatephone_number_name_updateA phone number's display-name review outcome is available.
onPhoneNumberQualityUpdatephone_number_quality_updateA phone number's messaging throughput or quality tier changes.
onSecuritysecurityA two-step-verification PIN change or reset request occurs for a phone number.
onTemplateCategoryUpdatetemplate_category_updateA message template's category changes, or is about to change.
onErrorN/AAny of the handlers above returned an error while being dispatched.

What's next​