Back
AI & Automation

Agentic Realty: WhatsApp AI Platform

Agentic Realty: WhatsApp AI Platform architecture diagram

Summary

(9 min read)

The flagship of my AI & Automation work, and my startup. A production platform where an AI agent runs a real-estate agency's WhatsApp line: replying in seconds at any hour, transcribing voice notes in Twi, Pidgin and English, matching leads to real listings without ever inventing one, booking viewings, chasing quiet leads on Day 3/7/14/30, and logging every word into the CRM automatically. Agents control everything from a Telegram bot, mostly by voice. Live in production: 15 n8n workflows, Claude API reasoning, Twenty CRM, and an ~86,000-character engineered persona prompt.

Project Snapshot

My Role

Co-founder · AI & Automation Engineer

Duration

3 months · 2026 · ongoing

Context

Agentic Realty, my PropTech startup

Outcome

Live in production · 15 n8n workflows · replies in seconds, 24/7 · voice notes in 3 languages

Stack

n8nClaude APIWhatsApp Cloud APIGroq WhisperTwenty CRMPostgreSQLRedisTelegram Bot APIGoogle Calendar APIDocker ComposeNginxAWS

The Problem

Context

Mid-tier real-estate agencies in Accra run their entire business on WhatsApp. Around 30 to 80 inquiries a week land on agents' personal phones while they're out on viewings. There is no CRM, or an empty one. Every conversation lives and dies in a chat thread.

The Pain

A lead messages four or five agencies at once, and the fastest reply wins the deal. Messages sit unanswered overnight and on weekends. Follow-ups are forgotten. Voice notes in Twi or Pidgin get skipped. When an agent leaves, their chats, and the pipeline inside them, leave with them.

Why It Mattered

Every ignored message is lost commission. The pitch to agency owners is not 'AI'. It's revenue recovery: the deals dying in their inbox every night, recovered by being the agency that always answers first.

Goals & Requirements

Technical Goals

  • Answer every WhatsApp lead in seconds, 24/7, whether it's text or a voice note in English, Twi, or Pidgin
  • Never fabricate: the AI must not invent a property, price, or availability under any pressure
  • Escalate negotiations and sensitive questions to a human, with SLA-tracked alerts. AI is the interface, the boss closes
  • Let agents run the back office from a phone: reply to leads, create listings, and query the pipeline via Telegram voice notes
  • CRM fills itself: every conversation logged and timestamped, every lead profiled, zero manual data entry
  • Automate the whole lead lifecycle: Day 3/7/14/30 follow-ups, new-listing matching alerts, viewing scheduling and reminders, post-deal review harvesting

Constraints

  • WhatsApp's 24-hour messaging window: free-form replies only within 24h of the last inbound; outside it, Meta-approved templates only
  • Leads send bursts of rapid messages, so conversation locking is required to prevent duplicate, racing AI replies
  • Ghana-first: MTN/Telecel/AirtelTigo/Glo phone validation, Africa/Accra timezone, GHS pricing
  • No PII in logs. Leads are referenced by ID only, never by name, number, or message content
  • Bootstrap budget: one VPS, self-hosted everything, sold as a managed monthly service

Architecture Design

WhatsApp Cloud API webhooks feed an n8n orchestration layer of 15 production workflows. Claude API provides the reasoning behind 'Ama', a warm, persona-engineered agent with an ~86,000-character system prompt, while Groq Whisper transcribes Twi/Pidgin/English voice notes. Twenty CRM is the system of record, accessed exclusively through its GraphQL API; a separate n8n-owned PostgreSQL database holds operational data (leads, conversations, follow-ups, viewings, deals). Redis provides Lua-scripted conversation locks. A Telegram bot is the agents' control plane. The whole stack runs on Docker Compose behind Nginx on an AWS VPS.

Architecture Diagram

Scroll horizontally on smaller screens to view full diagram

Component Breakdown

n8n

Orchestrates all 15 workflows: comms routing, lead intake, nurture, matching, reviews, escalation SLA, CRM sync, and the Telegram agent

Claude API ('Ama')

The conversational brain: qualifies leads, answers from real inventory only, and hands negotiations to a human. All of it driven by an ~86K-character engineered persona prompt

Groq Whisper

Transcribes WhatsApp voice notes. Leads speak Twi, Pidgin, or English while driving, and Ama answers the right property

WhatsApp Cloud API + wa-send subworkflow

The lead interface. Every outbound message flows through one shared wa-send subworkflow, the single place the 24-hour window and template rules are enforced

Twenty CRM

System of record for properties, leads, viewings, and deals. Written to exclusively via its GraphQL API, never its database

PostgreSQL × 2

Twenty's own DB plus a separate n8n-owned operational DB (leads, conversations, follow-up sequences, workflow_errors). The two never cross-write

Redis

Conversation locks: a 60-second TTL with a Lua heartbeat every 15s and compare-and-set release, so burst messages never produce racing replies

Telegram bot

The agents' control plane: dictate a reply to any lead by voice note, create listings by voice, ask the pipeline questions in natural language

