This multi-language chatbot is able to send text in multiple languages based on the browser language.
It uses an approach based on Reply Filters. The basic idea is that you can use some available attribute to "filter" in (or out) some replies' components (i.e. text, images etc.). The Filter feature is available on each reply component.
When we work with languages we can use the user_language attribute that always represents the ISO language of the user on the channel he's using to communicate on Tiledesk.
Take a look at the whole chatbot design. It is made up of four total replies.
- Welcome reply (greet the user in three supported languages)
- Sales specific welcome message
- Support specific welcome message
- Fallback message
Each reply is managed "multi language", supporting three total languages:
- English (iso code "en"). It also acts as pivot language (the fallback language used when there is no support for the user-language by the chatbot)
- Italian (iso code "it")
- Spanish (iso code "es")
Focus on the welcome block. It's made up of one Reply action, "composed" by three different messages. Each one is filtered based on the user language got from the communicating channel. We "filtered" each text reply adding a filter condition on each one. The filters are basically all the same, as you can see in the figure, except for the "en" part of the reply. We want english to be also the defalt language so we must add another condition on it useing the special regex "matches" condition".
We used the regex:
^((?!it|es).)*$
We use this regex to get a "true" condition when the user language is different by the other two that we know are supported. As you can see the languages are represented by their iso codes "it" and "es".
If you support other languages different by the pivot one, you should add them here, adding them like in the following example:
^((?!it|es|fr|ru).)*$
In the previous expression we also added support for French (iso code "fr") and Russian (iso code "ru").