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.
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.
Toggle on Language detection
You can use Language detection 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 a block that collects the user language.
Collect the user's preferredLanguage
The variable that stores the user's preferred language is called preferredLanguage
. You can collect and change this variable in multiple ways.
With buttons
To build a buttons flow that collects the user's preferredLanguage
:
Go to your canvas in Flows.
Create a Collect input 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.
With an intent
Go to your Entities tab.
Create a Contextual entity for the intent that will trigger the flow to change language.
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 Englishpt
for Portuguesees
for Spanish

Create an intent that will trigger the flow to change the language.
The intent of this example is called change language and is using the entity @language.

Go back to your Flows and add your change language intent to the canvas.
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:

Trigger a language with the Web channel
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 here.
Last updated
Was this helpful?