7

I am using Google Dialogflow (with V2 API) and I want to build a bot that can switch between multiple languages if desired by the user.

I have set up all intents in different languages and now I want users to be able to select one, e.g. by sending a simple message or by using a predefined button (this implementation detail is not yet certain but will probably not affect the problem anyway).

I know that the detectIntent method has a languageCode parameter, which is optional as far as I understand.

In the Dialogflow API environment at developers.google.com/apis-explorer, I can send the following request to my agent:

POST https://dialogflow.googleapis.com/v2/projects/<session>/agent/sessions/new:detectIntent?key={YOUR_API_KEY}

{
 "queryInput": {
  "text": {
   "text": "hi",
   "languageCode": "en-EN"
  }
 }
}

When sending a queryInput including a languageCode, the agent responds in the corresponding language, allowing to switch even mid-conversation, which I think is a great feature.

In other words, the language switch works fine in this testing environment, where you can manually send the languageCode parameter with each query, and change it if you want.

Now my question is:

Is there a way, preferably an easy one, for me to make use of this code?

I'm afraid I would have to set up a full implementation from scratch using JavaScript and HTML in order to get this running. Currently, I'm thinking about a website with an embedded iframe that lets you alter the Node.JS code somehow.

Any suggestions are welcome and appreciated. Except, please don't advise me to set up two separate bots, that's not what I'm looking for.

Alternatively, is there a better way of using Dialogflow to solve this problem?

Thank you.

Lin Du
  • 88,126
  • 95
  • 281
  • 483
acxcv
  • 73
  • 1
  • 8
  • 1
    Try using [Kommunicate](https://docs.kommunicate.io) – Sairaj Sawant Apr 25 '19 at 03:54
  • Interesting use case, this is currently not possible in Dialogflow, as the xml:lang attribute is not supported yet (https://www.w3.org/TR/speech-synthesis11/#S3.1.2) – lisa p. Apr 26 '19 at 15:03

1 Answers1

0

If you are using a Dialogflow integration, you can currently only use one language. If you are implementing your own interface with the end-user, just ask the end-user for their preferred language, and provide the language code with every call to detect intent.

Anthony V
  • 2,179
  • 1
  • 11
  • 6