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.