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 aPOST 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
- net/http
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:data.payload. Each event page in the WhatsApp webhooks reference shows the full payload.
WhatsApp webhook events
Handle each event
Route onevent and reply with the SDK. This example answers incoming messages and records read receipts:
- Basic Usage
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.Next steps
- Send Messages: reply with text, media, polls, and more
- WhatsApp webhooks reference: every payload in full