Closed MikeVerhees closed 6 years ago
Same issue here. Have you found a solution?
For now I'm using the workaround to have one app for each language:
var app = apiai('api_token_here', {language: 'nl'});
After some code diving, I'm using the following workaround, reusing the same app
:
const apiai = require('apiai')
const app = apiai('<your token here>', { version: '20170712' }) // ref below
const dialogflowRouter = {
async send(text, { sessionId, lang = '<your default lang here (e.g. pt-BR)>' } = {}) {
return new Promise((resolve, reject) => {
// before every request, make sure to set the language property of app
app.language = lang
let request = app.textRequest(text, { sessionId, lang })
request.on('response', resolve)
request.on('error', reject)
request.end()
}
}
}
// ----
// using the dialogflowRouter with language 'pt-BR'
let message = 'Your user input here'
dialogflowRouter.send(message, { sessionId: '<your session id>', lang: 'pt-BR' })
.then(dialogResponse => console.log(dialogResponse)) // adjust it to your needs
_ref: version: '20170712'
- uses @sys.number
as numbers instead of strings_
using apiai@4.0.3
I have the same issue. Have you found a solution?
@ppdeassis I have try your solution but it's not working
@nvtuan305 I've updated the code sample above, providing more details.
@ppdeassis Thank you! It's working. Another working solution is:
const aiClient = apiai('dialog_flow_access_token', { language: 'ja' });
aiClient.send(<parameters>);
NOTE: If you pass an invalid language (supported languages), the Dialogflow (apiai) will use the default language of the agent.
Hello,
so according to https://api.ai/docs/multi-language I can send the agent's language within the textRequest like so by providing the 'lang' parameter. However I've logged the result and the language is still set to 'en' even when I'm providing 'nl'
my textRequest looks like this:
var request = app.textRequest(commandData.text, { sessionId:
func${chatID}, lang: commandData.lang });
I've checked the examples and it seems the language is set when defining apiai. So am I doing something wrong or does the nodeJS client just not support setting the language at the request itself?
Thanks!