Skip to main content

How to set up and use webhooks in Wati

Updated today

Summary

Webhooks in Wati allow you to receive real-time updates about messages and their statuses by sending event data to your server. This guide explains what events you can track, how to set up a webhook, and how session-based callbacks work so you can reliably process message activity in your system.

Instructions

What events can webhooks capture?

Wati webhooks can notify your system when the following events occur:

  • Messages received

  • Messages sent (template and session messages)

  • Message status updates:

    • Sent

    • Delivered

    • Read

These events are sent to your configured webhook URL as callback payloads.

How to add a webhook in Wati

Follow these steps to set up a webhook:

  • Log in to your Wati dashboard.

  • Go to Connectors and click on Webhooks in the top navigation menu.

  • Click Add Webhook.

  • Enter your full webhook URL.

  • Set the status to Enabled.

  • Select the events you want to capture.

  • Click Save.

How to test your webhook

After adding the webhook, you can test the connection:

  • Use the Trigger sample callback option.

  • Wati will send a sample payload to your webhook URL.

  • Verify that your server receives and processes the payload correctly.

Understanding session-based webhooks

In the WhatsApp Business API, conversations are tracked as 24-hour sessions. A session starts when a business message is delivered.

Types of sessions

  • Active session

    • Both the business and the customer have exchanged at least one message.

    • Example: A business sends a template message and the customer replies.

  • Inactive session

    • Only one party has sent a message, and the other has not responded.

    • Example: A business sends a template message, but the customer does not reply.

Note: Webhook callbacks may vary depending on whether the session is active or inactive.

Webhook response and retry logic

To ensure reliable delivery, your webhook must respond correctly.

  • Your server must return a 200 OK response to confirm that the event was received.

  • If a 200 response is not received:

    • Wati retries sending the event.

    • Retries can happen up to 144 times.

    • Retry attempts run at 10-minute intervals.

  • If there are more than 100 consecutive failures:

    • The webhook is marked as Defective.

    • You will receive an email notification.

If all retry attempts fail, the event will no longer be sent.

Best practices

  • Ensure your webhook endpoint is always available and responsive.

  • Log incoming payloads for easier debugging.

  • Handle duplicate events, as retries may send the same payload more than once.

  • Validate incoming requests to ensure they originate from Wati.

This setup helps you keep your systems in sync with real-time messaging activity in Wati.

Frequently Asked Questions (FAQs)

Webhooks overview

1. What do webhooks in Wati do?

Webhooks in Wati send real-time updates about messages and their statuses to your server by delivering event data to a configured webhook URL.

2. What types of events can Wati webhooks capture?

Wati webhooks can capture the following events:

  • Messages received

  • Messages sent (template and session messages)

  • Message status updates, including Sent, Delivered, and Read

Webhook setup and testing

3. How do you add and test a webhook in Wati?

To add and test a webhook in Wati:

  • Log in to your Wati dashboard.

  • Go to Connectors and click Webhooks.

  • Click Add Webhook.

  • Enter your webhook URL and set the status to Enabled.

  • Select the events you want to capture and click Save.

  • Use the Trigger sample callback option to send a sample payload.

  • Verify that your server receives and processes the payload correctly.

Session-based webhooks

4. What is a session in the WhatsApp Business API?

A session is a 24-hour conversation window that starts when a business message is delivered.

5. What is the difference between an active and inactive session?

An active session occurs when both the business and the customer have exchanged at least one message. An inactive session occurs when only one party has sent a message and the other has not responded.

Webhook reliability and retries

6. What response must your server return for successful webhook delivery?

Your server must return a 200 OK response to confirm that the webhook event was received.

7. What happens if your server does not return a 200 OK response?

If your server does not return a 200 OK response, Wati retries sending the event up to 144 times at 10-minute intervals.

8. What happens if webhook delivery keeps failing?

If there are more than 100 consecutive failures, the webhook is marked as Defective and an email notification is sent. If all retry attempts fail, the event will no longer be sent.

Best practices

9. How can you ensure reliable webhook processing?

To ensure reliable webhook processing:

  • Keep your webhook endpoint available and responsive

  • Log incoming payloads for debugging

  • Handle duplicate events because retries may send the same payload more than once

  • Validate incoming requests to confirm they originate from Wati

Did this answer your question?