Webhook call failed. Error: Request timeout
Webhook call failed. Error: Request timeout
无法从节点服务器获得 dialogflow fullfillment 响应,任何帮助都是appreciated.Fulfillment状态如下
Webhook 调用失败。错误:请求超时。
在控制台上出现以下错误
(node:3600) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'result' of undefined
[0] at new WebhookClient (D:\practice\reactbot\node_modules\dialogflow-fulfillment\src\dialogflow-fulfillment.js:85:28)
[0] at app.post (D:\practice\reactbot\routes\fulfillmentRoutes.js:6:23)
[0] at Layer.handle [as handle_request] (D:\practice\reactbot\node_modules\express\lib\router\layer.js:95:5)
[0] at next (D:\practice\reactbot\node_modules\express\lib\router\route.js:137:13)
[0] at Route.dispatch (D:\practice\reactbot\node_modules\express\lib\router\route.js:112:3)
[0] at Layer.handle [as handle_request] (D:\practice\reactbot\node_modules\express\lib\router\layer.js:95:5)
[0] at D:\practice\reactbot\node_modules\express\lib\router\index.js:281:22
[0] at Function.process_params (D:\practice\reactbot\node_modules\express\lib\router\index.js:335:12)
[0] at next (D:\practice\reactbot\node_modules\express\lib\router\index.js:275:10)
[0] at expressInit (D:\practice\reactbot\node_modules\express\lib\middleware\init.js:40:5)
[0] at Layer.handle [as handle_request] (D:\practice\reactbot\node_modules\express\lib\router\layer.js:95:5)
[0] at trim_prefix (D:\practice\reactbot\node_modules\express\lib\router\index.js:317:13)
[0] at D:\practice\reactbot\node_modules\express\lib\router\index.js:284:7
[0] at Function.process_params (D:\practice\reactbot\node_modules\express\lib\router\index.js:335:12)
[0] at next (D:\practice\reactbot\node_modules\express\lib\router\index.js:275:10)
[0] at query (D:\practice\reactbot\node_modules\express\lib\middleware\query.js:45:5)
[0]
我正在使用 V2 api。
在 dialogflow 的调试行 85-fulfillment.js 正文未定义导致错误 (this.request_.body.result)
履行请求如下
{
"responseId": "9257c21f-bdc5-4994-ab1b-5902518c80bc-2dd8e723",
"queryResult": {
"queryText": "Where is snoopy?",
"parameters": {},
"allRequiredParamsPresent": true,
"fulfillmentText": "Can you help me find him?",
"fulfillmentMessages": [
{
"text": {
"text": [
"I dont know where Snoopy is."
]
}
},
{
"text": {
"text": [
"Can you help me find him?"
]
}
}
],
"intent": {
"name": "projects/reactpageagent-uonbfa/agent/intents/65dc9557-7ba3-4a79-97f9-3215daf7733f",
"displayName": "snoopy"
},
"intentDetectionConfidence": 1,
"diagnosticInfo": {
"webhook_latency_ms": 4982
},
"languageCode": "en"
},
"webhookStatus": {
"code": 4,
"message": "Webhook call failed. Error: Request timeout."
}
}
服务器端代码是
const {WebhookClient} = require('dialogflow-fulfillment');
module.exports = app => {
app.post('/', async (req, res) => {
const agent = new WebhookClient({ request: req, response: res
});
function snoopy(agent) {
agent.add(`Welcome to my Snoopy fulfillment!`);
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
let intentMap = new Map();
intentMap.set('snoopy', snoopy);
intentMap.set('Default Fallback Intent', fallback);
agent.handleRequest(intentMap);
});
}
在index.js
我正在导入上面的服务器代码 (fullfillment.js)
require('./routes/fulfillmentRoutes');
改变
require('./routes/fulfillmentRoutes')
到
require('./routes/fulfillmentRoutes')(app)
解决了问题
无法从节点服务器获得 dialogflow fullfillment 响应,任何帮助都是appreciated.Fulfillment状态如下
Webhook 调用失败。错误:请求超时。
在控制台上出现以下错误
(node:3600) UnhandledPromiseRejectionWarning: TypeError: Cannot read property 'result' of undefined
[0] at new WebhookClient (D:\practice\reactbot\node_modules\dialogflow-fulfillment\src\dialogflow-fulfillment.js:85:28)
[0] at app.post (D:\practice\reactbot\routes\fulfillmentRoutes.js:6:23)
[0] at Layer.handle [as handle_request] (D:\practice\reactbot\node_modules\express\lib\router\layer.js:95:5)
[0] at next (D:\practice\reactbot\node_modules\express\lib\router\route.js:137:13)
[0] at Route.dispatch (D:\practice\reactbot\node_modules\express\lib\router\route.js:112:3)
[0] at Layer.handle [as handle_request] (D:\practice\reactbot\node_modules\express\lib\router\layer.js:95:5)
[0] at D:\practice\reactbot\node_modules\express\lib\router\index.js:281:22
[0] at Function.process_params (D:\practice\reactbot\node_modules\express\lib\router\index.js:335:12)
[0] at next (D:\practice\reactbot\node_modules\express\lib\router\index.js:275:10)
[0] at expressInit (D:\practice\reactbot\node_modules\express\lib\middleware\init.js:40:5)
[0] at Layer.handle [as handle_request] (D:\practice\reactbot\node_modules\express\lib\router\layer.js:95:5)
[0] at trim_prefix (D:\practice\reactbot\node_modules\express\lib\router\index.js:317:13)
[0] at D:\practice\reactbot\node_modules\express\lib\router\index.js:284:7
[0] at Function.process_params (D:\practice\reactbot\node_modules\express\lib\router\index.js:335:12)
[0] at next (D:\practice\reactbot\node_modules\express\lib\router\index.js:275:10)
[0] at query (D:\practice\reactbot\node_modules\express\lib\middleware\query.js:45:5)
[0]
我正在使用 V2 api。
在 dialogflow 的调试行 85-fulfillment.js 正文未定义导致错误 (this.request_.body.result)
履行请求如下
{
"responseId": "9257c21f-bdc5-4994-ab1b-5902518c80bc-2dd8e723",
"queryResult": {
"queryText": "Where is snoopy?",
"parameters": {},
"allRequiredParamsPresent": true,
"fulfillmentText": "Can you help me find him?",
"fulfillmentMessages": [
{
"text": {
"text": [
"I dont know where Snoopy is."
]
}
},
{
"text": {
"text": [
"Can you help me find him?"
]
}
}
],
"intent": {
"name": "projects/reactpageagent-uonbfa/agent/intents/65dc9557-7ba3-4a79-97f9-3215daf7733f",
"displayName": "snoopy"
},
"intentDetectionConfidence": 1,
"diagnosticInfo": {
"webhook_latency_ms": 4982
},
"languageCode": "en"
},
"webhookStatus": {
"code": 4,
"message": "Webhook call failed. Error: Request timeout."
}
}
服务器端代码是
const {WebhookClient} = require('dialogflow-fulfillment');
module.exports = app => {
app.post('/', async (req, res) => {
const agent = new WebhookClient({ request: req, response: res
});
function snoopy(agent) {
agent.add(`Welcome to my Snoopy fulfillment!`);
}
function fallback(agent) {
agent.add(`I didn't understand`);
agent.add(`I'm sorry, can you try again?`);
}
let intentMap = new Map();
intentMap.set('snoopy', snoopy);
intentMap.set('Default Fallback Intent', fallback);
agent.handleRequest(intentMap);
});
}
在index.js
我正在导入上面的服务器代码 (fullfillment.js)
require('./routes/fulfillmentRoutes');
改变
require('./routes/fulfillmentRoutes')
到
require('./routes/fulfillmentRoutes')(app)
解决了问题