Key Design Decisions

AI answers, humans negotiate

Full autonomy is a trust liability in a relationship business. When a lead starts negotiating price, Ama reassures them, pings the boss instantly, and the boss replies with one Telegram voice note that lands on the lead in the agency's own voice. The AI makes the agency fast; the human closes the deal.

Anti-fabrication as a product feature

One invented listing burns a brokerage's name permanently. Ama answers only from live inventory. Ask her for a beachfront 5-bed at an impossible price and she declines and pivots to what's real. In demos this refusal is a selling point, not a limitation.

Two databases that never cross-write

Twenty CRM is touched only through its GraphQL API; operational data lives in a separate n8n-owned PostgreSQL database. This survives Twenty upgrades, keeps a clean audit boundary, and means a bug in one system can't corrupt the other.

One shared wa-send subworkflow for every outbound message

WhatsApp's 24-hour window rule is the kind of policy that rots when copy-pasted across workflows. It lives in exactly one subworkflow that decides free-text vs pre-approved template. No other workflow may call Meta's API directly.

An AI-native engineering process

The repo itself is a Claude Code harness: a project constitution with non-negotiable invariants, seven specialized subagents (architect, workflow-builder, schema-designer, tester, code-reviewer, doc-gardener, researcher), ADRs, and a rule that nothing is DONE until the tester agent returns green and the code-reviewer signs off. It's how a two-founder team ships at this scope.

Implementation Breakdown

01

Ama: engineering a persona at scale

Ama's system prompt is ~86,000 characters, refined over 100+ iterations: persona rules, Ghana-market knowledge, honesty rules, escalation triggers, and dozens of worked example conversations. Making her sound genuinely human was an engineering problem, not a writing problem.

  • Static prompt audits: scripted n-gram and banned-phrase analysis of the prompt against itself. Every robotic tic in live chats was traced to the prompt's own example dialogues, not missing rules
  • Exemplars beat instructions: rules banned phrases like 'on my end' while example replies taught them, so patch scripts now lint every new exemplar against the ban list before shipping
  • Personas are swappable per agency (name, agency brand, review links) via whole-word replacement scripts. Same brain, rebranded per client
  • Debounce plus typing indicators: rapid message bursts are collected into one coherent reply instead of five overlapping ones
  • Budget honesty rules: tell Ama your budget is 15k and she drops the 22k listing and offers what 15k actually gets. She never oversells
02

15 production n8n workflows

Every stage of the lead lifecycle is a version-controlled n8n workflow with an explicit contract doc, and every workflow has an error branch writing to a workflow_errors table. Silent failures are treated as bugs.

  • A · Communications router: webhook intake, delivery-receipt filtering, debounce, conversation locks, routing
  • B · Lead intake & qualification, Ama's home: profiling, qualification, inventory matching, photo sending, escalation triggers
  • C · Nurture: follow-up sender (Day 3/7/14/30), viewing scheduler with Google Calendar, and 24h/2h viewing reminders
  • D · Matching engine: a new listing automatically finds every lead whose profile fits and alerts them on WhatsApp
  • E · Review harvester: post-deal review requests with a 7-day reminder, converging on deal completion
  • F · Escalation SLA: unanswered human escalations re-alert at 2h/4h/6h so a hot lead is never silently dropped
  • Sync workflows: Twenty CRM ↔ operational DB property/lead/CRM sync, plus the Telegram agent and shared wa-send / claude-call / groq-call subworkflows
wa-send: the single enforcement point for WhatsApp's 24h windowjavascript
// Every workflow sends through wa-send. Nobody calls Meta directly.
const hoursSinceInbound =
  (Date.now() - new Date(lead.last_inbound_at)) / 36e5;

if (hoursSinceInbound < 24) {
  // Inside the window: Ama replies free-form, in persona
  return sendFreeText(lead.wa_id, message);
}

// Outside the window: only Meta-approved templates are legal
return sendTemplate(lead.wa_id, "property_followup", {
  name: lead.first_name,
  property: match.title,
});
Redis conversation lock: heartbeat & CAS releaselua
-- Burst-proofing: one reply pipeline per conversation.
-- Acquire: SET lock:conv:{lead_id} <token> NX EX 60

-- Heartbeat (every 15s): only the owner may extend
if redis.call("GET", KEYS[1]) == ARGV[1] then
  return redis.call("EXPIRE", KEYS[1], 60)
end
return 0

-- Release (on every exit path): compare-and-delete
if redis.call("GET", KEYS[1]) == ARGV[1] then
  return redis.call("DEL", KEYS[1])
end
return 0
03

The Telegram control plane

Agency owners don't open laptops. The entire back office is drivable from a Telegram bot, mostly by voice.

  • Dictate a reply: the boss voice-notes 'tell him 13k flat if he pays 6 months upfront, lock a viewing Saturday 11am'. It lands on the lead in Ama's warm voice, and the viewing is booked
  • Create a listing by voice: 'add a 3-bed for rent in Spintex, 8,500 a month'. The property appears in the CRM, and photos sent to the bot attach automatically
  • Query the pipeline in natural language: 'show me all leads looking in East Legon'. Instant answer from the operational DB
  • Escalation alerts arrive here too, so negotiation requests reach the boss's pocket in seconds
