简体   繁体   English

Webhook呼叫失败。 错误:请求超时

[英]Webhook call failed. Error: Request timeout

Not able to get dialogflow fullfillment response from node server and any help would be appreciated.Fulfillment status is following 无法从节点服务器获得对话框流程的完整填充响应,我们将不胜感激任何帮助。实现状态如下

Webhook call failed. Webhook呼叫失败。 Error: Request timeout. 错误:请求超时。

on console getting following error 在控制台上获得以下错误

(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] 

I am using V2 api. 我正在使用V2 api。

on debugging line 85 of dialogflow-fulfillment.js the body is undefined that is causing the error (this.request_.body.result) 在调试dialogflow-fulfillment.js的第85行时,正文是未定义的,导致错误(this.request_.body.result)

Fullfillment request is following 满额要求如下

{
  "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."
  }
}

server side code is 服务器端代码是

    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);
});

    }

In index.js 在index.js中

I was importing the above server code (fullfillment.js) by require('./routes/fulfillmentRoutes'); 我是通过require('./routes/fulfillmentRoutes');导入上面的服务器代码(fullfillment.js require('./routes/fulfillmentRoutes');

changing require('./routes/fulfillmentRoutes') to require('./routes/fulfillmentRoutes')(app) solved the issue require('./routes/fulfillmentRoutes')更改为require('./routes/fulfillmentRoutes')(app)解决了问题

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 带有 Lambda 的 Dialogflow - Webhook 调用失败。 错误:502 错误网关 - Dialogflow with Lambda - Webhook call failed. Error: 502 Bad Gateway Dialogflow Webhook(Webhook调用失败。错误:500内部服务器错误) - Dialogflow Webhook (Webhook call failed. Error: 500 Internal Server Error) Webhook呼叫失败。 错误:500内部服务器错误| Dialogflow | 火力地堡 - Webhook call failed. Error: 500 Internal Server Error | Dialogflow | Firebase Dialogflow Webhook 调用失败。 错误:[ResourceName 错误] 路径 '' 与模板不匹配 - Dialogflow Webhook call failed. Error: [ResourceName error] Path '' does not match template npm 获取失败。 错误代码 504 - npm Fetch Failed. Error Code 504 多部分/表单数据请求失败。 直播意外结束 - multipart/form-data request failed. Stream ended unexpectedly 系列请求错误:SqlContext 错误。 步骤“GetData”失败:“超时:请求未能在 15000 毫秒内完成 - seriate RequestError: SqlContext Error. Failed on step “GetData” with: "Timeout: Request failed to complete in 15000ms 我的 node.js 服务器在 heroku 中成功运行,但构建失败。(运行构建包超时) - My node.js Server is running successfully in heroku but build failed.( Timeout running buildpack) heroku 构建失败。 “mongoUrl”://“mongodb...” 语法错误等等 - heroku build failed. “mongoUrl”://“mongodb…” syntax error and more WebSocket 连接失败。 WebSocket 握手期间出错 - socketjs - WebSocket connection failed. Error during WebSocket handshake - socketjs
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM