In this section, we will see how to teach your bot to manage several languages.
In certain countries, you may have multiple languages to handle.
And you can't know in advance wich language your user will prefer.
Allowing the user to seamlessly select his preferred language is a must have feature to achieve this goal.
Multilanguage support is a native feature of Smartly.ai
Want to see how it works? Try the example below 😀👇
Availability of this feature
Please note that this feature is currently only available for the Webchat and Messenger channels.
Say that you already have a great bot working in english anf that you now want to offer new language options to your users.
The steps below will show you to do that.
Click on the Add New Language button
Then select the new language you want to add
You now have two dialog flows, one per language.
The cool thing is some elements have been duplicated to make the translation process easier for you:
- the structure of the dialog flow
- the node.js code
- the rich messages
- the bot answers
- the titles of each objects in the dialog flow
Now go ahead and translate:
- the intents
- the entities (if any)
- the bot answers
Which language is the reference while duplicating?
No matter how much translations you have for your bots, each new dialog flow will be created based on the original language selected at bot creation.
UX wise, you can offer the language selection option at start
For each language preference you will need the following elements in your dialog flow
- A user intent: to detect the user choice
- An answer box: to give a feedback confirming the user choice
It can be empty if you prefer is a rich message
It is recommanded to give this confirmation in the newly set language
- A rich message box: to give a feedback confirming the user choice in a richer way
- A node.js box: to store the information of the user preferred language
And here is the code used to store the preferred language of the user
user_data.preferred_language = 'en-gb';
Where can I find the locale name to store as the preferred language?
The locale can be easily found in your dialog flows name as shown in the picture below.
If you are working on a single bot then there is no question, leave it there.
If you are working in a multi bot architecture, then place your language switching code in the masterbot.
Once you have stored the user preferred language, the next messages will be always processed in the newly set language regardless of the default language set in the bot.
Of course the user can change his mind and change his preffered language again, the method is exactly the same!
Updated about 1 year ago