Skip to main content

Webhooks

What it is

Webhooks are BotBat's event-driven notification system that pushes real-time updates to your server whenever something significant happens on the platform. Instead of polling the API repeatedly to check for changes, you register an HTTPS endpoint, select the event types you care about, and BotBat sends structured JSON payloads to your server the moment an event occurs. Every payload is signed with an HMAC-SHA256 signature so your server can verify that the request genuinely originated from BotBat.

The webhook system includes a robust retry policy with exponential backoff. If your endpoint is temporarily unavailable or returns a non-2xx status code, BotBat automatically retries delivery up to five times over a 12-hour window. Each delivery attempt is logged in the BotBat console with the event type, HTTP status code from your server, response time, and retry count, giving you full visibility into delivery health.

Webhooks are the foundation of event-driven integrations with BotBat. They power use cases ranging from real-time CRM synchronization and delivery status dashboards to compliance audit trails and automated follow-up workflows. By subscribing only to the events your integration needs, you keep your server's processing load minimal while still reacting instantly to the events that matter most.

When to use

ScenarioDescription
Syncing data with external systemsAutomatically push contact changes to your CRM, data warehouse, or marketing automation tool when contacts are created or updated in BotBat.
Triggering downstream workflowsKick off follow-up actions in your backend when a campaign completes or a conversation is resolved. For example, update an order status or send a satisfaction survey.
Monitoring message delivery in real timeSubscribe to message.delivered and message.read events to update delivery dashboards or trigger time-sensitive follow-ups.
Auditing events externallyForward events to a logging or SIEM system for compliance, security monitoring, or custom analytics beyond BotBat's built-in reporting.
Debugging integration issuesUse webhook logs and the testing tools to verify that events are being sent, received, and processed correctly during development.

Steps

1. Navigate to Webhooks

Go to Developer > Webhooks in the sidebar. The main view shows a table of all configured webhook endpoints, including each endpoint's name, URL, active event count, and current status (active or disabled).

Webhook endpoints list table showing endpoint name, URL, event count, and status

2. Create a webhook endpoint

Click Add Endpoint to open the creation form. Enter your server's HTTPS URL (plain HTTP is not supported for security reasons), give the endpoint a descriptive name such as "CRM Contact Sync" or "Delivery Status Tracker," and select the event types that should trigger notifications to this endpoint. You can select individual events or use Select All for a catch-all endpoint that receives every event type.

Create endpoint form with URL input, name field, and event type checkboxes

Only HTTPS endpoints with valid SSL certificates from trusted Certificate Authorities are accepted. Self-signed certificates will be rejected. If you are developing locally, use a tunneling tool such as ngrok to expose your local server with a valid HTTPS URL.

3. Copy the signing secret

After saving the endpoint, BotBat generates a unique signing secret. This secret is displayed once. Copy it immediately and store it in a secure location such as an environment variable or secrets manager. You will use this secret on your server to verify that incoming webhook payloads are authentic.

Signing secret value shown with copy button after endpoint creation

4. Implement signature verification

On your server, compute an HMAC-SHA256 hash of the raw request body using the signing secret as the key. Compare the resulting hex digest to the value in the X-BotBat-Signature header of the incoming request. If they match, the payload is authentic. If they do not match, reject the request with an HTTP 401 response. The following table summarizes the signature verification steps.

StepAction
1Read the raw request body as a byte string (do not parse JSON first).
2Retrieve the X-BotBat-Signature header value from the request.
3Compute HMAC-SHA256 of the raw body using your signing secret as the key.
4Compare your computed hex digest with the header value using a constant-time comparison function.
5If the values match, process the payload. If they do not match, return HTTP 401 and discard the request.

5. Process the payload

Parse the JSON body. Every webhook payload follows a consistent structure with four top-level fields.

FieldTypeDescription
eventstringThe event type identifier, e.g., message.delivered or contact.created.
timestampstring (ISO 8601)The UTC timestamp when the event occurred.
webhook_idstringA unique identifier for this specific delivery. Use this for idempotency checks.
dataobjectThe event-specific payload containing the relevant resource data.

Example payload:

{
"event": "message.delivered",
"timestamp": "2026-02-11T14:30:00.000Z",
"webhook_id": "wh_evt_abc123def456",
"data": {
"message_id": "msg_789xyz",
"contact_id": "ct_456abc",
"channel": "whatsapp",
"delivered_at": "2026-02-11T14:29:58.000Z"
}
}

