Skip to main content

Overview

Hypersender sends a WhatsApp webhook to your URL whenever something happens on your instance: a new message, a delivery or read receipt, a reaction, a poll vote. You receive it with your own route. The SDK is only needed when you reply. A webhook is a POST with a JSON body and your secret in the Authorization header, so any Go router can handle it. The examples use the standard library’s net/http, and the same handler works with Gin, Echo, or chi. Combine the two examples on this page to build a Golang WhatsApp bot that answers incoming messages.

Set up the webhook

1

Add the webhook in the dashboard

In the Hypersender dashboard, open your WhatsApp instance and add a webhook with your public HTTPS URL, for example https://example.com/whatsapp/webhook.
2

Set a secret

Set an authorization secret on the webhook. Hypersender sends it in the Authorization header so you can reject requests that did not come from Hypersender. Save the same value as HYPERSENDER_WHATSAPP_WEBHOOK_SECRET.
3

Answer quickly

Reply with a 2xx status right away. If handling an event takes time, store the payload and process it in the background.

Receive and verify webhooks

Compare the secret with subtle.ConstantTimeCompare, not ==, so the comparison takes the same time whether or not the secret matches. Refuse to start when the secret is empty, or a request with no Authorization header would match it.

Payload

Every WhatsApp webhook has the same outer shape:
The event-specific fields are in data.payload. Each event page in the WhatsApp webhooks reference shows the full payload.

WhatsApp webhook events

Handle each event

Route on event and reply with the SDK. This example answers incoming messages and records read receipts:
Call handle(r.Context(), body.Event, body.Data.Payload) from your handler after the secret check. For slow work, hand it to a goroutine or a job queue and return right away. A goroutine must not use r.Context(), which is canceled once the response is sent; pass context.Background() instead.
Always skip message.any events where fromMe is true. Otherwise a bot that replies to every message also replies to its own replies.

Next steps

Last modified on November 24, 2026