How a WhatsApp Message Reaches Your App in Real Time
WhatsApp's Business API delivers messages by calling a webhook on your server. That is reliable but it is not realtime for the people who matter — your agents sitting in a browser. Something has to carry the message the last mile.
The path a message takes
- Meta calls your webhook when a customer sends a message.
- The request is queued immediately and acknowledged. Returning 200 fast matters: Meta retries on timeouts, which causes duplicates.
- A worker processes the job — it stores the message, runs any chatbot flow, and decides who should see it.
- The message is published to a channel, typically a private channel for the assigned agent or a shared team channel.
- Every subscribed browser receives it over the WebSocket connection it already holds. No polling.
The result is that a customer's message appears in your agent's inbox in roughly ten milliseconds after your server has it, rather than whenever a polling timer happens to fire.
Why the same socket layer matters
A common architecture bolts a separate realtime service onto a WhatsApp integration. That means two providers, two sets of credentials, two failure modes, and two bills.
With PubSub the WhatsApp relay publishes to the ordinary channel API — the same one your own application code uses. An agent's browser subscribes to one connection and receives both WhatsApp messages and your product's own events on it.
const channel = pusher.subscribe("private-team-support");
channel.bind("message.new", (msg) => {
appendToInbox(msg);
});
channel.bind("message.status", (status) => {
updateTicks(status);
});
Delivery status, not just messages
WhatsApp reports when a message is sent, delivered and read. Those arrive as further webhooks and are relayed as message.status events, which is what drives the ticks in an agent interface. One outbound message therefore produces several realtime events — worth knowing, because it affects how usage adds up.
Bots and humans on one thread
Because the bot and the agent interface read the same conversation, a flow can greet a customer, qualify them, answer common questions, and hand off to a human when it matters. The handoff is itself an event, so the agent's inbox updates the moment a conversation is claimed.