cd /news/ai-agents/building-a-production-whatsapp-ai-ag… Β· home β€Ί topics β€Ί ai-agents β€Ί article
[ARTICLE Β· art-89592] src=dev.to β†— pub= topic=ai-agents verified=true sentiment=↑ positive

Building a Production WhatsApp AI Agent: Architecture That Actually Works

A developer has detailed the architecture behind SARA, an open-source WhatsApp AI agent that has achieved 99.7% uptime over six months using a multi-provider AI chain with zero inference cost. The system, which serves businesses across 20 industries, employs a four-provider failover chain (Groq, Cerebras, SambaNova, Mistral) and a tool dispatcher with an autonomy gate to handle actions like reservations and inventory checks. The developer emphasizes that production AI is 10% model quality and 90% engineering, sharing lessons on WhatsApp-specific constraints such as session contention and message ordering.

read2 min views1 publishedAug 9, 2026

Everyone demos a WhatsApp chatbot. Few run one in production with real customers sending real messages 24/7.

After 18 months of running SARA β€” an open-source WhatsApp AI agent serving businesses across 20 industries β€” here's what we learned about architecture that survives contact with reality.

The numbers are simple:

But WhatsApp is NOT just another chat channel. It has unique constraints that break naive implementations.

WhatsApp (WAHA) β†’ Bridge (:3008) β†’ SARA API (:3006) β†’ AI Provider Chain β†’ Tool Dispatcher
                                                              ↓
                                                    Groq β†’ Cerebras β†’ SambaNova β†’ Mistral

Single-provider AI is a production risk. We use a 4-provider chain:

Primary: Groq (fastest, free tier)
    ↓ fail
Fallback 1: Cerebras
    ↓ fail
Fallback 2: SambaNova
    ↓ fail
Fallback 3: Mistral (paid, always works)

Each provider gets 2 retries with exponential backoff before failover. Result: 99.7% uptime over 6 months with $0 inference cost (free tiers).

SARA doesn't just answer questions. She executes actions:

create_reservation

β€” books a table with date normalization ("domani alle 8" β†’ 2026-08-10T20:00)check_inventory

β€” queries stock levelsgenerate_invoice

β€” creates a PDF from database recordsschedule_appointment

β€” manages calendar slotsThe dispatcher maps 30+ tools to handlers with an autonomy gate:

User message β†’ Intent classification β†’ Risk assessment β†’ Tool execution
                                              ↓
                                    Low risk: execute immediately
                                    Medium: execute + notify owner
                                    High: ask for confirmation first

You do NOT want your AI agent booking a catering order for 500 people without human approval.

Messages contain names, phone numbers, addresses. Our pipeline:

WhatsApp doesn't have "sessions" β€” it's just a stream of messages. We manage context with:

SARA runs on a single VPS (4 vCPU, 8GB RAM):

Component Resource
WAHA (WhatsApp Web) ~500MB RAM
Bridge service ~50MB
SARA API ~200MB
PostgreSQL + pgvector ~2GB
Total ~3GB

No GPU needed β€” inference is offloaded to cloud providers (Groq, etc.).

WhatsApp session contention β€” running two instances with the same number = instant logout for both. We learned this the hard way.

Date parsing across languages β€” "dopodomani" (Italian for "day after tomorrow") + timezone handling + business hours awareness. This alone took weeks.

Message ordering β€” WhatsApp doesn't guarantee delivery order. Our bridge queues and re-orders by timestamp.

SARA is AGPL-3.0 on GitHub: github.com/Alessandro114/sara

Self-host it, extend it, build your own vertical agent on top. Cloud-only features (multi-tenant, white-label, analytics) stay in the commercial version.

The 20 industry-specific agent definitions are also open source: scala-agent-definitions (Apache-2.0).

Running AI in production is 10% model quality and 90% engineering. Follow for more war stories.

── more in #ai-agents 4 stories Β· sorted by recency
── more on @sara 3 stories trending now
sponsored brought to you by zahid.host 4,200+ EU-deployed projects
reading about agents? ship yours in a single git push.

Run your AI side-project on zahid.host

EU-based hosting, git-push deploys, automatic HTTPS, no cold starts. Free tier with a custom domain β€” perfect for shipping the agent you just read about.

$git push zahid main
β†’ Live at https://your-agent.zahid.host βœ“
Get free account β†’ Pricing
from €0/mo Β· no card required
LIVE [news/building-a-productio…] indexed:0 read:2min 2026-08-09 Β· β€”