What it is
A customer support CRM on the WhatsApp Cloud API. Customers write to a business number on WhatsApp, and agents answer from a shared inbox, organised in teams. A bot greets people, asks what they need in English or Arabic, and hands the conversation to the right team. It runs in production with 500+ agents.
The problem
Sending a WhatsApp message is one API call. Everything around it is a stream. Every customer message arrives as a webhook, and every message an agent sends comes back as up to three more: sent, delivered, read. With hundreds of agents working at once the stream never stops, and it arrives out of order, sometimes twice, and now and then before the message it's about has been saved. Agents still expect a reply to appear the moment it lands.
What I built
- A shared inbox across several business numbers, with teams, tags, private notes, mentions, quick replies, templates and the 24-hour messaging window
- A bot for each number that handles office hours, shows a service menu in English and Arabic, and routes the ticket to the right team, or back to the team that helped last time
- Assignment that keeps workloads level and puts a ticket in front of the agent most likely to take it, without hiding it from the rest of the team
- An asynchronous webhook pipeline on Laravel queues and Horizon, with live updates over WebSockets
- Text, media, locations, contacts, reactions, lists, buttons and flows, plus a web chat widget on the same engine
The interesting parts
Say 200, then think
The webhook endpoint does as little as it can: it stores the raw payload and answers straight away. If the message belongs to a conversation an agent already has open, it's broadcast to their screen first, so they see it before it's even saved. Everything else happens on queues: a job per webhook, an event per message and per status, then separate lanes for live updates, the bot and outgoing messages.
Statuses only move forward
Delivery statuses arrive in any order, so a message's status can only move forward: sent, delivered, read. A late "delivered" after a "read" is kept for the record but can't undo it, and a "read" that arrives first marks the message delivered as well. WhatsApp can even report a message as sent before the call that sent it has returned, so a status for a message that isn't saved yet waits a few seconds and tries again.
Duplicates don't double up
WhatsApp retries webhooks, so the same message can arrive twice. Every message carries WhatsApp's own ID with a unique index behind it, so the second copy finds the first instead of creating another. The bot takes a lock per customer too, so someone who types "hi", "hello" and "?" in a row gets one menu, not three.
Screens that stay in order
Each conversation keeps a sequence number in Redis, so agents' screens apply live updates in the right order and catch up after a dropped connection. Large events carry only an ID and the screen fetches the rest, so one big message never holds up the socket.
Result
It runs in production with 500+ agents using it, and the inbox keeps up without slowing down.