Every WhatsApp integration starts with the same demo. You send one POST to the Cloud API, a message lands on your phone, and the response hands you back an ID. It takes an afternoon. It feels like most of the work.
It's about one percent of it. I spent a good while building a support CRM on the Cloud API, an inbox that hundreds of agents answer customers from, and almost none of that time went into sending messages. It went into everything that comes back.
Every message comes back three times
A message you send doesn't end when the API says yes. It comes back as webhooks: sent, then delivered, then read. Three updates for every message, each one a database write and a push to the agent's screen. Multiply that by hundreds of agents having conversations all day and the stream never stops.
It doesn't arrive in order, either. A "read" can turn up before the "delivered" it's meant to follow, and a "delivered" can arrive after the "read". So a message's status in my code can only move forward. A late, lower status is kept for the record but can't drag a message backwards, and a "read" that arrives first marks the message delivered on the way.
My favourite one: WhatsApp can tell you a message was sent before the API call that sent it has returned. The webhook is about a message ID your code hasn't saved yet. If you treat that as an error, you lose the status. If you wait a second or two and try again, the ID is there and everything lines up. A few seconds of patience, written down as a retry, is the difference between a status that lands and one that's quietly lost.
Inbound: say 200, then think
Meta wants a quick answer to every webhook. So the endpoint does almost nothing: it stores the raw payload and replies. Turning that payload into a ticket, a bot reply and a live screen happens later, on queues.
The one exception is the part agents care about most. If a customer writes into a conversation an agent already has open, the message is broadcast to their screen straight away, before it's saved. To the agent it just looks fast. Behind it, the real work happens two queue hops later, and the screen quietly swaps the early copy for the saved one.
Outbound needs manners
Sending looks like the easy direction, but it has its own rules. The same customer shouldn't get a burst of messages in one second, so sends to one person are paced. And when a send fails, the important question is whose problem it is. A rate limit or a maintenance window is worth retrying. A policy error or an expired token isn't: retrying it just fails again, slower. So the error list splits in two: retry these, and show these to a person.
Even the leftovers need care
Every webhook's raw payload is kept, because when something goes wrong it's the only record of what actually arrived. Kept forever in a hot table, though, it slows everything down. So a scheduled job moves old payloads out in small batches, and it backs off whenever the queues are busy, so cleaning up never competes with customers.
Where the work really is
None of this shows up in a demo. The API call is the same one line it was on day one. What changed is everything around it:
- statuses that can only move forward, whatever order they arrive in
- a few seconds' grace for webhooks that outrun your own code
- an endpoint that stores and answers, and queues that do the thinking
- retries for problems that pass on their own, and people for problems that don't
When someone tells me a messaging integration is nearly done because the messages send, I ask what happens when the replies come back. That's usually where the project starts.