Multiple languages

How can we use Rasa to support multiple languages in a single bot?

I want to support that if the customer is replying in language 1, then the bot replies with response from language 1, but if the user replies in language 2 then bot should continue with response in language 2. Ideally this would be part of same story.

you can use conditional response variation by creating a slot called language which is filled by a custom component that detects the language and sets a slot for every incoming message and then you can use the response variation based on the slot filled in

I understand how we can give out various responses. However, is it possible to use rasa to identify which language “intent” was matched?

Example:

greet intent has 2 variations. greet_en, greet_es. This however will break the story, as the intents will not be covered in the story.

I guess if there was a way to have maybe multiple NLU.yaml, one for each language, and the one with the highest confidence could set the language entity.

what do you mean by this? intents are generally ranked in order, so you can see the ranking to set the language. i am not sure what you mean having multiple nlu files. even if you split files, it still trains ONE model

Sorry, I know I’m not being clear. a bit too confused myself!

Let me take an example.

Even if the intents are ranked in order, what if 2 languages have similar “text”, but different intent? If rasa could be annotated about the language the user was communicating in, we could respond better.

Think of google translate’s detect language feature. It can offer you a better translation if it know which language the input is in.

Ultimately my goal is to make rasa be able to as easily switch language as the user is.

I still believe you can make a custom component which can detect language of an incoming sentence and set a slot for the incoming message and use conditional response to reply in the language detected.

Create a custom component, that can see the incoming message, detect the language and set a slot or an entity and use that slot to make responses.

you can also implement the same in custom actions.

That is definitely one way, but what if the language needs a different pipeline? Eg, english has words separated by space, but if language abs has words separated by say ., then we would need a different pipeline for nlu models. how would that work?

you would have to train two different models in that case. there is no way around that.

Got it! Thank you so much!