Agentic AI · Comebck Pakistan Cohort 1

WhatsApp Commerce Copilot

Case study published Project built

WhatsApp Commerce Copilot is an AI-powered commerce platform that lets a clothing brand run its store over WhatsApp. Customer questions are answered automatically from the store's own catalogue, a shop owner can take over the conversation in one click, and stock is edited live from a React dashboard. It was built by a four-person squad in Comebck Pakistan Cohort 1, an 8-week AI readiness program, and is recorded on Sajid Islam's résumé as a Top 5 project of that cohort.

Problem

Pakistani clothing brands sell through Instagram and WhatsApp DMs, and lose orders in two places: questions that go unanswered while the owner is asleep or busy, and Cash-on-Delivery orders that were never properly confirmed.

Before writing code, the squad validated the problem on the ground — messaging 16 Pakistani clothing brands as real customers within one hour to measure how many DMs went unanswered. Only 1 of the 16 replied instantly and completely. The squad then interviewed brand owners to shape the product.

On the 30–35% figure. The squad's problem statement estimated that 30–35% of Cash-on-Delivery orders come back undelivered because customers were never confirmed before dispatch. That range is the squad's own working assumption from customer-discovery conversations — it is recorded in the squad repository without a source, and no authoritative published statistic was found to support that specific range. Treat it as a project assumption, not a measured industry rate.

Solution

An agentic copilot that sits on the brand's WhatsApp number and answers customers from the store's real catalogue rather than from open-ended model knowledge.

The copilot reads customer questions in English, Roman Urdu and Urdu script — language detection is a purpose-built keyword heuristic, because langdetect does not handle Roman Urdu — and answers on sizing, delivery and COD confirmation. The shipped transport is WhatsApp only; Instagram was part of the original product vision but no Instagram integration exists in the codebase.

Architecture

The whole backend runs from a single docker compose up: database, Redis, the Evolution API WhatsApp gateway and the Python backend all come up together. The dashboard is a separate React app.

Dashboard
React / Vite app on port 5173 — conversations, stock, and the Human Mode toggle.
Backend
Python / FastAPI service on port 8000 — all business logic, catalogue retrieval and AI orchestration.
Gateway adapter
A separate Node.js / Express service on port 3001 that normalises Evolution API webhooks and posts them to the backend over an internal token-authenticated route. It is transport-only, which is what makes a later swap to the official Meta Cloud API a contained change.
WhatsApp protocol engine
Self-hosted Evolution API on port 8080; the brand's number is linked by scanning a QR code from the dashboard.
Data stores
PostgreSQL as the primary store (12 tables, SQLite for tests); Redis as the cache Evolution API requires.
Infrastructure
Docker Compose orchestrating PostgreSQL, Redis, Evolution API, the backend and the gateway.
Request path of the WhatsApp Commerce Copilot A vertical flow diagram. A customer's WhatsApp message reaches the self-hosted Evolution API protocol engine on port 8080, which posts a webhook to a Node.js Express gateway adapter on port 3001. The adapter normalises the payload and forwards it to the Python FastAPI backend on port 8000 using an internal token, where the message is normalised and its language, intent and entities are detected. The backend queries PostgreSQL for catalogue products and store policies, every query scoped by store id. At most five retrieved candidates are passed to an optional LangChain chain, used only for ambiguous or low-confidence queries; any product id it returns outside that candidate set is rejected. The grounded reply, carrying a matched product id and sources, is sent back to the customer. Separately, a React and Vite dashboard on port 5173 lets the shop owner toggle Human Mode, which disables the AI so they can reply personally. Redis on port 6379 backs Evolution API, and all six services run under Docker Compose. WhatsApp customer English, Roman Urdu or Urdu script Evolution API self-hosted protocol engine (Baileys) :8080 webhook Gateway adapter Node.js / Express — normalises payload :3001 X-Internal-Token FastAPI backend normalise · language · intent · entities :8000 store-scoped query Catalogue + policy retrieval PostgreSQL · scoped by store_id :5432 ≤ 5 candidates LangChain (optional) low-confidence queries only non-candidate IDs rejected Grounded reply carries matched_product_id + sources sendText Customer receives the reply React / Vite dashboard conversations, stock, Human Mode :5173 one click Human Mode AI off — the owner replies personally Redis (:6379) backs Evolution API. All six services run under Docker Compose.
Fig. 1 — the path a customer message actually takes, drawn from the project's docker-compose.yml and architecture notes. Every component shown exists in the repository; nothing here is aspirational. Note the two separate Node services: Evolution API speaks the WhatsApp protocol, while the gateway adapter is transport-only, which is what makes a swap to the official Meta Cloud API a contained change.

How the AI layer is grounded

The backend ships with a deterministic catalogue pipeline that keeps working with no AI key present. When a provider is configured, inbound messages pass through a LangChain intent chain, and LangChain response generation is used for ambiguous or low-confidence queries only. Crucially, that generation step receives only store-scoped products and policies retrieved by the backend — retrieval grounding that keeps answers tied to the brand's actual inventory instead of invented detail.

The grounding contract is enforced, not merely prompted: the model never queries the database. The deterministic layer pre-fetches at most five candidates, and any product or variant ID the model returns outside that closed set is rejected in favour of the deterministic response. Every reply carries traceability fields (matched_product_id, sources). Store isolation is likewise structural — every query is scoped by store_id.

Technology

Results and validation

Team and my contribution

Built by a four-person squad — Squad Margalla: Sajid Islam, Khansa Maryam, Muhammad Ullah Baig and Manahil Shah — over eight weeks. My résumé records my part as running the ground-truth user validation (contacting the 16 brands and interviewing owners) and building the agentic AI and LLM integration; the squad repository's commit history shows my work concentrated in the backend, the catalogue and grounding pipeline, and the order flows.

The precise engineering split across the four squad members is not documented in the public repository, so it is deliberately not itemised here.

Limitations and lessons learned

Related reading

View project source on GitHub → Back to all projects

Next case study: Entropy-Aware Data Preservation System →