Skip to main content

Support for other languages

This article is part of a tutorial about creating a multilingual bot.

  1. Basic principles
  2. Request routing
  3. Support for English
  4. Support for other languages (you are here)
  5. Channel deployment

In this section of the tutorial, we will create a bot in French which will constitute our multilingual bot. Create a new project, choosing French as the NLU language.

Intents

This bot in French will support exactly the same /hello and /book intents as supported by the bot in English, differing only in the language of training phrases and questions used for slot filling.

Booking intent

Bot script

The code for the French bot will also be identical to the English one, the only exceptions lying in its configuration and the reply texts.

  • In the injector section of chatbot.yaml, replace the value of currentLanguage with the French ISO code instead of English:
injector:
currentLanguage: fr
  • In main.sc, translate the texts of all bot replies to French:
require: name/nameEn.sc
module = sys.zb-common

require: slotfilling/slotFilling.sc
module = sys.zb-common

require: routerClient.js

theme: /

state: Start
q!: $regex</start>
go!: /Hello

state: Hello
intent!: /hello
a: Bonjour ! Comment vous appelez-vous ?

state: Name
q: * $Name *
a: Enchanté, {{$parseTree._Name.name}} !
script:
$session.booking = $session.booking || {};
$session.booking.name = $parseTree._Name.name;
go!: /Book

state: Book
a: Indiquez le nombre de la chambre que vous voulez réserver.

state: Yes
intent: /book
a: Chambre numéro {{$parseTree._Room}} a été réservée.
script:
$session.booking = $session.booking || {};
$session.booking.room = $parseTree._Room;

state: NoMatch || noContext = true
event!: noMatch
if: isSameLanguage($context)
a: Désolé, je ne vous comprends pas.
else:
script: returnToRouter($context, $session.booking);
tip
No changes are required in routerClient.js — you may copy it as is.

Registration in the router

In the same way as before, deploy the created bot to any channel, copy its ID, and register it in the injector section in the router bot:

injector:
bots:
en: "250555190-booking_en-250555190-UNE-16011289698"
fr: "250555190-booking_fr-250555190-ydK-20938138709"

Other languages

The multilingual bot created according to the scheme described in this tutorial can easily support any number of other languages.

  1. Create a new project supporting the desired NLU language. Repeat the steps given in this section.
  2. After deploying the bot, add its ID to the injector configuration of the router bot.

In the last step of this tutorial, we will discuss how to deploy the multilingual bot and verify that the script works.