Language Detection Flow
DRUID 5.3 and higher is capable of detecting any language change in the conversation prior triggering the Intent not found flow, covering the cases when the user types something in another language than the default language of the bot. It does not include the cases when the user changes the conversation language using the snippet's Language option.
The Language Detection flow enables bot authors to address situations when DRUID detects a language change in the conversation.
Language Detection Flow - Solution Template
To simply flow authoring when bot authors want to handle the situations when language change is detected within the conversation, DRUID provides you with a built-in solution template, Language detection flow, which addresses extensive use cases for language detection.
Go to the Solutions Library, search for the Language detection flow solution template, import it and enable language detection on the bot, following the instructions described in Enabling language detection on the bot.
You can update the Language detection flowsolution template or you can define your own flow for handling the cases when language change is detected in the conversation.
How the Language change flow is working
For each processing of a user says (not only for intent recognition, but also for input mapping), first the origin from where the language change is triggered is checked.
If condition [[ChatUser]].DetectedLanguage == null is met, then the user has changed the language from the chat snippet Language option. The bot will continue the conversation in the new language (the Language Changed flow is not triggered).
If the user did not change the language from the chat snippet, then automatic-language-detection flow step will be executed.
If condition ![[ChatUser]].DetectedLanguage.IsAvailable is met (that is, the detected language is not defined on the bot), the chatbot realizes that the user is typing in another language, captures this language in [[ChatUser]].DetectedLanguage.FriendlyName and tells the user that it doesn’t know that particular language, but to choose from one of the languages it knows, by presenting a hero card with all the available languages on the bot.
Example – bot trained in Romanian and other languages, but NOT English
Conversation Language: Romanian
User types something in English
Chatbot: Observ că ai scris în limba Engleză. Din păcate nu cunosc această limbă în prezent. Pentru a continua, te rog să scrii ceea ce dorești în limba Română, sau alternativ, îmi poți scrie în… limba 1, limba 2 și limba 3.
The user receives a hero card with the languages available on the bot.
User chooses language.
The bot continues the conversation in the language chosen by the user and sets [[ChatUser]].Language = [[ChatUser]].DetectedLanguage.Code.
If the chatbot realizes that the user is typing in another language, captures this language in [[ChatUser]].DetectedLanguage.FriendlyName and asks the user if he wants to continue in that language by either using an entity with a Boolean field or a local variable @yesno.
Example – bot trained in Romanian and English
Conversation Language: Romanian
User types something in English
Chatbot: Observ că ai scris în limba Engleză. Dorești să continuam în această limbă?
User: yes/da
Chatbot: Sure, what can I do for you? (enters idle mode)
User: no/nu
If the user does not accept to change the language into the language detected by the model, then the user will not be prompted anymore for the following 15 minutes for that language. The user will, however, be asked if he/she wants to change into other languages, if detected by the model.
Enabling language detection on the bot
To enable language detection, on the bot Details make the following settings:
- Click the Dialogue management section header and select the Language Changed flow to be triggered when language change is detected in the conversation.
- Tap on Language detection. The Threshold field becomes editable.
- In the Threshold field, enter a value (we recommend setting the threshold to 90). Whenever the threshold is reached, the selected Language Changed Flow will be triggered.
- Save the bot.
- [[ChatUser]].DetectedLanguage is different than the [[ChatUser]].Language.
- [[ChatUser]].DetectedLanguage.Score is higher than the value of the NLP.Language.Detection.Threshold parameter.
- The last language change detection was more than 15 minutes ago. The last language change detection for the same new language identified, was more than 15 mins ago (E.g., the current language is German and bot detects English; the user doesn’t want to switch to English because he/she only used a universal word like “laptop” or “mouse”; therefore, next time the bot will identify a language change intent to English and current language is still German, it will not trigger the Language Changed special flow again).
Debugging why the Language changed flow was not triggered
In DRUID 5.11 and higher you can test user says to see the Predicted language and the Confidence (the score of the predicted language). This is particularly useful for debugging purposes to check why language detection was not done on user says or why the Language changed flow was not triggered.
If the Confidence of the predicted language is below the language detection threshold (which by default is 90), the Language Changed Flow will not be triggered.