Limited Time: Start your 14-day free trial, no credit card required
Back to Blog
Tutorials

WhatsApp Webhook Setup: Receive Real-Time Message Events (2026)

Walytic TeamJuly 1, 20267 min read

What Is a WhatsApp Webhook?

A WhatsApp webhook is an HTTP endpoint on your server that receives real-time notifications when events happen on your WhatsApp number — an incoming message, a message delivered, a message read, or a status update.

Instead of your application polling WhatsApp every few seconds asking "any new messages?", a webhook flips the model: WhatsApp (or your automation platform) pushes the event to your server the instant it happens.

Common events delivered via webhook:

  • New incoming message from a contact
  • Message delivered to recipient's device
  • Message read by recipient
  • Contact replies to a broadcast or chatbot flow
  • Delivery failure or error

Webhooks are the backbone of any real-time WhatsApp integration — they're what lets your CRM update the moment a customer replies, or your support ticket close the second a customer confirms their issue is resolved.

Two Ways to Receive WhatsApp Webhooks

Option 1: WhatsApp Business API (Official)

Meta's official WhatsApp Business API delivers webhook events through an approved BSP (Business Solution Provider). You register a callback URL in the Meta Developer Console and verify it by responding to a challenge request.

Pros: Official, green-tick compatible

Cons: Requires business verification (days to weeks), approved templates for outbound messages, per-conversation fees of $0.005–$0.08

Option 2: Linked Device Technology (Faster Setup)

Platforms like Walytic use WhatsApp's linked device technology — the same system that powers WhatsApp Web and Desktop — to forward webhook events to your server without Meta's BSP approval process. You register your endpoint in the Walytic dashboard and start receiving events in minutes.

Pros: Setup in under 5 minutes, no business verification, no per-message fees

Cons: No green-tick verification

For most developers building automations and integrations, the linked device approach is faster and cheaper to get production-ready.

Setting Up Your Webhook Endpoint

Before connecting any platform, you need an HTTPS endpoint that can receive POST requests and return a 200 OK response within 5 seconds.

Here's a minimal webhook receiver in Node.js:

javascript
const express = require('express');
const app = express();
app.use(express.json());

app.post('/webhook/whatsapp', (req, res) => {
  const event = req.body;
  console.log('Incoming WhatsApp event:', JSON.stringify(event, null, 2));

  if (event.type === 'message.received' && event.message.fromMe === false) {
    const from = event.message.from;
    const text = event.message.body;
    console.log(`New message from ${from}: ${text}`);
  }

  res.sendStatus(200);
});

app.listen(3000, () => console.log('Webhook receiver running on port 3000'));

Your endpoint must:

  1. Respond with HTTP 200 within 5 seconds — offload long processing to a queue
  2. Handle duplicate events (webhooks can re-deliver on timeout)
  3. Use HTTPS — plain HTTP endpoints are rejected

Walytic WhatsApp Webhook Setup (Step by Step)

Setting up WhatsApp webhooks in Walytic takes under 5 minutes:

Step 1: Sign Up and Connect Your Number

Create your Walytic account and navigate to Devices. Click Add Device and scan the QR code with your WhatsApp app to link your existing number.

Step 2: Register Your Webhook URL

Go to Settings → Webhooks in your Walytic dashboard. Click Add Webhook and enter your HTTPS endpoint URL. Select the event types you want to receive:

Event TypeDescription
`message.received`A contact sent your number a message
`message.sent`Outbound message dispatched
`message.delivered`Message reached recipient's device
`message.read`Recipient opened the message
`message.failed`Delivery failure

Step 3: Verify Delivery

Walytic sends a test payload to your endpoint immediately after saving. Check your server logs for the incoming POST request and confirm you responded with 200. The dashboard shows green status when verification succeeds.

Step 4: Add a Signing Secret

Set a Webhook Secret in the dashboard. Walytic includes it as an `X-Walytic-Signature` header on every request so your server can verify events are genuine and not spoofed.

WhatsApp Webhook Payload Structure

Here's what a `message.received` event looks like:

json
{
  "type": "message.received",
  "timestamp": "2026-07-01T09:15:33Z",
  "deviceId": "device_abc123",
  "message": {
    "id": "msg_xyz789",
    "from": "+15551234567",
    "fromMe": false,
    "body": "Hi, what are your opening hours?",
    "type": "text",
    "timestamp": "2026-07-01T09:15:31Z"
  },
  "contact": {
    "phone": "+15551234567",
    "name": "Jane Smith",
    "isOptedIn": true
  }
}

For media messages, the payload includes a `media.url` field pointing to a temporary download URL for the image, document, or audio file.

Securing Your WhatsApp Webhook

1. Verify the Signature

Always validate the `X-Walytic-Signature` header before processing:

javascript
const crypto = require('crypto');

function verifySignature(rawBody, signature, secret) {
  const expected = crypto
    .createHmac('sha256', secret)
    .update(rawBody)
    .digest('hex');
  return crypto.timingSafeEqual(
    Buffer.from(signature),
    Buffer.from(expected)
  );
}

app.post('/webhook/whatsapp', express.raw({ type: 'application/json' }), (req, res) => {
  const sig = req.headers['x-walytic-signature'];
  if (!verifySignature(req.body, sig, process.env.WEBHOOK_SECRET)) {
    return res.status(401).send('Unauthorized');
  }
  const event = JSON.parse(req.body);
  // Safe to process
  res.sendStatus(200);
});

2. Respond Fast, Process Async

If your processing logic takes more than 2–3 seconds (database writes, calls to other APIs), respond with 200 immediately and push the event to a queue:

javascript
app.post('/webhook/whatsapp', (req, res) => {
  res.sendStatus(200);      // Respond instantly
  queue.push(req.body);     // Process in background
});

3. Handle Idempotency

Webhooks may be delivered more than once. Use the `message.id` field to deduplicate events in your database before processing to avoid double-handling the same message.

Webhook vs Polling: Why It Matters

ApproachLatencyServer LoadReliability
Polling every 5s0–5 secondsConstant requestsMisses events if server is down
Webhooks (push)Near real-timeOnly on eventsRe-delivered on timeout

For real-time chatbots and support tools, polling creates a 5–15 second lag that makes conversations feel slow. Webhooks eliminate that delay entirely — your system reacts to every message within milliseconds of receipt.

What to Build With WhatsApp Webhooks

Once your endpoint is live, the use cases are broad:

  • CRM sync: Write every incoming message to HubSpot, Salesforce, or your own database
  • Support ticketing: Auto-create a ticket in Zendesk or Freshdesk when a customer first messages
  • Chatbot routing: Trigger different flows based on message keywords or contact attributes
  • Analytics: Log all events to a data warehouse for conversation-level reporting
  • Auto-replies: Respond instantly to after-hours messages using your own logic
  • Payment triggers: Update order status the moment a customer confirms payment via WhatsApp

Combined with Walytic's REST API, webhooks give you full bidirectional control — send outbound messages via REST calls, receive inbound events via webhooks, and build any integration your stack needs.

Start Receiving WhatsApp Webhooks Today

Webhooks turn your WhatsApp number into a real-time event stream for your entire application stack. Once configured, every incoming message, delivery event, and read receipt flows directly into your systems without polling or delay.

Start your free 14-day trial with Walytic — connect your WhatsApp number in under 2 minutes and start receiving webhook events with no per-message fees. No credit card required.

Ready to Automate WhatsApp?

Start sending bulk messages, automate follow-ups, and build chatbots, all with flat-rate pricing. No per-message fees.

Start Free 14-Day Trial