Change language within the conversation
If you have built your bot to support multiple languages, you want it to talk to the user in their own language.
Last updated
Was this helpful?
If you have built your bot to support multiple languages, you want it to talk to the user in their own language.
Last updated
Was this helpful?
The two solutions presented below go hand-in-hand in determining what's the user favorite language to interact in.
Please note that the bot can't figure out the language based on what the user is saying. What the bot can do instead is using the channel information. On Facebook, for example, the bot will use the value it receives from the FB user API. For the web widget, it'll use the SDK language.
You can use to check if the user's language is supported by your bot. If your bot doesn't support the user's language, redirect language detection to .
The variable that stores the user's preferred language is called preferredLanguage
. You can collect and change this variable in multiple ways.
To build a buttons flow that collects the user's preferredLanguage
:
Go to your canvas in .
Create a block.
Inside this block, ask the user in what language they'd like to continue, with buttons corresponding to your bot languages.
For each button, set the preferredLanguage
variable with value corresponding to the chosen language code.
Fill the lower part with these info:
Click Save.
In the example below, we've created an entity called @language to identify the languages that are available in the bot and have set a value for them:
en
for English
pt
for Portuguese
es
for Spanish
The intent of this example is called change language and is using the entity @language.
Make the change language intent go to a Condition block that we'll call Go to language.
In this Condition block, build conditions so that your language
variable goes to the next block with the new language set as the value for the preferredLanguage
variable, as in the example below:
At the end, your flow should look like something like this:
Go to your tab.
for the intent that will trigger the flow to change language.
that will trigger the flow to change the language.
.
Go back to your and add your change language intent to the canvas.
In the web widget you can trigger a specific bot language based on the language of the page the user is looking at. Find more information on this