# Multilingual ChatBot

**URL:** <https://forum.rasa.com/t/multilingual-chatbot/46102>\
**Category:** Rasa Open Source\
**Created:** [July 24, 2021, 7:42am UTC](https://forum.rasa.com/t/multilingual-chatbot/46102 "2021-07-24T07:42:25Z")\
**Posts on this page:** 14\
**Page:** 1

<div class="post-metadata">

**Author:** ![VNY](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/vny/32/19632_2.png) [@VNY](https://forum.rasa.com/u/VNY)\
**Post date:** [July 24, 2021, 7:42am UTC](https://forum.rasa.com/t/multilingual-chatbot/46102/1 "2021-07-24T07:42:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [July 24, 2021, 8:35am UTC](https://forum.rasa.com/t/multilingual-chatbot/46102/2 "2021-07-24T08:35:25Z")

</div>

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:

```auto
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:

```auto
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.

---

<div class="post-metadata">

**Author:** ![VNY](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/vny/32/19632_2.png) [@VNY](https://forum.rasa.com/u/VNY)\
**Post date:** [July 24, 2021, 11:06am UTC](https://forum.rasa.com/t/multilingual-chatbot/46102/4 "2021-07-24T11:06:27Z")

</div>

@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.

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [July 24, 2021, 1:31pm UTC](https://forum.rasa.com/t/multilingual-chatbot/46102/5 "2021-07-24T13:31:54Z")

</div>

You’ll need to build a [Custom Pipeline Component](https://rasa.com/docs/rasa/components/#custom-components) ([read more](https://blog.rasa.com/enhancing-rasa-nlu-with-custom-components/)) 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.

```auto
- intent: greet
  examples: | 
  - hello
  - bonjour
etc...

```

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

All your responses will need to be [Custom Actions](https://rasa.com/docs/rasa/custom-actions); in which you access the language and dispatch the correct message accordingly:

```auto
if language == "fr":
    dispatcher.utter_message("Salut! Comment puis-je vous aider?")
    #/* or dispatcher.utter_message(response = "utter_greet_fr") */
else:
     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.

```auto
- intent: greet
  examples: | 
  - hello
  - hey there
etc...

```

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](https://rasa.com/docs/rasa/custom-actions); in which you access the language, and translate then dispatch the message accordingly:

```auto
english_text = translateEnglish("Hey! How can I help you?", language)
dispatcher.utter_message(english_text)

```

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

---

<div class="post-metadata">

**Author:** ![VNY](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/vny/32/19632_2.png) [@VNY](https://forum.rasa.com/u/VNY)\
**Post date:** [July 24, 2021, 6:24pm UTC](https://forum.rasa.com/t/multilingual-chatbot/46102/6 "2021-07-24T18:24:17Z")

</div>

Thank you very much this help a lot

---

<div class="post-metadata">

**Author:** ![VNY](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/vny/32/19632_2.png) [@VNY](https://forum.rasa.com/u/VNY)\
**Post date:** [July 25, 2021, 9:32am UTC](https://forum.rasa.com/t/multilingual-chatbot/46102/7 "2021-07-25T09:32:10Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [July 25, 2021, 9:32am UTC](https://forum.rasa.com/t/multilingual-chatbot/46102/8 "2021-07-25T09:32:52Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![VNY](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/vny/32/19632_2.png) [@VNY](https://forum.rasa.com/u/VNY)\
**Post date:** [July 25, 2021, 6:36pm UTC](https://forum.rasa.com/t/multilingual-chatbot/46102/9 "2021-07-25T18:36:00Z")

</div>

@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

---

<div class="post-metadata">

**Author:** ![ChrisRahme](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/chrisrahme/32/15572_2.png) [@ChrisRahme](https://forum.rasa.com/u/ChrisRahme)\
**Post date:** [July 25, 2021, 7:08pm UTC](https://forum.rasa.com/t/multilingual-chatbot/46102/10 "2021-07-25T19:08:05Z")

</div>

That’s amazing! Glad to be of help 😄

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](http://forum.rasa.com/t/multilingual-chatbot/46102/5) as a solution if it helped you so that the topic can be marked as solved 🙂

---

<div class="post-metadata">

**Author:** ![Rishabhh17](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/rishabhh17/32/16105_2.png) [@Rishabhh17](https://forum.rasa.com/u/Rishabhh17)\
**Post date:** [September 19, 2021, 3:58am UTC](https://forum.rasa.com/t/multilingual-chatbot/46102/11 "2021-09-19T03:58:24Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![xsamerx3](https://avatars.discourse-cdn.com/v4/letter/x/b9bd4f/32.png) [@xsamerx3](https://forum.rasa.com/u/xsamerx3)\
**Post date:** [March 17, 2022, 11:38am UTC](https://forum.rasa.com/t/multilingual-chatbot/46102/12 "2022-03-17T11:38:07Z")

</div>

may you please share your code with us ?

---

<div class="post-metadata">

**Author:** ![Khadija](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/khadija/32/21407_2.png) [@Khadija](https://forum.rasa.com/u/Khadija)\
**Post date:** [September 7, 2022, 12:36am UTC](https://forum.rasa.com/t/multilingual-chatbot/46102/13 "2022-09-07T00:36:59Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![minji](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/minji/32/22018_2.png) [@minji](https://forum.rasa.com/u/minji)\
**Post date:** [November 25, 2022, 8:44am UTC](https://forum.rasa.com/t/multilingual-chatbot/46102/14 "2022-11-25T08:44:25Z")

</div>

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

---

<div class="post-metadata">

**Author:** ![AlleneBrick](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.rasa.com/allenebrick/32/22667_2.png) [@AlleneBrick](https://forum.rasa.com/u/AlleneBrick)\
**Post date:** [March 25, 2023, 3:07pm UTC](https://forum.rasa.com/t/multilingual-chatbot/46102/15 "2023-03-25T15:07:57Z")

</div>

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.

> **Summary**
>
> [my centura health login](https://mycenturahealth.site/)
