We live in a global world, and that means your customers are active in more than one language. It is very easy to build bots in multiple languages in Chatlayer.
When a bot is created, a user has to choose a primary language. This is the language in which the bot will be developed. In other words, this language is the language that is shown in the 'Bot dialogs' module where you configure all the messages, button labels, content, links and logic of the bot.
When a bot is created, the user also has the option to choose (multiple) secondary languages. To configure the copy-writing for these languages, you can use the Translations module.
The structure and logic of the bot is defined once and then reused for all languages. That means that you build the bot once, and then just translate it. If you add functionality or conversational flows, they will automatically be added to the secondary languages as well. This makes sure your bot remains in sync and offers a consistent experience for all languages.
When you have created a multi-lingual bot, you will notice that in the NLP module, you can switch the active language in menu bar at the top, upper right. When you switch language, the color of the interface will change.
Things to note when managing NLP models in more than one language
If you add an intent, the intent will automatically be added to all other languages as well. You can add intents in the primary as well as in the secondary languages.
If you add an expression, the expression is language dependent and will only be added to the active language model.
As language models are independent of each other, you have to train and publish them separately. That means that if you make changes to two languages, you will have to train and publish them both.
The number of expressions that is displayed under the 'Intents' block is the number of expression for the active language.
The use the correct language NLP model, English or Dutch in our example, and to send the bot response messages in the user's preferred language we need to request their language. Chatlayer supports two helper plugins for this:
Language action to store the user's preferred language in Chatlayer
Locale action to check if the user;s Facebook preferred language is supported by the bot
To save the users preferred language in Chatlayer:
Add an input validation 'Ask user language'
Define the type as 'language' and combine user text input and buttons by using a button template. The language type parser will parse and validate the language from any user input. Find more about the language type parser and related languages codes and supported synonyms here. Save the input in a variable 'userLang'. Use this variable name in the button variable definition and as the variable saved in the input validation.
Add an action 'Save user language'
Add the Language action to this bot dialog. This action will retrieve the value from the defined variable and will try to store this value as the users preferred language. Define a go to when an error occurs or when the value was successfully saved. If the users preferred language is successfully saved the bot will response in this language.
Use the Locale action to check if the user his Facebook profile language is supported by the bot.
If the language is supported save this Facebook language by using 'locale' as variable in the Save language plugin
If not, start the 'Ask user language' flow