Multilingual ChatBot

Hi Iam working on a RASA chat bot where while interacting with chat bot If a change any language it need to be interact with same language if I was chatting in English and while chatting I asked French than it should continue with french

There are multiple solutions for this. Notably:

  1. Let the bot understand multiple languages at any time, but only change the response language when the user tells it to. For example:
User: "Hello"
Bot:  "Hey, how are you?"
User: "Je vais bien et toi?"
Bot:  "I am great! How can I help?"
User: "Parle en Francais" or "Can you speak French?"
Bot:  "Ok, je vais vous répondre en Francais!"
  1. Let the bot understand multiple languages at any time, and change the language every time the user changes it. For example:
User: "Hello"
Bot:  "Hey, how are you?"
User: "Je vais bien et toi?"
Bot:  "Je vais bien! Comment puis-je vous aider?"
  1. Build a bot per language on different servers, and in your frontend, let the user change the language, which will connect them to the other server.

Which one are you interested in?

Solution 2 is better, but harder to implement.

@ChrisRahme Thank you I am looking for solution 2 which matches with my requirements can you please help me to understand the best course of action to implement this solution.

You’ll need to build a Custom Pipeline Component (read more) that detects the language of the input.

Again you have multiple possibilities:

1. Understand and respond in only French and English:

Introduce intents with examples in both English and French.

- intent: greet
  examples: | 
  - hello
  - bonjour

Your Component will only detect the language only and save it.

All your responses will need to be Custom Actions; in which you access the language and dispatch the correct message accordingly:

if language == "fr":
    dispatcher.utter_message("Salut! Comment puis-je vous aider?")
    #/* or dispatcher.utter_message(response = "utter_greet_fr") */
     dispatcher.utter_message("Hey! How can I help you?")
    #/* or dispatcher.utter_message(response = "utter_greet_en") */

2. Understand and respond in any language:

Introduce intents with examples in English only.

- intent: greet
  examples: | 
  - hello
  - hey there

Your Component will detect the language, save it, and then translate the user input into English before passing it to the rest of the Pipeline, which will therefore process the translated English text and match it to an intent.

All your responses will need to be Custom Actions; in which you access the language, and translate then dispatch the message accordingly:

english_text = translateEnglish("Hey! How can I help you?", language)

As previously, solution 2 is better but harder to implement.

Thank you very much this help a lot

1 Like

@ChrisRahme custon action response I tried but it’s failing while translating the language can you please elaborate the solution or you have any code example in details thank you

Sorry, I don’t have any code examples.

What’s your error? You will probably need to check the documentation of the translation API you’re using.

Were you successful in building the Custom Pipeline Component before writing the Custom Action?

@ChrisRahme Thank you very much for your constant support I have successful build the code multi language interactive chatbot and yes previous error is due to the I used translator which is outdated and by replacing it with good translation it worked


That’s amazing! Glad to be of help :smile:

Especially that you built it in less than a day! I don’t think I could have done it myself that fast since I have no experience with Custom Pipeline Components.

Please mark the post above as a solution if it helped you so that the topic can be marked as solved :slight_smile:

1 Like

@VNY Are you able to make the multi lingual bot , I need some help.

may you please share your code with us ?

Hey please I’m interested in solution 3, i dont know how to link my 2 bots (of each language)to the html files, any help or any example code?

How did you manage to build the custom pipeline for language detection ? I tried working with google-cloud-translate module but didn’t manage…

Hey, If you’ve created the multi-lingual chat bot then please share its code with us, it will be of much help. Thanks in advance.


my centura health login