{
  "id": 21268458,
  "title": "Building a WhatsApp AI assistant for Moroccan businesses (Darija) with Next.js, Supabase and Claude",
  "url": "https://urgent.news/2026/11/22/building-a-whatsapp-ai-assistant-for-moroccan-businesses-darija-with",
  "topic": "ai",
  "section": "AI",
  "published": "2026-11-22T19:10:04.000Z",
  "source": {
    "name": "Dev.to",
    "slug": "dev-to",
    "url": "https://dev.to/lamaizi_hajar_b310d8837b4/building-a-whatsapp-ai-assistant-for-moroccan-businesses-darija-with-nextjs-supabase-and-claude-3p7o"
  },
  "original_language": "en",
  "account": "In Morocco, the majority of small businesses handle customer orders through WhatsApp. The owner must read every message, repeat the menu, and risk missing messages outside of regular business hours. To address this issue, the reporter built an AI assistant that answers customer inquiries in Moroccan Darija, French, or Arabic.\n\nThe assistant is designed to only provide information from the business's actual menu, prices, and hours, without inventing any dishes. The owner is notified when a customer has placed an order or requires a human's assistance. The entire system uses a single codebase for multiple merchants, ensuring that no data is mixed.\n\nThe architecture of the assistant relies on routing by phone_number_id. WhatsApp Cloud API sends every message to a single webhook, which identifies the merchant (tenant) based on the phone number ID of the receiving number. Isolation is achieved using Supabase Postgres with Row Level Security, ensuring that merchants can only access their own data.\n\nToken security is maintained by encrypting each merchant's WhatsApp token using AES-256-GCM in a table with no public policy. The webhook undergoes strict safety measures, including an HMAC signature check, immediate 200 response, background processing, and a table to handle duplicate message IDs. Monthly conversation limits are set per plan, and if the limit is reached, the customer receives a fixed message without any LLM calls, capping the cost.\n\nClaude Haiku is used as the LLM, with a system prompt built from the merchant's catalog, hours, and information. Special tags in the reply trigger order or human-handoff alerts to the owner. One surprising discovery was the 24-hour rule, where WhatsApp only delivers free-form messages within 24 hours of the customer's last message. Outside this window, an approved template is required for alerts.\n\nThe assistant also addresses the token expiry issue, as Meta's test token lasts approximately 24 hours. Detection of expired tokens is implemented to inform merchants of the necessary steps. Delivery is asynchronous, meaning the API can accept a message and handle the response later, with the webhook statuses events providing the actual reason for the delay.\n\nStructured editing is preferred over free text, as merchants do not want to write prompts. The dashboard takes product rows, opening hours, and delivery information and converts them into text that the model can understand, without losing any critical details. However, the story does not cover subscription payments, Meta's Embedded Signup for easy onboarding, voice-message transcription, or approved message templates for out-of-window alerts.\n\nThe reporter has packaged the entire project (Next.js 15, TypeScript, Supabase, Tailwind v4, tests, and installation/.env/usage guides) as a paid source-code product, targeting developers and agencies who wish to offer this solution to their clients: https://hajarlmz.gumroad.com/l/nlgxr. The dashboard and guides are currently in French, and the reporter welcomes questions and feedback in the comments.",
  "summary": "Most small businesses in Morocco take orders on WhatsApp. The owner reads every message, types the menu again and again, and misses messages at night. I wanted to see how far a small, cheap AI assistant could go for them, so I built one that answers in Moroccan Darija, French or Arabic. The problem Customers write in Darija (often in Latin letters), French, or a mix of both. Answers must come…",
  "key_points": [
    "AI assistant answers customer inquiries in Moroccan Darija, French, or Arabic.",
    "System uses single codebase for multiple merchants, isolating data via Supabase Postgres.",
    "Reporter sells packaged Next.js, TypeScript, Supabase solution for developers and agencies."
  ],
  "editors_take": null,
  "illustration": null,
  "coverage": {
    "outlets": 1,
    "also_reported_by": []
  },
  "ai_generated": true,
  "disclaimer": "Summaries, key points and the editor’s take are written by software from other outlets’ reporting and may contain errors — always check the linked original."
}