04

Reliability engineering & guardrails

An AI agent talking to real customers is a production system first and an AI project second. The unglamorous engineering is what makes it trustworthy.

  • Voucher scripts: every external API (WhatsApp, Claude, Twenty, Groq, Calendar) is smoke-tested with a standalone script before any workflow is built against it. Integrations are never debugged inside n8n
  • Idempotent operations and read-back assertions on every database write
  • Ghana phone normalization at lead creation: strip +/0, prepend 233, validate against MTN/Telecel/AirtelTigo/Glo prefixes
  • Zero PII in logs: lead IDs only, never names, numbers, or message content
  • Append-only versioned migrations for both the operational DB and Twenty's custom objects (Property, Lead, Viewing, Deal, Landlord)

Challenges & Solutions

#1WhatsApp message bursts causing racing AI replies

The Problem

Real leads don't send one tidy message. They send five short ones in ten seconds. Each webhook fired a parallel workflow execution, and with real Claude API latency, a naive flat-TTL lock expired mid-reply: the lead got multiple overlapping, contradictory answers.

The Fix

A Redis lock per conversation with a 60-second TTL, a Lua heartbeat every 15 seconds that only the lock owner can extend, and a compare-and-set release on every exit path, combined with a debounce that batches the burst into one coherent context before Ama replies once. Typing indicators keep the lead engaged while it thinks.

#2The AI's worst habits were taught by its own prompt

The Problem

Live chats kept surfacing robotic tells: 'I don't have that tagged on my end', identical greetings for every lead, database jargon like 'what's actually live'. Rules explicitly banned these phrases, yet they kept appearing, and every prompt edit risked breaking 100+ prior refinements with no token budget for regression testing.

The Fix

Built a zero-cost static audit: scripts that cross-check every example dialogue in the prompt against its own ban lists. The finding: seven 'model' example replies were teaching the exact phrases the rules banned, and exemplars beat instructions every time. Rewrote the offending exemplars into compliant phrasing, varied the duplicate greetings, and added a banned-phrase lint that runs before any new exemplar ships.

#3Being helpful outside WhatsApp's 24-hour window

The Problem

WhatsApp forbids free-form business messages more than 24 hours after the lead's last message, which is exactly when Day-3/7/14/30 follow-ups and viewing reminders need to fire. A workflow that ignores this silently fails in production.

The Fix

All sends route through one shared wa-send subworkflow that checks the last-inbound timestamp and switches between free-form persona replies and Meta-pre-approved templates (property_followup, new_listing_alert, viewing reminders, review_request). Template approval became a tracked prerequisite in every feature plan rather than a launch-day surprise.

Results & Impact

The platform is live in production, deployed on AWS with Twenty CRM and n8n running behind SSL, tested end-to-end over live WhatsApp and Telegram, and now being hardened for its first pilot agency.

Before → After

Lead response time

Hours, or neverSeconds, 24/7
Always first to reply

Voice notes (Twi/Pidgin)

Skipped or delayedTranscribed & answered
3 languages

Follow-ups

ForgottenDay 3/7/14/30 automated
Zero dropped leads

CRM data entry

Manual / skippedFills itself
Every word logged

New-listing marketing

Manual broadcastsAuto-matched alerts
Right lead, instantly

Missed escalations

Lost in chatsSLA re-alerts 2h/4h/6h
Nothing goes silent

Business Outcome

Sold to agencies as a managed monthly service with a free 30-day pilot, positioned as revenue recovery rather than software. The live demo is the pitch: a real lead message answered in seconds on a real number, a Twi voice note understood, a negotiation escalated to the boss's pocket and closed with one voice note. Everything in the demo is real, and that honesty is the selling point.

Reflections

Would Do Differently

  • 01Reserve an API token budget for behavioral regression testing from day one. Static prompt audits catch what the prompt teaches, but only live runs prove how it behaves
  • 02Lint prompt exemplars against the ban lists from the first edit, not after 100. Examples are the strongest instructions in the file
  • 03Add HMAC signature verification on inbound webhooks from day one instead of retrofitting it

Key Takeaways

  • 01In prompt engineering, examples beat instructions. Every robotic tic in production traced back to an exemplar, never to a missing rule
  • 02What makes an AI agent production-grade is boring reliability engineering: locks, debounce, idempotency, error tables, and one enforcement point per external policy
  • 03Partial autonomy is a feature. Routing negotiations to a human closes more deals and builds more trust than a fully autonomous agent would
  • 04An AI-native process (a Claude Code harness with specialized subagents, invariants, and ADRs) is how a two-founder team ships a platform this large

Next Project

Creelo: AI Filmmaking Workspace

AI & Creative Tooling

Creelo: AI Filmmaking Workspace

Thanks for Reading