Multilanguage

In this section, we will see how to teach your bot to manage several languages.

Overview and demo

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.

1. Add new languages

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.

2. Offer language switching

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

  1. A user intent: to detect the user choice
  2. 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
  3. A rich message box: to give a feedback confirming the user choice in a richer way
  4. A node.js box: to store the information of the user preferred language
Switching Intent from french to englishSwitching Intent from french to english

Switching Intent from french to english

Confirmation messageConfirmation message

Confirmation message

Node.js codeNode.js code

Node.js code

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.

Where should I handle language switching?

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.

What happens behind the scene?

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!