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.

A bot that doesn't have any information about the user's language will automatically use the primary language. The active language inside the conversation can be changed inside the flow.

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

With buttons

To build a buttons flow that collects the user's preferredLanguage:

  1. Go to your canvas in Flows.

  2. Create a Collect input block.

  3. Inside this block, ask the user in what language they'd like to continue, with buttons corresponding to your bot languages.

  4. For each button, set the preferredLanguage variable with value corresponding to the chosen language code.

  1. Fill the lower part with these info:

  1. Click Save.

With an intent

1

Go to your Entities tab.

2

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 English

  • pt for Portuguese

  • es for Spanish

3

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.

5

Go back to your Flows and add your change language intent to the canvas.

6

Make the change language intent go to a Condition block that we'll call Go to language.

7

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:

8

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?