All work

WhatsApp assistant for real-estate agents

I captured every agent conversation from WhatsApp, then gave agents an assistant that steps in when a conversation stalls and answers only from the brokerage's own listings and deals.

Role
Sole engineer: design, build and operation
Where
La Capitale Real Estate, Dubai
When
2025
WhatsApp chatbots live at La Capitale
Production
SaaS costs saved by replacing paid tools
AED 25k
Capture, assist, then grounded replies
3 phases

The problem

Agents ran their client conversations on WhatsApp from their own numbers. Those conversations, and the brochures and documents shared in them, stayed on individual phones, where the business could not see, search or learn from them.

The brief had two parts: capture every conversation reliably, then give agents an assistant that could step in when a conversation broke down, without ever inventing a price or an availability.

Follow one message

WhatsApp assistant architecture: a capture lane from WhatsApp through a FastAPI webhook, ingest and media workers into PostgreSQL and S3, and an assist lane from breakdown detection through listing retrieval and a model router to a drafted reply.CaptureAssistWhatsApp Cloud APIagents' own numberscoexistence modeFastAPI webhooksignature checkqueues on SQSIngest workersupsert by message IDand agent numberPostgreSQLthreads, messagesand labelsMedia workersretry, refresh linksSHA-256 checksumAmazon S3encrypted mediaand data lakeBreakdown trigger/assist, 20-min silence,repeats, sentimentListing retrievalfilter, broaden,rerank top 15Model routersmall model first,escalate onceDraft or replyagent sends it;/bot off any timeListings and dealspgvector, HNSWBudget guardalert at 70%, hard cap

Scroll the diagram sideways to see all of it.

  1. A client messages an agent

    Agents keep using WhatsApp on their own numbers. Coexistence mode with the Cloud API sends every message to the system as a webhook.

  2. The webhook verifies and queues it

    A FastAPI service checks the request's signature, puts the message on an SQS queue and acknowledges at once, so a slow step downstream never loses a message.

  3. Ingest stores it exactly once

    Workers upsert each message keyed on WhatsApp's message ID and the agent's number, and remove it from the queue only after it is stored. Duplicate and out-of-order deliveries are harmless.

  4. Media is saved with the conversation

    Photos, PDFs and voice notes are downloaded by media ID with retries and refreshed links, checksummed and stored encrypted in S3.

  5. The assistant notices a stall

    It steps in when the agent types /assist, the client waits more than 20 minutes, a question repeats or the tone turns negative.

  6. Retrieval finds real listings

    Filter by the client's requirements, broaden if too few match, re-rank the top 15 with pgvector and pass the best three with reason codes. No match means one clarifying question, never a guess.

  7. A small model drafts the reply

    A low-cost model writes in the agent's style and escalates once only when retrieval is thin. The agent sends the draft; only scheduling is answered automatically, within each agent's budget.

The production design at La Capitale. Capture runs independently of the assistant, so recording conversations never depends on the AI being available.

How I built it

I delivered it in three phases, each with its own definition of done, so the business got value from the first week and the riskier AI work rested on proven foundations.

Phase 1: capture everything

Phase 2: data readiness and assist mode

Phase 3: grounded replies

Key decisions

Quality and evaluation

Security and privacy

Infrastructure and operations

Targets I set: at least 99% of messages captured, media saved within 60 seconds at p95, assistant drafts within 5 seconds and takeover replies within 8 seconds at p95, a top-three retrieval hit rate of at least 95% on the golden set, and no more than USD 25 per agent per month.

Results

What I would do differently

Stack

Hiring an AI engineer?

I am based in Dubai on a UAE residence visa and open to roles in the UAE and abroad. I am glad to walk through any of these systems in detail.