Rasa Core version: 0.9.6
Python version: python 3
Operating system (windows, osx, ...): Ubuntu
Issue:
I want to build a multilingual chatbot. for EX, when a user starts a conversation in French, The bot will response in French. if user types something in English, the bot will start the conversation in English. How can I do this? (I will use google translate API to detect language and translate)
My idea is:
Content of domain file (if used & relevant):
I want to detect the language which user uses and translate user input into French before tokenization, featurization, extraction...
Could you tell me from the code, where should I modify it?
I think the ideal case here would be to have seperate bots that get loaded dependent on whether the language detected was english or french. I don't think translating the user input into french is such a good idea, google translate often messes that up and so you might not get the meaning you want
@akelad in run_bot(), how can I get the latest message from user?. I tried: DialogueStateTracker.latest_message but It gives me the error: type object 'DialogueStateTracker' has no attribute 'latest_message'
I want to get the latest_message to detect the language user uses
It's best to do that in a custom action, where you can call tracker.latest_message.text
I can get it in a custom action but I want to do in bot.py file because from there, I will decide which model should be loaded
@souvikg10 I think you had some suggestions on how best to get this working?
@MinhMinnie I think the models are loaded on startup, Imo, once your model becomes very large it is not a good idea to load it on the fly based on input message. You should spin up two bots with pre-loaded models and then put an detector in the middle that diverts traffic to each bot based on language detection( we use cookies to do that) but there are other methods. but as I mentioned in Gitter I suppose - lang detect is not easy specially English and French ( they are very similar in written when it comes to one word replies and you won't be able to make out anything).
Can you explain me a scenario where you might face this on a regular basis? I work in Belgium and we deal with 4 languages but never heard a scenario where people are switching languages during a conversation and for each language we manage separate channels today.
@souvikg10 Could you help me please?
I start the conversation by "Get started" button in fb messenger.
The bot gives me 3 options, "Choose a language" is one of them
After choosing "Choose a language", I have 2 choices : English and Fran莽ais (I have 2 models : English and French)
The bot is pre loaded with English model
If I click on button "Fran莽ais", How to reload the bot with the French model?

i wrote the solution in the above comment, create two bots in each language and use the same tracker store
@souvikg10 but in my case, the English model is loaded before the user chooses "French model". that means the user wants to switch the language during the English conversation.
I have 2 bots in each language, use Redis server as a tracker-store
@souvikg10 You mean: when a user starts interacting with the chatbot. The chatbot will detect what language the user is using based on the first input message. Then one of the models will be loaded. and then the user will be unable to change the language as the model is loaded?. But in my case, once a model has been loaded, how can I switch to another model (when user click to choose "Francais")?
You need an intermediary layer between two rasa chatbots(FR/EN), some sort of dispatcher,
Dispatcher could be a simple application in python that has a webhook for your channels or in node js(we are using botkit) this dispatcher is able to detect the user language( in case of Facebook, you can get user's profile language to start with.
In the backend you have two rasa servers with two endpoints for /parse, using the same user id you call either one of them using the language parameter
In my opinion, you should not provide user an option for a language, Facebook gives you user's profile language in it's webhook, use that to check which language the user has. Most users prefer the language their profile is in. It makes more sense.
You can also use Chatfuel and JSONAPI integration to get facebook's params such as userid, user language and pass it to the right Rasa server(FR or EN)
Channels --> Dispatcher(FR/EN) --> RasaFR OR RasaEN --> TrackerStore(Redis)
I will write up an example multilingual chatbot this weekend to better describe this case using Rasa.
Thanks @souvikg10. Waiting for the example
awesome, looking forward to seeing this @souvikg10!
If this example helps
https://github.com/souvikg10/rasa_multi_bot
https://medium.com/@souvikghosh_14630/building-a-multi-lingual-chatbot-using-rasa-and-chatfuel-cca20cbc645a
I wrote this that might help you understand what i was saying about a dispatcher. Here i used chatfuel because it is easy but you can use any application or API gateway
This issue has been automatically marked as stale because it has not had recent activity. It will be closed if no further activity occurs. Thank you for your contributions.
This issue has been automatically closed due to inactivity. Please create a new issue if you need more help.
@souvikg10 Could you help me please?
I start the conversation by "Get started" button in fb messenger.
The bot gives me 3 options, "Choose a language" is one of them
After choosing "Choose a language", I have 2 choices : English and Fran莽ais (I have 2 models : English and French)
The bot is pre loaded with English model
If I click on button "Fran莽ais", How to reload the bot with the French model?
@akelad
Hi,
Did you implemented this ?
Most helpful comment
I will write up an example multilingual chatbot this weekend to better describe this case using Rasa.