Giving a support agent a second language
Your support agent works in English. Your customers don't always write in it. How to add detection and translation around the agent, in about thirty lines, without changing the agent.
By FluentC2 min read
You built a support agent that answers questions from your help center. It's good. It's in English. Then a customer writes in Portuguese.
You have two options: rework the agent so it handles every language itself, or leave the agent alone and put translation on either side of it. The second one is usually simpler, and it keeps the agent's behaviour the same for everyone.
The shape
customer (any language)
│
▼
detect language ──► translate to English ──► your agent (English)
│
customer (their language) ◄── translate reply ◄────┘
The agent only ever sees English. The customer only ever sees their own language. Everything in between is two translation calls.
Step 1: detect the language
You can skip this if you already know the customer's language from their profile or locale. If you don't, FluentC can tell you. The detect language endpoint returns a code and a confidence:
import os
import requests
API = "https://api.fluentc.ai"
HEADERS = {"Authorization": os.environ["FLUENTC_KEY"]}
def detect(text):
res = requests.post(
f"{API}/ai_agent/checklanguage",
headers=HEADERS,
json={"input": text, "input_format": "text"},
timeout=15,
)
res.raise_for_status()
body = res.json()
return body["detected_language"], body["confidence"]
Decide what to do when the confidence is low. A short message such as "ok" doesn't tell you much. A reasonable rule is to keep using the language of the previous message, or the one on the customer's account.
Step 2: translate in and out
One function does both directions. In a real-time call the translation comes back in the response:
def translate(text, target, source=None):
body = {
"input": text,
"input_format": "text",
"target_language": target,
"mode": "real-time",
}
if source:
body["source_language"] = source
res = requests.post(
f"{API}/ai_agent/translate", headers=HEADERS, json=body, timeout=30
)
res.raise_for_status()
return res.json()["translation"]
Pass source_language when you know it. It avoids guesses on very short messages.
Step 3: wrap the agent
def answer(message, customer_language=None):
if customer_language is None:
customer_language, confidence = detect(message)
if customer_language == "en":
return agent.reply(message) # your existing agent, unchanged
english = translate(message, "en", source=customer_language)
reply = agent.reply(english)
return translate(reply, customer_language, source="en")
That's the whole integration. agent.reply is whatever you already have.
Things worth knowing
- Use real-time mode. Someone is waiting. Real-time needs the Real-time plan; see plans and modes.
- Repeated answers are consistent. If your agent often says the same thing, such as a returns policy or a delivery window, those sentences go out in the customer's language the same way every time, because FluentC returns the stored translation for text it has translated before. See ten agents, one translation.
- Reply in the language they wrote in. If a customer switches languages mid-conversation, detect again rather than assuming.
- Language codes are lowercase and two or three letters.
pt, notpt-BR. - Keep a person in the loop where it matters. For anything sensitive, such as refunds or account closure, have the agent hand over to a person who can read the original message too. Translation is a bridge, not a replacement for judgment.
Doing it without code
If your support flow runs in n8n, the same steps are nodes: a FluentC Detect node, a Translate node, your agent, then a second Translate node. The n8n guide covers both operations and lists this multilingual chatbot pattern. If your agent is built on tool calling, you can give it a translate_text tool and let it decide when to use it; see function calling.
Try it
Get an API key and paste the three functions above. You can have a second language running in an afternoon.