Building a multilingual bot with Tock
The Tock Studio interface allows you to translate and modulate a bot's responses according to the language but also the channel used.
Prerequisites
Tock provides a complete internationalization framework. It is enabled by default in Bot API mode (for example on the demo platform).
In Integrated Bot mode (see the developer manual), internationalization is disabled by default. To enable it, it is then necessary to configure the platform at startup:
- Either via the bot startup code (developer):
Translator.enabled = true
- Or with a System property (administrator) by passing
-Dtock_i18n_enabled=true
at JVM startup
Enable multiple languages for a bot
It is possible to add and manage active languages for a bot in the NLU Applications section (in Tock Studio). See The Settings menu.
At any time in Tock Studio, it is possible to change the language selected in the banner at the top of the page, in particular to communicate with a bot in the Test the bot interface. See General interface.
User language and locale
When possible, the user's locale (language/region) is imported from their account's.
For example, if a Messenger user's account is set to French, French will be automatically selected by Tock.
If there is no locale specified, Tock's default locale is used.
A developer can change the user's locale in the bot's code itself:
userPreferences.locale = Locale.FRENCH
Finally, the default locale can be changed by a platform administrator, by passing the System property
-Dtock_default_locale=fr
when starting the JVM.
Translate and vary the bot's answers
In Tock Studio, the Stories & Answers > Answers section allows you to manage the labels of the bot's answers.
See The Stories & Answers menu.
Each label has a default value for each language of the bot.
It is possible to design and configure different variants:
- Depending on the language
- Depending on the channel / connector
For example, some channels require specific labels, either because the channel owner requires it (on Alexa, the use of the formal "vous" is required), or because the user experience differs from other channels (for example in voice, we will avoid sentences that are too long).
- Randomly (so that the bot does not always answer the same thing)
Massively translate models and responses
Features are being studied to allow the more or less automated translation of many user sentences (corpus / conversational model) and responses (labels / i18n). To be continued...
For the moment, to consider a mass translation, we can for example:
- Export the data in JSON or CSV with Tock Studio
- Translate the sentences/responses outside of Tock (SaaS API, agency...)
- Import the translations with Tock Studio
Note: at the time of import, only the labels marked validated are taken into account.
Develop with internationalization
The Tock developer manual gives more details on the development of multilingual bots.