Now live — start freeGet started

Building a Multilingual AI Agent for FR / AR / EN Markets

A practical guide to building WhatsApp AI agents that handle French, Arabic, and English — including the code-switching reality of North African communication.

Cover Image for Building a Multilingual AI Agent for FR / AR / EN Markets

Building an AI agent for a North African business isn't just about adding another language to a list. It's about understanding that your customers don't stay in one language — they flow between them mid-sentence, mid-conversation, and sometimes mid-word. A multilingual agent that treats each language as a separate mode will frustrate these users. One built with code-switching in mind will feel natural.

Here's how to build an agent that works for FR/AR/EN markets, based on the realities of Moroccan communication.

Understanding the Language Reality

In Morocco, language use follows rough patterns:

  • Darija (Moroccan Arabic) — the language of daily life, family, and informal commerce. Written in Arabic script or romanized (Franco-Arab), often mixed with French.
  • French — the language of business, formal education, and urban commerce. Most educated Moroccans switch to French for technical or business topics.
  • Modern Standard Arabic (Fusha) — used in formal written contexts, some media. Less common in conversational WhatsApp messages.
  • English — growing among younger demographics and tech-oriented users.

A WhatsApp conversation from a real Moroccan customer might look like: "Salam, 3afak wach kayn delivery pour Casablanca? Et c'est combien les frais?"

An agent that only handles full-sentence French will miss the "salam" and "wach kayn" and potentially misclassify the intent. One trained only on MSA will completely fail on Darija.

Detection Over Declaration

The first decision is: do you ask customers what language they prefer, or do you detect it?

Asking is tempting but adds friction. Most customers don't want to make a menu selection before getting help. Detection works better in practice.

A practical detection strategy:

  1. Script detection first: If the message contains Arabic-script characters, assume the customer is comfortable with Arabic/Darija. Respond in Darija.
  2. French keyword detection: Common French function words ("je", "vous", "est-ce que", "combien", "merci") suggest French as the preferred register.
  3. English fallback: If neither Arabic script nor French keywords are detected, default to English or French depending on your primary market.
  4. Conversation persistence: Once a language is detected, keep it for the entire conversation unless the customer explicitly switches.

This isn't perfect, but it's good enough for 80% of cases and doesn't require sophisticated NLP.

Structuring Your Prompt for Multilingual Behavior

If you're building on top of a language model (Claude, GPT, Gemini), the system prompt is where multilingual behavior is established. A system prompt for a Moroccan business agent should include:

You are a customer support agent for [Business Name], a Moroccan business
that sells [products/services].

Language behavior:
- Detect the language of the customer's message and respond in the same language.
- If the customer writes in Moroccan Darija (including romanized/Franco-Arab),
  respond in simple, natural Darija. Use Arabic script, not romanized.
- If the customer writes in French, respond in French.
- If the customer writes in English, respond in English.
- If the message mixes languages, respond in the language that appears dominant.
- Never ask the customer to choose a language.

Tone: Friendly, warm, direct. Use "3afak" (please) and "shukran" (thank you)
in Darija responses. Use "s'il vous plaît" and "merci" in French.

The explicit language instructions prevent the model from defaulting to whatever language is most common in its training data.

Handling Darija-Specific Challenges

Several challenges arise specifically with Darija:

Romanized Darija ("Franco-Arab"): Messages like "wach kayn delivery?" need to be recognized as Darija even though they're in Latin script. Include examples in your system prompt: "Romanized Darija examples include: wach, kayn, kifach, bghit, 3afak, shhal, fin."

Number substitutions: Moroccan Arabic text often uses numbers for sounds not in the Latin alphabet: "3" for ع, "7" for ح, "9" for ق. Your agent should recognize "3afak" as "عفاك" (please) and "9rib" as "قريب" (soon/nearby).

Vocabulary gaps: Some product categories have no standard Darija term and are always referred to in French ("livraison" not "تسليم" for delivery, "commande" not "طلبية" for order). Train your agent to handle these French terms even in otherwise Darija conversations.

Practical Architecture for a WhatsApp Agent

A production multilingual WhatsApp agent needs:

  1. Webhook handler — receives incoming messages from WhatsApp Cloud API
  2. Language detector — simple script/keyword detection to set conversation language
  3. Context store — remembers conversation history and language preference per customer
  4. LLM call — sends system prompt + conversation history to the language model
  5. Response formatter — formats the LLM output into WhatsApp message format
  6. Fallback handler — routes to human agent when confidence is low

The most important component is the context store. Without it, each message is treated independently and the agent can't maintain coherent conversations or language consistency.

What to Automate vs What to Hand Off

Multilingual agents work best on well-scoped tasks:

  • Product availability and pricing questions
  • Order status lookups
  • Business hours and location
  • Shipping time and cost estimation
  • Basic FAQ (return policy, payment methods)

They struggle with:

  • Complaints requiring empathy and negotiation
  • Complex custom orders
  • Technical support for physical products
  • Anything requiring judgment about specific situations

Build clear escalation paths. When the agent can't help, it should say so immediately and connect to a human — not continue generating generic responses. Customers forgive an AI that says "let me get a real person for this" much more than one that answers confidently with wrong information.

AidGens builds these multilingual agent flows for Moroccan businesses. If you're curious what a setup looks like for your specific use case, reach out by WhatsApp or email.