Skip to content

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 Settings > Applications menu (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 > Test 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, or because the user experience differs from other channels (for example, in voice, sentences that are too long are avoided)
  • Randomly (so that the bot does not always answer the same thing)

Massively translate models and responses

Tock can translate answers and sentences with a translation engine: the optional tock-deepl-translate and tock-translator-google modules, added to the Tock Studio backend (tock/bot_admin), provide one for DeepL and Google Translate. With a translation engine, the Answers screen translates the missing labels, and the sentence screens of Language Understanding translate the selected sentences into another locale.

Without a translation engine, to consider a mass translation, you can for example:

  1. Export the data in JSON or CSV with Tock Studio
  2. Translate the sentences/responses outside of Tock (SaaS API, agency...)
  3. 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.

Chat with Tock
×