Nathan Gilson
Nathan Gilson

Reputation: 11

How do I force google action to switch the language during conversation?

I am building a bot for the google assistant using the action-on-google sdk and dialogflow in a webhook.

During the conversation, I need to give to the user the option to switch the language, as the implemented language detection doesn't work every time.

Exemple, in the middle of the conversation:

All I have found is that I can get the language of the request with agent.locale, but I haven't found any way to set it.

Any help?

Upvotes: 1

Views: 897

Answers (2)

sid8491
sid8491

Reputation: 6800

If you are using any SDK to call dialogflow then you can change language code based on some logic or some utterance (maybe identify the language and pass the language code accordingly).

For python SDK you can use below code and change the language_code accordingly.

text_input = dialogflow.types.TextInput(text=text, language_code="en")
query_input = dialogflow.types.QueryInput(text=text_input)
response = session_client.detect_intent(session=session, query_input=query_input)

Hope it helps.

Upvotes: 0

Nick Felker
Nick Felker

Reputation: 11970

The platform doesn't support swapping languages dynamically.

Upvotes: 1

Related Questions