How I Built a WhatsApp Bot That Closes Sales 24/7, Without AI Agents

MM

Muchiri Mwangi

AI Automation Specialist

11 min read
How I Built a WhatsApp Bot That Closes Sales 24/7, Without AI Agents

Most small e-commerce businesses in Kenya lose sales the moment the store owner goes offline. A customer sends a message at 10 PM asking about sneakers, gets no reply, and buys from a competitor by morning. I built a WhatsApp automation system for BeiFity.com that handles product search, size selection, cart management, and the full checkout flow, entirely through WhatsApp, no AI required, no customer left hanging.

Why WhatsApp, and Why Automation?

WhatsApp is where Kenyan customers actually are. Not email. Not a fancy website live chat widget. WhatsApp. The problem is that running a WhatsApp storefront manually is exhausting, every inquiry needs a human to respond, share a product image, confirm sizes, capture delivery details, and follow up on payment. Multiply that by 50 customers a day and your store manager is buried. The solution isn't hiring more people. It's building a system that handles the entire buying journey programmatically, so a customer can go from "I want sneakers" to "order confirmed" without a human lifting a finger.

What the System Does (The Full Flow)

Before diving into the technical side, here's what a customer actually experiences. A customer messages BeiFity.com on WhatsApp. The bot immediately responds, understands what they're looking for, and sends back a product card, complete with an image, price in KES, and a direct product link. The customer picks a quantity (1 item, 2 items, 3 items, presented as quick-reply buttons), selects a color, then gets asked for their shoe size from available options (40, 41, 42, 43, 44). The moment they reply with their size, the bot confirms: "Added 1x Naked Wolfe Sneakers (Black, 43), KES 3,100" and shows them their cart with options to add more or checkout. That entire flow — product discovery to cart to delivery details — happens automatically, even at 2 AM.

The Architecture: No AI, Pure Logic

This is the part most people overthink. You do not need a language model to build a powerful WhatsApp commerce bot. What you need is a well-designed state machine — a system that tracks exactly where each customer is in the conversation and responds accordingly. When a message comes in, the system first checks: what step is this customer on? The response is determined entirely by that state, not by trying to interpret free-form text in complex ways.

Session State Management

Every customer has a session stored server-side, keyed to their WhatsApp number. The session tracks their current step in the flow (browsing, size selection, cart review, checkout), their cart contents, and any data collected so far such as county, town, and delivery location. When a message arrives, the system reads the session, processes the input, updates the state, and fires back the appropriate response — all in under a second.

Webhook + WhatsApp Business API

The system runs on the WhatsApp Business API via a provider like Twilio or the official Meta Cloud API. Every incoming message hits a webhook endpoint. That endpoint reads the session, processes the input, updates the state, and sends back the appropriate response.

Product Catalog as Structured Data

Products are stored with all their attributes: name, price, image URL, available sizes, available colors, and a product page URL. When a customer's query matches a product, the system pulls that data and formats it into a WhatsApp message with an image attachment and interactive list for size and quantity selection.

Quick Replies and List Messages

Instead of asking customers to type freeform answers, the bot uses WhatsApp's native interactive message types. Quantity selection becomes three buttons: 1 item, 2 items, 3 items. Size selection is a list message showing only the sizes actually in stock. This removes friction and eliminates misunderstandings — no one types "fourty three" when they can just tap "43."

The Checkout Flow in Detail

The checkout sequence is where most WhatsApp bots fall apart. They ask for everything in one message and customers don't know what format to use, or they skip a field, or they send their location as a pin instead of text. The approach here is sequential — one question at a time.

  • Step 1/4 — County: The bot asks for the customer's county and validates it against a list of Kenyan counties, re-prompting if it doesn't match.
  • Step 2/4 — Town: Once county is confirmed, it asks for the specific town within that county.
  • Step 3/4 — Specific Location: Street, estate, or landmark — the customer types this freely.
  • Step 4/4 — Phone Number: Collected separately from their WhatsApp number in case they want delivery updates on a different line.

After step 4, the bot sends a full order summary — items, quantities, subtotal, delivery address — and asks for confirmation before the order is written to the database.

Handling Edge Cases

A rule-based bot lives or dies by how well it handles unexpected inputs. A few patterns that made this system robust:

  • Unrecognized input at a structured step: The bot re-sends the options with a gentle prompt rather than crashing or going silent.
  • Restarting the flow: If a customer sends a greeting keyword like "hi" or "menu" at any point, the system resets their session and starts fresh.
  • Cart modification: After viewing their cart, customers can tap "Add More" to continue browsing without losing what's already in the cart.
  • Out-of-scope inquiries: Unusual complaints or wholesale queries get a polite hold message and are logged for human follow-up.

The Business Impact

No customer inquiry goes unanswered regardless of time of day. The store manager stopped spending hours on repetitive product questions and redirected that time toward sourcing and fulfillment. Order capture became more accurate because the bot collects delivery details in a structured way — fewer missing fields and address errors than when humans were taking orders manually. Closing rates improved specifically because the bot keeps customers engaged at the moment of intent. A customer who asks about sneakers at 11 PM gets an immediate product card, not a reply 12 hours later when they've already moved on. Striking while the iron is hot — automatically — is the single biggest conversion lever here.

Tools and Stack

WhatsApp Business API

Either via Meta's Cloud API directly or through a BSP (Business Solution Provider). For businesses just starting out, Twilio or 360dialog are reliable entry points with solid documentation.

Node.js or Python Backend

The webhook handler can be built in either. A lightweight Express server in Node or a Flask app in Python is more than enough. The logic is simple; the infrastructure doesn't need to be heavy.

Redis or a Database for Session State

Redis works well for session management because it's fast and you can set automatic expiry on sessions. A simple Postgres table also works fine at smaller volumes.

A Product Database

Even a well-structured Google Sheet connected via API works at the start. The key is that product data — name, price, image URL, sizes, colors — is queryable programmatically.

The bot doesn't sleep, doesn't get tired, and never forgets to ask for the delivery address. That alone recovered more lost sales than any marketing campaign we'd run before.

What This Approach Can't Do (And That's Okay)

This is a rule-based system. It handles defined flows extremely well. It does not handle open-ended questions like "what's the best sneaker for running on grass" or nuanced complaints that require judgment. For BeiFity.com, that's an acceptable tradeoff — the vast majority of customer interactions are transactional (find product, pick size, buy), and the bot handles all of those flawlessly. The 10% of conversations that require genuine human judgment get flagged and handed off. The store manager now only deals with conversations that actually need them.

Key takeaway

You don't need AI to build a WhatsApp system that sells. You need a clear understanding of your customer's buying journey, a state machine that guides them through it step by step, and WhatsApp's native interactive message types to make the experience feel natural. BeiFity.com now captures orders around the clock, responds to every customer instantly, and has a cleaner order pipeline than before, all without a single AI model in the stack. Build the flow first. Add intelligence later if you actually need it.

MM

Written by

Muchiri Mwangi

I build AI automation and workflow systems for businesses, with a focus on practical results over hype.

More about me

Keep reading