Receive Messages via Webhook
Overview
When a WhatsApp user sends a message to one of your connected numbers, Muchaw DEV routes that message to your webhook URL. This guide walks through setting up a webhook server that securely receives and processes these events.
Step 1 — Create a webhook
Save the secret from the response — you’ll need it to verify incoming requests.
Step 2 — Build the webhook handler
Always respond with 200 before processing. Muchaw DEV waits up to 10 seconds for a response. If your processing takes longer, respond immediately and handle the event asynchronously.
Step 3 — Expose your server publicly
For local development, use a tunnel like ngrok:
Update your webhook URL to the ngrok URL.
Step 4 — Test the webhook
Response:
Webhook event structure
All events follow the same envelope:
The data shape depends on the event type. For message.* events, it’s a Message object. For number.* events, it’s a Number object.
Handling retries
Muchaw DEV retries events up to 3 times with exponential backoff. Your handler should be idempotent — processing the same event twice must not cause side effects (duplicate records, duplicate sends, etc.).
Use event.data.id as a deduplication key:
In production, use Redis or your database for deduplication.