I Designed a Commerce Bot. WhatsApp Redesigned It.
From the publisher’s feed, collected in the ZeroLabs newsroom.
Architecture Notes #1The webhook landed at 9:14 AM. Message body:bhai same as last timeMy intent classifier had nothing. No product name, no quantity, no category. Just a reference to something the bot had never been told about.My first instinct was to call it an edge case. Handle it later. Get the core flows working first.That was wrong.“Same as last time” isn’t an edge case for a B2B pharmacy reorder bot. It’s the primary use case. FundlyMart is a WhatsApp commerce system for Indian pharmacy retailers — they search medicines, build a cart, and place orders through natural conversation on WhatsApp. Real pharmacists, real inventory, real orders. And those pharmacists don’t browse. They restock. “Same as last time” is how most of them think about that action. Not “show me my order history.” Not “let me rebuild my cart from scratch.” Just: same as last time, bhai.That message forced me to rebuild how the agent reasons about context. But it also forced something bigger: I started noticing how many architectural decisions I wasn’t making. WhatsApp was making them.Here’s what the channel forced.There’s No UIThe first thing you hit when you design a commerce flow inside WhatsApp is that you have nothing to work with.No dropdowns. No product carousels. No “Add to Cart” button. No quantity steppers. No search bar with autocomplete. No confirmation modal.What you have: a text input, and whatever the user decides to send.Early on, I prototyped cart confirmation like this: “Your cart has 3 items totaling ₹2,400. Reply 1 to confirm, 2 to edit, 3 to cancel.”It worked in solo testing. Then I showed it to a pharmacist during an early walkthrough. He didn’t type “1.” He typed “haan bhai confirm karo.” (Yes, confirm it.)I adjusted the prompt. Next session: “thik hai.” (Okay.) Then just “ok.” Then silence for twelve minutes, followed by a completely different product query. He’d gotten pulled away by a customer at the counter.When there’s no button to constrain the input, you can’t constrain intent to a numbered list. The entire UI layer moves into natural language. FundlyMart has to handle every regional variation of “yes” — Hindi, English, Hinglish, implicit, ambiguous — plus every variation of “let me think about it” and “I got distracted.” Pharmacists are in the middle of a workday when they’re using this. Three other chat windows open. A delivery at the door. A supplier on hold.That forced a specific design constraint for every response FundlyMart sends. Short enough to read in under three seconds. Structured enough to carry a cart summary without losing the user. Open-ended enough not to back them into a corner. In a web app that tradeoff is nice to have. On WhatsApp it’s the only mode that works, and it applies to every message.The Hinglish ProblemStandard NLP intent classification makes a few assumptions you don’t notice until they break.Clean input. Consistent vocabulary. A defined language. Entities that map cleanly to something in your catalog.None of those hold when your users are pharmacy retailers typing fast on mobile WhatsApp.Actual queries from testing and early beta:“bhai telma 40 hai kya” — “do you have Telma 40?” (Telma is a telmisartan brand for hypertension; the user assumes you know it without spelling it out)“augmentin leke do 10 strip” — Hindi verb, English brand name, English product unit, one sentence“clavem 625” — meant CLAVAM 625, a co-amoxiclav antibiotic; phonetic misspelling, extremely common among retailers who learned the name by ear“same as last time but add the BP tablets” — full context reference plus a partial new intent in the same message, no product name anywhereThe clavem case is where you learn the most.A pure lexical matcher returns nothing. Search the catalog for “clavem 625” and you get zero results. The pharmacist concludes the bot is broken, which is accurate enough.A vector search might catch it. Running cosine similarity over medicine name embeddings via pgvector, “clavem” might land close enough to “CLAVAM” to return the right result. Maybe 65–70% of the time on inputs like this. Not reliable enough for a production ordering system where a wrong drug suggestion has real consequences.An LLM can infer the correct medicine from the raw query. But you’re paying per call and you don’t want to invoke the model for every product search in a high-volume system.None of those works alone. What FundlyMart uses is a three-tier fallback I built one failure at a time:Tier 1 — Lexical match. Exact or near-exact string match against the medicine catalog. Fast, free, zero hallucination risk. If the user types “Augmentin 625” and that string exists in the catalog, done.Tier 2 — Vector match. Cosine similarity search over medicine name and description embeddings via pgvector. Handles abbreviations, alternate brand names, common misspellings. This is where “clavem” finds CLAVAM 625.Tier 3 — LLM extraction. When Tiers 1 and 2 both miss, the raw query goes to the model, which pulls a recognizable medicine name from it. This catches the hardest cases: fragmented Hinglish, brand names the user half-invented, contextual references like “the white tablets from last month.” If the LLM extracts a name, that name then runs back through Tier 1 — the result is always catalog-grounded, never hallucinated.Each tier was added after the one above it failed for a real input class in production.Each tier exists because the one above it failed for a specific input class I saw in production.The one I remember most clearly: a pharmacist typed “normet.” He meant Normet — a norfloxacin + metronidazole combination used for GI infections. Common drug. Tier 1 returned nothing. Tier 2 returned Norflox — norfloxacin alone — a different drug with different indications. The pharmacist messaged back: “bhai yeh nahi, normet chahiye.” (Not this, I want Normet.) We added a catalog entry and tuned the index that day. But the failure mode was real: a plausible-looking result that was clinically wrong. Confident and incorrect is the worst failure mode in a medicine ordering system.The Hinglish problem isn’t solved. It’s managed. New users keep introducing query patterns I haven’t seen. The three-tier stack buys resilience, not completeness. The long tail is still there.Nobody BrowsesI built the initial FundlyMart agent like a standard commerce chatbot. User searches for a product, agent returns results, user picks one, adds to cart, repeat until checkout.That model works for a consumer medicine delivery app. For a B2B pharmacy reorder bot, it’s almost entirely wrong.Pharmacy retailers have stable, predictable ordering habits. The top 35–40 medicines in any retailer’s regular assortment account for roughly 80% of their weekly order volume. These aren’t browsing sessions — these are restocking runs. The pharmacist knows what they need. They need to communicate it fast and get back to their counter.“Same as last time” is the extreme version of this. But the pattern shows up constantly:“last week waali order” — last week’s order, just repeat it“Augmentin aur usual stuff” — one explicit brand name, everything else implicit“8 ka order phir se” — the order from the 8th, again“add the BP tablets to whatever I had before”None of these are standalone product queries. All of them require the agent to maintain a working model of what this specific user has ordered before — and to reason about that history mid-conversation, without being asked explicitly.In a web app this is a Reorder button. Order history page, check the items, one click.On WhatsApp, the agent has to figure out which prior order the user means, pull those line items, format them into a text message summary the user can read and verify in under ten seconds, and carry them forward into a live cart. Then handle partial modifications: “same as last time but skip the Metformin, we’re overstocked” means cart hydration plus a removal operation in natural language, no UI affordance to confirm the change.What that looks like in practice: FundlyMart calls an order history tool, surfaces the most recent order, renders it as a compact text summary — medicine name, quantity, price per unit — and asks the user to confirm before adding to cart. If they say “haan” (yes), the items go in. If they say “add the BP tablets too,” the agent adds the cart context, does a fresh search for BP tablets, and merges the results. The whole flow is conversational. There’s no UI step where the user can visually inspect a list and tick boxes.I added explicit order history retrieval to FundlyMart’s tool set about two weeks into the build, after the second internal testing session. Not because I’d anticipated the use case — because I watched it break twice in the same afternoon. A pharmacist opened with a prior order reference, the bot returned a generic search prompt, the pharmacist repeated himself, the bot still couldn’t help. He gave up both times.The shift wasn’t adding a feature. It was recognizing that “recall what this user has ordered before” is a first-class reasoning requirement for this domain. A good human order-taker at a wholesale distributor remembers their regulars. They know that “the usual” is complete and actionable. The agent has to work the same way.The Clock Is Always RunningEvery WhatsApp conversation runs inside a 24-hour session window.From the moment a user sends a message, you have 24 hours to reply in the full message format. After that, only pre-approved template messages will deliver. You can’t send free-form responses until the user initiates again.For a quick-query chatbot, this barely registers.For a commerce flow where a pharmacist starts building a cart at 10 AM, gets pulled into a supplier call, and comes back the next morning expecting to continue — it matters in ways that fail silently.It happened three times in the first ten days of beta access. All three mid-cart. All three ended with the pharmacist typing some variation of “confirm karo” into a bot that had no active session, no cart context, and no idea what they were referring to. All three ended with the pharmacist starting over from scratch.Two things fix this:Cart state is not conversation state. WhatsApp makes this mandatory — not a design choice.Cart state has to be independent of session state. The cart doesn’t expire when WhatsApp’s timer does. A pending order with eight line items lives in the database, not in conversation context. When the session dies, the cart survives.Re-entry detection. When a pharmacist comes back after session expiry and sends anything at all — even just “hi” — FundlyMart checks for a pending cart before responding. If one exists, the first reply is the cart summary and a clear path to continue or discard. Not “Hello! How can I help you today?” That response, after a 16-hour gap with a half-built order sitting in the system, is the WhatsApp equivalent of logging someone out mid-checkout and greeting them with a blank homepage.What you can’t do is reach them proactively after the window closes. A “your cart is still waiting” message won’t deliver through standard WhatsApp messaging once the session expires. You’d need a pre-approved outbound template, a separate infrastructure setup. Re-entry detection handles most cases because pharmacists generally remember they were mid-order. But that’s a bet on user memory, not system reliability — something to properly solve later.The session window forced a clean separation between conversation state (ephemeral, session-scoped) and commerce state (persistent, user-scoped). That separation is good practice in any distributed system. On WhatsApp it’s not optional. You can’t cut the corner.The Platform Made the DecisionsI’ve built web apps, mobile features, API services. None of them taught me constraints the way WhatsApp has.On a UI-rich platform, constraints are negotiable. Response too long? Add a modal. Numbered reply feels clunky? Swap in a button. Users mistyping? Build autocomplete. The platform can absorb a lot of design mistakes.WhatsApp doesn’t absorb anything. The text input is the interface. Natural language is the only affordance. The session clock runs whether you’ve planned for it or not.None of the architecture in FundlyMart came from a whiteboard. I didn’t design a three-tier search fallback because I was being careful about phonetic variation in Indian pharmaceutical brand names — I built it because pharmacists kept typing “clavem” and the bot kept returning nothing. I didn’t make order history retrieval a first-class reasoning primitive because I anticipated B2B reorder patterns — I added it after watching the same failure twice in the same afternoon. I didn’t separate cart state from session state as a design principle — I built it in after three pharmacists lost their carts in ten days.The channel didn’t give me a spec. It gave me a sequence of failures, one at a time, until the system fit.That’s fine. That’s how systems get built when real users are involved. The constraint is the curriculum.Architecture Notes is a new series documenting real decisions from building FundlyMart — not the theory, the actual calls made under actual constraints. Next: how FundlyMart tracks conversation state across a multi-turn order flow, and why a simple state machine turned out to be more reliable than giving the LLM full context and hoping it remembered where it was.I write about production LLM systems. Follow for more.I Designed a Commerce Bot. WhatsApp Redesigned It. was originally published in Towards AI on Medium, where people are continuing the conversation by highlighting and responding to this story.