I have tried to create a multilingual chatbot using N8n. Tried several models (OpenAI, Gemini 2.5 and Deepseek r1), but the output wasn’t perfect as expected. How can I create a multilingual chatbot? Should I use a specific model or a separate dictionary, or should I use something like translation api (Google,AWS or Azure)
Hmm you could add a switch node to use as a system prompt expression depending on the language someone chooses and instruct the LLM to continue from that point onwards in said language?
Incoming Message Flow: Trigger Node: Start with a Webhook or Chat Trigger node to capture user input.
Detect Language: Use a language detection API (e.g., Google Cloud Translation, LibreTranslate, or AWS Comprehend) to detect the user’s language.
Translation Layer (If Needed):
Translate to English: Use a translation API (Google, Azure, or AWS) to convert the message into English (if it’s not already).
Route to LLM: Send the translated text to the LLM (OpenAI GPT -4 or Gemini 1.5 Flash) for a balance between quality and latency.
AI Processing: Use n8n’s AI Agent node or HTTP Request node with the desired model.
For context-aware responses, use memory tools such as vector search or a context buffer (MemoryBufferWindow node).
Structure prompts carefully, e.g.:
System: You are a multilingual assistant.
User Input: ${translated_input}
Task: Provide a helpful response.
Translate Output (If Needed): If the original user language isn’t English, translate the LLM’s response back using the exact translation API.
Send Response: Output the translated response to the user via Telegram, Discord, webchat, etc.