Basic principles of multilingual bots
This article is part of a tutorial about creating a multilingual bot.
- Basic principles (you are here)
- Request routing
- Support for English
- Support for other languages
- Channel deployment
Monolingual bots
The concept for implementing multilingual bots is based on a Tovie Platform feature which allows switching the context from one bot to another by using special reply types: context-switch
and context-return
.
When receiving a request in a language they don’t understand, bots can use this feature to switch the context to the bot which supports this language.
In order to implement a multilingual bot, you will need to create separate projects for bots in different NLU languages, which will differ from one another in the following aspects:
- NLU language configuration in the project settings and
chatbot.yaml
. - Training phrases and patterns in Tovie NLP intents and entities.
- Bot reply texts.
Every other piece of content, such as the names for states and intents, business logic written in JavaScript, etc. — should be identical for every monolingual bot. Every bot should also implement context switching when receiving a request in an unknown language.
Bilingual bot diagram
Consider the structure of a bot which has to maintain communication in two languages, such as English and French:
- The client sends a
/start
request to activate the bot. The request is processed by the bot in the language selected as the main one (e.g. English). The interaction continues in English. - If the client sends a request in French, the bot switches the context to its French counterpart. The interaction continues in French.
- If the client then sends a request in English when talking to the bot in French, it returns the context back to the bot in English.
Multilingual bot diagram
context-switch
reply, and when to send context-return
. Switching the context too often without returning it can lead to bot stack overflow.To implement a bot which supports more than two languages, one more component must be added to the diagram: the router. The router bot acts as an intermediary between monolingual bots and serves only to detect the language of incoming requests and switch the context to the appropriate bot.
This is what the updated workflow looks like:
- The client sends a
/start
request to activate the bot. The request is processed by the router bot, which switches the context to the bot in the language selected as the main one (e.g. English). - If the client sends a request the bot can’t understand, it detects the request language. If the language is the same, the interaction continues according to the bot script.
- If the request language is different from the language supported by the bot, it returns the context to the router, which in turn switches the context to the bot in the appropriate language.
During the next step, we will develop a possible implementation of a router bot.