Skip to content

Building a multilingual bot with Tock

The Tock Studio interface allows translating and customizing a bot’s answers based not only on the language, but also on the connector used.

Prerequisites

Tock provides a full internationalisation framework. It is enabled by default in Bot API mode (e.g. on the demo platform).

In the integrated bot mode (see the dev guide), internationalisation is disabled by default. To enable it, you must configure the platform at launch :

  • Either through the bot’s init code (developer side) :
      Translator.enabled = true
    
  • Or through a configuration value (administrator side), as the added property -Dtock_i18n_enabled=true at JVM launch, or as an environment variable export tock_i18n_enabled=true

Enabling multiple languages for a bot

It is possible to add and configure a bot’s active languages in the NLU Applications section (in Tock Studio) - see the Settings menu.

At any time in Tock Studio, it is possible to change the selected language in the banner at the top of the page. This is particularly useful when conversing with a bot in the Test the bot interface.

When possible, the user’s locale (language/region) is imported from their account.

For example, if a Messenger user’s account is set to French, French will be automatically selected by Tock.

If no locale is specified, Tock’s default locale is used.

A developer can change the user’s locale in the bot code itself:

userPreferences.locale = Locale.FRENCH

Finally, the default locale can be modified by a platform administrator, by passing the System property -Dtock_default_locale=en at JVM startup.

Translate and vary bot responses

In Tock Studio, the Stories & Answers > Answers section lets you manage the wording of bot answers. See The Stories & Answers menu.

Each label has a default value for each bot language. Different variants can be designed and configured:

  • language-dependent
  • Channel/connector-dependent

    For example, some channels require specific labels, either because the channel owner requires it (on Alexa, polite conversation is required), or because the user experience differs from other channels (for example in voice, avoid long sentences).

  • Randomly (so that the bot doesn’t always answer the same thing)

Mass translation of templates and responses

Functionalities are being considered to enable more or less automated translation of numerous user phrases (corpus / conversational model) and responses (labels / i18n). To be continued…

For the time being, if mass translation is required, you may for example:

  1. Export data as JSON or CSV with Tock Studio.
  2. Translate sentences/answers outside Tock (SaaS API, agency…)
  3. Import translations with Tock Studio.

Note: when importing, only wordings marked validated are taken into account.

Developing with internationalization

The Tock developer manual gives more details on developing multilingual bots.