How I Built a WhatsApp AI Sales Agent for a Moroccan E-Commerce Store
End-to-end walkthrough of building a WhatsApp AI sales agent using n8n + Claude API, designed for the Moroccan COD e-commerce market with Darija and French support.
The Problem: Why Moroccan E-Commerce Stores Lose Sales Outside Business Hours
In Morocco, 70%+ of online purchases happen through WhatsApp. Customers send a message, ask about a product, negotiate the price, and place a COD order — all within a chat. But here's the catch: most store owners can only respond during business hours. Messages that come in at 11 PM or during Friday prayer? They go unanswered. And unanswered messages mean lost sales.
The average Moroccan COD e-commerce store has a 35% return rate. A big chunk of those returns come from poorly qualified leads — customers who weren't asked the right questions before the order was confirmed.
I set out to build an AI-powered WhatsApp sales agent that could handle the entire sales funnel 24/7, in Darija and French.
Solution Architecture: n8n + Claude API + WhatsApp Business API
The architecture is surprisingly clean:
WhatsApp Business API (webhook)
→ n8n (workflow orchestrator)
→ Claude API (AI brain)
→ Product Catalog (JSON/API)
→ Order System (webhook)
→ WhatsApp (response)
Why n8n?
n8n is the backbone. It handles:
- Webhook reception from WhatsApp Business API
- Conversation state management via a simple key-value store
- Claude API calls with conversation context
- Product catalog lookups for recommendations
- Order creation when the customer is ready
Why Claude API?
Claude handles the nuance that rule-based chatbots can't:
- Understanding Darija mixed with French ("bghit dak le produit li f la photo")
- Natural conversation flow (not robotic menu trees)
- Intelligent product recommendations based on customer needs
- Polite objection handling and upselling
Handling Darija and French in the Same Conversation
This was the trickiest part. Moroccan customers freely mix Darija (Moroccan Arabic), French, and sometimes even Spanish in a single message. The system prompt I designed for Claude includes:
You are a friendly sales assistant for [Store Name].
You speak Darija (Moroccan Arabic written in Latin or Arabic script),
French, and English. Match the customer's language automatically.
Common Darija patterns:
- "bghit" = I want
- "ch7al" / "bch7al" = how much
- "wach kayn" = is there / do you have
- "safi" = okay/done
Always be warm, use "khouya/khti" naturally, and never be pushy.
Claude handles this remarkably well. It picks up on the language within the first message and responds accordingly.
The Workflow: Lead Qualification → Product Recommendation → Order Confirmation
The n8n workflow has 5 main stages:
Stage 1: Greeting & Intent Detection
When a new message arrives, Claude identifies the customer's intent: browsing, asking about a specific product, ready to buy, or asking about an existing order.
Stage 2: Product Recommendation
Based on the conversation, the workflow queries the product catalog and Claude recommends items with prices, available sizes, and colors.
Stage 3: Lead Qualification
Before confirming an order, the AI asks qualifying questions:
- Delivery city (for shipping cost calculation)
- Phone number confirmation
- Preferred delivery time
This step alone reduces return rates by qualifying out impulse buyers and fake numbers.
Stage 4: Order Confirmation
The AI summarizes the order, confirms the total with shipping, and asks for final confirmation. Only then does it create the order in the system.
Stage 5: Follow-up
24 hours before delivery, the system sends an automated confirmation message. This alone cuts "customer unavailable" returns by an estimated 20%.
Results and Projected ROI
For a typical Moroccan e-commerce store doing 50 orders/day:
| Metric | Before AI Agent | After AI Agent | |--------|----------------|----------------| | Response time | 2-4 hours | < 30 seconds | | After-hours sales | 0% | ~30% of total | | Lead qualification rate | ~40% | ~75% | | Projected return rate reduction | — | 15-25% |
The cost? About $50/month for n8n cloud + ~$30/month for Claude API usage. The ROI is massive.
What I'd Do Differently Next Time
- Voice messages: Many Moroccan customers send voice notes instead of text. I'd integrate Whisper API for voice-to-text transcription.
- Payment integration: Adding CashPlus or Barid Bank mobile payment would reduce COD dependency.
- Multi-store architecture: Build a SaaS layer so multiple stores can share the same infrastructure.
Want a WhatsApp AI agent for your business? Get a free AI audit.
Want more like this?
Get the free toolkit + occasional tips on React Native, Next.js, and AI.
No spam. Unsubscribe anytime.