I'm working on communicating with Dialogflow API.
`
const dialogflow = require('@google-cloud/dialogflow-cx');
const uuid = require('uuid');
const config = require('./devkey');
const projectId = 'test';
const location = 'northamerica-northeast1';
const agentId = 'test';
const sessionId = uuid.v4();
async function runIntent(text) {
const sessionClient = new dialogflow.SessionsClient({
apiEndpoint: 'northamerica-northeast1-dialogflow.googleapis.com',
credentials: {
private_key: config.private_key,
client_email: config.client_email
}
});
const sessionPath = sessionClient.projectLocationAgentSessionPath(
projectId,
location,
agentId,
sessionId
);
console.log('sessionPath: ', sessionPath, 'sessionId: ', sessionId);
const intentRequest = {
session: sessionPath,
queryInput: {
text: {
text: text
},
languageCode: 'en'
}
}
try {
const [response] = await sessionClient.detectIntent(intentRequest);
console.log('response: ', response);
console.log('resonse.text: ', response.queryResult.responseMessages[0].text.text[0]);
return response.queryResult.responseMessages[0].text.text[0];
} catch (err) {
console.log('error: ', err);
return err;
}
}
`
My question is regarding detectIntent method.
Usually it is working fine, however, sometimes it's not responding at all and ends up getting time out error.
Not sure what to do for this.
Any recommendation would be appreciated.
Thanks,
`
GoogleError: Total timeout of API google.cloud.dialogflow.cx.v3.Sessions exceeded 220000 milliseconds before any response was received.
at repeat (C:\google-dialogflow\poc-dialogflow2\backend\node_modules\google-gax\build\src\normalCalls\retries.js:66:31)
at Timeout._onTimeout (C:\google-dialogflow\poc-dialogflow2\backend\node_modules\google-gax\build\src\normalCalls\retries.js:101:25)
at listOnTimeout (internal/timers.js:531:17)
at processTimers (internal/timers.js:475:7) {
code: 4
}
`
Normally the detectIntent method is working, but sometimes it's responding at all, and only throws time out error at the end.
No idea what goes wrong.