Language Switching Logic in Multilingual Agent (Ge...
# support
h
I’ve developed a multilingual agent that supports German (default), English, and French. The current setup works like this: - If the caller speaks English or French, the agent asks: “Would you like to switch?” - After confirmation, the agent switches to that language. This is working fine, but I want to refine the logic: ### Issue Right now, the agent asks for a language switch even if the caller says just one word in English or French (e.g., “Alright”, “Yeah”). I only want the switch prompt to trigger when the caller speaks 3 or more words in English or French. ### Example - Caller says: “Alright” → No switch prompt - Caller says: “Yes, I would like that” → Switch prompt appears Additionally, there’s a small complication: - When the caller says “Ja” (German for “Yes”), the transcriber sometimes interprets it as “Yeah” (English). - This incorrectly triggers the switch prompt, even though the caller is still speaking German. ### What I’ve Tried I added to the prompt: > “Only switch when the utterance contains more than 3 words.” But the agent still asks for a switch when single words like “Yeah” are detected. --- ### Question How can I enforce this rule so that: 1. The agent only asks for a switch when the utterance has 3+ words in English or French. 2. Prevent false triggers when German words like “Ja” are transcribed as English equivalents. Has anyone implemented a similar condition in Vapi prompts or workflows? Any guidance or best practices would be greatly appreciated
@User @Vapi @Vapi Support Bot
v
To enforce the "3+ words" rule, add a workflow condition that checks the word count before triggering the language switch prompt. For example, in your workflow node, use a custom condition like:
Copy code
js
condition: preferred_language == 'english' && user_utterance.split(' ').length >= 3
This ensures the switch prompt only appears when the utterance in English (or French) has 3 or more words. For the "Ja"/"Yeah" issue, consider adding a check to ignore single-word utterances or maintain a list of common false positives to filter out in your logic. For more details, see the [multilingual agent guide](https://docs.vapi.ai/assistants/examples/multilingual-agent). Source: - [Multilingual support agent guide](https://docs.vapi.ai/assistants/examples/multilingual-agent)
h
condition: preferred_language == 'english' && user_utterance.split(' ').length >= 3 I just have to add this? I am utilizing Vapi Dashboard for agent development
v
To enforce the "3+ words" rule, add a workflow node condition that checks the word count before prompting for a language switch. For example, in your workflow logic:
Copy code
js
if (detected_language !== 'german' && utterance.split(' ').length >= 3) {
  // Trigger language switch prompt
}
Additionally, add "Ja" to your transcriber's custom vocabulary to reduce false positives. This approach ensures the switch prompt only appears for longer utterances and helps prevent "Ja" from being misclassified as "Yeah" in English. Sources: - [Multilingual Agent Example](https://docs.vapi.ai/assistants/examples/multilingual-agent) - [Multilingual Configuration Guide](https://docs.vapi.ai/customization/multilingual)
h
I am using vapi dashboard, how to add in the dashboard? if (detected_language !== 'german' && utterance.split(' ').length >= 3) { // Trigger language switch prompt }