- Role
- Author
- Type
- Open source
- Stack
- Python
- FastAPI
- Next.js
- PostgreSQL
- Hybrid RAG
- WhatsApp Cloud API
Multi-tenant AI assistant for businesses on the web and WhatsApp, in Urdu, Roman Urdu, English and Arabic. Answers from the business’s own documents, scores leads and hands off to staff.
The problem
Businesses in Pakistan and the Gulf get customer questions on WhatsApp in several languages. Generic bots answer in one language, make things up and cost too much per message.
What I built
A cost-aware chat engine that runs cheap checks first and calls the LLM last, with hybrid retrieval scoped to each tenant and a router that falls back across model providers.
- 01GuardPrompt injection
- 02LanguageDetect
- 03Hand-offTo staff
- 04RetrieveBM25 + vectors
- 05ConfidenceRefuse w/o LLM
- 06LLM routerCheap → strong
Highlights
- 01
Hybrid retrieval
BM25 and embedding similarity fused with Reciprocal Rank Fusion, always scoped to the tenant and agent.
- 02
LLM router with fallback
Routes across Gemini, Anthropic and OpenAI; every reply records tokens, cost, model and citations.
- 03
Tenant isolation, tested
Isolation enforced in code and attacked by tests on every endpoint, with Postgres row-level security as a second layer.
- 04
Business workflows
WhatsApp Cloud API, lead scoring, bookings, an exact installment calculator and a shared inbox.