How to make your chatbot multilingual

Image of an author
Konrad Suchecki
5 min read
updated: Jun 10, 2024

The ChatBot platform allows you to communicate with customers all over the world. In this article, you’ll learn how to add a new language to your AI bot. We’ll also show you how to make it work with your LiveChat integration.

Setting up a multilingual bot in ChatBotLink icon

Ask users about their languageLink icon

Use the Bot Response block to ask users about their language. In this example, we use the “Welcome and language options” block.
In this example, we use a Button type response with two buttons: English and Spanish.
Each of the buttons, once clicked, is set to go to the respective User Input block - English or Spanish.

Save the language chosen by the user (Set attribute)Link icon

Once a user clicks a chosen button, one of the related Set attribute blocks is triggered to set the language in your chatbot. Each of the mentioned Set attribute blocks changes the value of the selected_language attribute to English or Spanish.

If the selected_language attribute is not available on the list of attributes to choose, use the +Add custom attribute option once you open the SET dropdown.

Go to “Hello once again!” (Go to step)Link icon

Once your chatbot sets the language, the flow continues. If the Spanish language is set, the Go to step block brings the bot and the customer back to the main flow. If the English language is set, the flow continues automatically to the “Hello once again!” Bot Response and further on.

Hello once again! (Bot Response)Link icon

After successfully setting the language, each Bot Response block can be set to display the expected language messages.

In the example, the chatbot uses filters to check the value of selected_language.

Each response needs to have a filter added to check the value of selected_language.
Once you set the mentioned filters for your Bot Response messages, your chatbot will always check the selected_language to see what language message it should send.

Automatically detect the website language with JSLink icon

If your website has different language versions, you can make your chatbot recognize which one is loaded when a customer starts a chat. It can be done using Chat Widget API and the setSessionAttributes method.

Detect the website language
window.BE_API = window.BE_API || {};
window.BE_API.onLoad = () => {
    window.BE_API.setSessionAttributes({
        selected_lanugage: “English”,
    })
}

For example, if you have two language versions of your website - the English and the Spanish ones: on the English version, you need to add the code with the selected_lanugage: “English” parameter, and on the Spanish one, you need to set selected_lanugage: “Spanish”.

Once you set it, depending on what language version of your website a customer opened, when they started a chat, the chatbot will receive the information about the selected language attribute and if its value is English or Spanish. More about ChatBot Attributes can be found here.

Using the described Chat Widget API method, the process takes place automatically on your website.

Set Filters in your chatbot to make it display English or Spanish messages respectively.
Each of your Bot Responses blocks needs to have two responses - one in English and the other in Spanish. Each one also needs a filter added to check the value of selected_language.

The filter of the English message has to check if the selected_language value equals English. The Spanish message filter has to check if the selected_language value equals Spanish.

Setting up a multilingual bot in ChatBot integrated with LiveChatLink icon

Ask users about their language for chats handled by ChatBotLink icon

If you want your chatbot to ask customers what language it should use to chat with them in the LiveChat widget, the configuration is required only on the ChatBot side. Follow the steps in this section of this article.

Make ChatBot use your LiveChat Group languageLink icon

With LiveChat, you can set a different language for each of your LiveChat Groups. When ChatBot is assigned to a chat in the LiveChat app, it receives the information about the Group in which the chat was started.

ChatBot saves the Group’s ID number as the default_group_id attribute. Using that attribute, you can filter your chatbot to use the expected language. The LiveChat Group ID can be found in your LiveChat agent application Team section > Groups tab or by following this link. After clicking the chosen group on the list, you can find its ID right below its name in the Details on the right.

For our example, we created two groups. The “English” group has ID number 21, and the “Spanish” group has ID number 22.
Within each of the bot responses, we need to add two of them – one in English and the other in Spanish.
Each response needs to have a filter added to check the value of default_group_id. If once we click Add filter, the default_group_id is not available on the list, we have to choose +Add filter for the custom attribute and add default_group_id there**.**

The filter of the English message has to check if the default_group_id value equals 21 (our English group ID). The Spanish message filter has to check if  default_group_id equals 22 (our Spanish group ID).

Once you set the mentioned filters for all of your Bot Response messages, your chatbot will always check the group ID to see what language message it should send. You can always add more languages and related filters if needed.

Was this article helpful?

Got it!

Thanks for your feedback.

Thank you!

We’re happy to help.

Start a free ChatBot trial
and build your first chatbot today!

Free 14-day trial No credit card required

Discover our text| products