6. Return a 2xx response

Your endpoint must return an HTTP 2xx status code within 30 seconds to acknowledge receipt. Any non-2xx status code, or a timeout exceeding 30 seconds, triggers the retry policy. Best practice is to accept the webhook immediately (return 200 with an empty body or {"ok": true}), then process the event asynchronously using a job queue or background worker.

7. Monitor webhook logs

In the BotBat console, open the Logs tab for any webhook endpoint. Each delivery attempt is logged with the event type, the HTTP status code your server returned, the response time in milliseconds, and the retry count. You can filter logs by event type, status (success, failed, retrying), and date range.

Webhook delivery logs table showing event type, HTTP status, response time, and retry count

Click on any log entry to expand it and view the full request payload that was sent, the response body your server returned, and any error details. This is invaluable for debugging failed deliveries.

Failed delivery detail showing request payload, response body, and error details

8. Test locally

Use the Send Test Event button to send a sample payload for any event type to your endpoint. This generates a realistic test payload and delivers it immediately, regardless of whether any real events have occurred. Combined with a tunneling tool like ngrok, this lets you iterate rapidly on your webhook handler without deploying to a remote server.

Send Test Event modal with event type dropdown and Send button

Event types

The following table lists all available webhook event types. Subscribe only to the events your integration needs to minimize unnecessary processing on your server.

EventTriggerTypical use case
message.receivedA new inbound message arrives from a contact.Route incoming messages to your support system or chatbot.
message.sentAn outbound message is sent to a contact.Log outbound activity in your CRM.
message.deliveredAn outbound message is confirmed delivered to the contact's device.Update delivery dashboards in real time.
message.readAn outbound message is read by the contact.Trigger time-sensitive follow-ups or measure engagement.
campaign.completedA campaign finishes sending to all recipients.Generate post-campaign analytics or notify stakeholders.
contact.createdA new contact is created in BotBat.Sync the contact to your CRM or data warehouse.
contact.updatedAn existing contact's fields are updated.Keep external systems in sync with the latest contact data.
conversation.assignedA conversation is assigned to an agent.Notify the agent via Slack, email, or your internal tools.
conversation.resolvedA conversation is marked as resolved.Trigger a satisfaction survey or close a support ticket.

Retry policy

When your endpoint fails to return a 2xx response, BotBat retries with exponential backoff according to the following schedule.

AttemptDelay after previous failure
1st retry1 minute
2nd retry5 minutes
3rd retry30 minutes
4th retry2 hours
5th retry12 hours

After 5 consecutive failed retries, the event is permanently marked as "failed" in the webhook logs. If an endpoint fails consistently for 72 hours across multiple events, BotBat automatically disables the endpoint and sends an email notification to all workspace administrators. You can re-enable a disabled endpoint from the Webhooks settings page after resolving the underlying issue.

Common pitfalls

PitfallImpactRecommendation
Not verifying webhook signaturesAny party who discovers your endpoint URL can send fake events, potentially corrupting your data.Always validate the X-BotBat-Signature header using HMAC-SHA256 with your signing secret.
Processing webhooks synchronouslySlow operations (database writes, external API calls) before returning a response may cause timeouts and trigger unnecessary retries.Return a 2xx response immediately, then process the event asynchronously via a job queue.
Not handling duplicate deliveriesNetwork issues can cause the same event to be delivered more than once, leading to duplicate records or double-processed actions.Use the webhook_id field for idempotency. Check whether you have already processed a given ID before acting on it.
Using HTTP instead of HTTPSBotBat rejects non-HTTPS endpoints. Self-signed certificates are also rejected.Use a valid SSL certificate from a trusted Certificate Authority. For local development, use a tunneling tool.
Subscribing to all events unnecessarilyReceiving events your integration does not use wastes bandwidth and processing resources on your server.Subscribe only to the specific event types your integration requires.
tip

During development, use the "Send Test Event" button combined with a tunneling tool like ngrok to test your webhook handler locally. This lets you iterate quickly without deploying to a server after every change.

  • Webhook Endpoints
  • Create Endpoint
  • Signing Secret
  • Event Types
  • Delivery Logs
  • Test Event
  • Retry Policy
  • Signature Verification