All projects

Open source Case study

Munshi

Multilingual AI business chat

Live GitHub
Role
Author
Type
Open source
Stack
  • Python
  • FastAPI
  • Next.js
  • PostgreSQL
  • Hybrid RAG
  • WhatsApp Cloud API
Multilingual AI business chatMunshi

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.

Cost-aware chat engine
  1. 01GuardPrompt injection
  2. 02LanguageDetect
  3. 03Hand-offTo staff
  4. 04RetrieveBM25 + vectors
  5. 05ConfidenceRefuse w/o LLM
  6. 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.