# Multi-Language AI Agent Setup Guide

### 🎯 **Objective**

This guide explains how to build a **multilingual AI agent system** by separating each language into its own dedicated agent.\
This ensures accurate responses, prevents mixed-language outputs, and provides a smooth experience for users communicating in different languages.

### 🧭 Overview

The **Greeting Agent** is the first interaction point for users.\
Its purpose is to **greet the user**, **detect the language**, and **route the conversation** to the correct language-specific agent (for example, English Agent or Thai Agent).

This ensures a seamless multilingual experience without mixing responses between languages.

### 💬 Example Prompt

```
You are an agent — a multilingual greeting assistant. 
Your role is to warmly welcome users and identify the language they are using.

Follow these steps:
1. Greet the user politely and ask how you may assist them.  
2. Detect the language of the user's response accurately.  
3. Based on the detected language, transfer the conversation seamlessly to the respective specialized agent who can assist further in that language.  

Rules:
- Always be friendly, professional, and concise.  
- If language detection is uncertain, politely ask the user to confirm their preferred language before transferring.  
- Do not attempt to answer complex or topic-specific queries yourself; always route to the specialized agent responsible for that language.  
- Maintain user privacy at all times and never share personal information.  
- Keep interactions short, clear, and helpful.  

```

### Example Agent Flow

<figure><img src="https://420146782-files.gitbook.io/~/files/v0/b/gitbook-x-prod.appspot.com/o/spaces%2FqqwHJh6YA4uvzfFRLnoR%2Fuploads%2FWTDKJ6II0Fl4H71ilAUp%2FScreenshot%202568-10-22%20at%2012.40.03%E2%80%AFPM.png?alt=media&#x26;token=c6961be8-cc64-4ce6-b2ed-39ca51d08110" alt=""><figcaption></figcaption></figure>

### ⚙️ How to Implement in Kai Builder

#### **Step 1: Create a New Agent**

1. Go to your **Kai Builder dashboard**.
2. Click **“Create New Agent”** → select **Conversation Agent**.
3. Name it **Greeting Agent (Language Detector)**.
4. Paste the **example prompt** (above) into the **Instructions** field.

***

#### **Step 2: Add Language-Based Transitions**

Create separate transitions to route users based on detected language.

**Example Transitions:**

| Transition Name           | Condition                           | Next Agent                                                                         |
| ------------------------- | ----------------------------------- | ---------------------------------------------------------------------------------- |
| Transfer to English Agent | If user message detected in English | English CS Agent                                                                   |
| Transfer to Thai Agent    | If user message detected in Thai    | Thai CS Agent                                                                      |
| Ask for Confirmation      | If language uncertain               | Stay in Greeting Agent and ask “Could you please confirm your preferred language?” |
|                           |                                     |                                                                                    |

#### **Step 3: Set Up the Language-Specific Agents**

1. Create one **Conversation Agent** for each language (e.g., English Agent, Thai Agent, Japanese Agent).
2. Inside each, define:
   * Language-specific instructions (respond only in that language)
   * Tone and style appropriate to local culture
   * Connection to language-specific FAQ or knowledge base

**Example Rule for English Agent:**

```
You are an English-language customer assistant. 
Respond 100% in English and never switch languages.
```

**Example Rule for Thai Agent:**

```
คุณเป็นเจ้าหน้าที่บริการลูกค้าภาษาไทย ตอบกลับเป็นภาษาไทยเท่านั้น
```

***

#### **Step 4: Add Shared Agents for Cancellations or Escalations**

After each language agent, you can route special intents (like **refunds**, **account issues**, or **human escalation**) to shared agents:

* **Cancellation Agent**
* **Human Agent**

This ensures a unified escalation experience regardless of the user’s language.

***

#### **Step 5: Test the Flow**

1. Open the test console in Kai Builder.
2. Type in both **English** and **Thai** messages to confirm routing works correctly.
3. Check that:
   * English messages trigger the **English Agent**.
   * Thai messages trigger the **Thai Agent**.
   * Uncertain language prompts a polite confirmation message.

***

### 🧠 Best Practices

* Keep each agent **language-isolated** — do not mix bilingual replies.
* Add **strict language rules** inside each agent to avoid confusion.
* Maintain separate **FAQ or knowledge base** per language for higher accuracy.
* Use **short greetings** and transfer quickly — the Greeting Agent should not handle support queries.
* Monitor routing analytics regularly to refine detection accuracy.
