SmartRestoAI
WhatsApp AI ordering for restaurants.
- LangChain
- FastAPI
- .NET 8
- Next.js
- PostgreSQL
- WhatsApp Cloud API
- EF Core
- SignalR
- DeepSeek
- OpenAI
- Gemini
- Sentry
- PostHog
- Docker
Closed source · case study
The problem
Restaurants already take orders on WhatsApp, by hand. Someone reads out the menu, works out the total and the delivery fee, asks for the address and types the order into the system, one chat at a time. At peak hours that's a queue.
An AI agent can run the conversation. But a model that guesses a fee, or tells a customer their order is placed when it isn't, costs real money and real trust. The hard part isn't the chat. It's making every number and every confirmation true.
My role
I joined early and became the main contributor across the stack: the agent, the .NET API and the dashboards.
- Rebuilt the agent: its 12 tools, the prompt, and the guards around every reply
- Model routing, failover and the evaluations that chose the models
- Most of the .NET 8 API: orders, offers, escalations, usage and billing
- The restaurant dashboard and the platform admin, in Next.js
- Running it in production: observability, incidents, and the fixes they led to
Architecture
ALSO IN THE SYSTEM
- Voice notes are transcribed and photos captioned before the agent sees them
- Any fee in a reply must have been authorised by a tool; misnamed dishes and impossible pickup promises are caught in code
- If a customer says yes and the model asks again, a guard places the order, but only when four conditions hold: forcing an unwanted order is worse than losing one
- Every guard's hit rate is counted on an internal stats endpoint: you can't hold a failure rate you don't measure
- Webhook signatures are verified fail-closed, in constant time; the body-size cap runs before the check
- PostHog tracks LLM cost and latency per model; Sentry reports errors from the dashboards
Key decisions
The model can't lie about an order
- CHOSE
- A guard on every reply. If it claims the order is placed and create_order never ran, the agent is re-run with the exact quoted order, twice at most. If there's still no order, the chat goes to a human and the false reply is never sent.
- REJECTED
- Relying on a prompt rule alone, or asking the model to rebuild the order itself.
- WHY
- Rebuilding the order is exactly what the model just proved it can't do reliably, so the guard hands the quoted arguments back instead. A confirmation the kitchen never received is the worst failure this product can have.
Code owns every number
- CHOSE
- The quote tool sums the cart in code from the menu the .NET API serves, discounts come from the API's offer engine, and the API re-prices every order from the database when it's created.
- REJECTED
- Letting the model add up the items it can see.
- WHY
- Language models are unreliable at arithmetic, and a wrong total is an argument with a real customer. The model never computes a number: it only relays one.
The model picks the zone, code checks the evidence
- CHOSE
- Put the menu and delivery zones straight into the prompt. The model picks the zone; code checks that the customer actually said it, negations included.
- REJECTED
- Lookup tools for menu and zones, and a deterministic fuzzy matcher for addresses.
- WHY
- One measured lookup took 13.45 s, 12.54 s of it model time, so the lookups went. The fuzzy matcher charged real customers the wrong fee. A prompt rule is a probability, and money needs a rule that holds every time.
Fail over on hangs, not just errors
- CHOSE
- Every model call gets a 60-second wall-clock limit, and three timeouts in a row pin the fallback model for an hour. The fallback may only answer if no tool with side effects has run yet.
- REJECTED
- Waiting for the provider to return an error.
- WHY
- The incident that triggered it was a provider that hung instead of failing. And handing a turn to a second model after an order was already written could place it twice.
Results
2,096
customers since September 2026
1,432
ordered through the agent
3,440
orders placed by the AI
51.5%
of customers who ordered came back
First client, since September 2026.
What I'd do next
- 01
Make the live-model battery (57 scripted conversations plus replays of reported ones) a gate on every change instead of a manual run.
- 02
Move conversation state (history, quotes, debounce, failover, rate limits) out of the process, so the service can run more than one replica and survive a restart.
- 03
Check that the confirmed quote total equals the created order's total, not just its items.