到firebase的dialogflow连接错误:Webhook调用失败。错误:请求超时

时间:2019-03-28 13:43:18

标签: firebase google-cloud-functions dialogflow actions-on-google dialogflow-fulfillment

Dialogflow代理通过云函数内联编辑器给出以下错误:“ Webhook调用失败。错误:请求超时。”在获取云函数“ handleReadTemp”时

无法观察到任何其他错误,无法测试意图本身,并且可以在其他与基础/非Firebase相关的响应上工作。

内联编辑器云功能代码;

'use strict';

const functions = require('firebase-functions');
const admin = require("firebase-admin");
const {WebhookClient} = require('dialogflow-fulfillment');
const {Card, Suggestion} = require('dialogflow-fulfillment');

admin.initializeApp({
  credential: admin.credential.applicationDefault(),
  databaseURL: 'ws://urlFromFirebase.firebaseio.com/'
});  

process.env.DEBUG = 'dialogflow:debug'; // enables lib debugging statements

exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
  const agent = new WebhookClient({ request, response });
  console.log('Dialogflow Request headers: ' + JSON.stringify(request.headers));
  console.log('Dialogflow Request body: ' + JSON.stringify(request.body));

  function welcome(agent) {
    agent.add(`Welcome to my agent!`);
  }

  function fallback(agent) {
    agent.add(`I didn't understand`);
    agent.add(`I'm sorry, can you try again?`);
  }
  function handleReadTemp(agent) {
    return admin.database().ref('dev/data/012dsf/').limitToLast(1).once('value').then((snapshot) => {
    const value = snapshot.child('Temp').val();
     agent.add(`The temperature right now is`); 
    });
  }
  let intentMap = new Map();
  intentMap.set('Default Welcome Intent', welcome);
  intentMap.set('Default Fallback Intent', fallback);
  intentMap.set('temperatureStatus', handleReadTemp);
  agent.handleRequest(intentMap);
});

诊断信息-响应:

{
  "responseId": "ca009ac6-a732-4427-8faa-922187fd8deb",
  "queryResult": {
    "queryText": "what is temperature",
    "parameters": {},
    "allRequiredParamsPresent": true,
    "fulfillmentMessages": [
      {
        "text": {
          "text": [
            ""
          ]
        }
      }
    ],
    "intent": {
      "name": "projects/projectName/agent/intents/d4450093-c128-4dc4-b4e1-d9c2bd9b2049",
      "displayName": "temperatureStatus"
    },
    "intentDetectionConfidence": 1,
    "diagnosticInfo": {
      "webhook_latency_ms": 5000
    },
    "languageCode": "en"
  },
  "webhookStatus": {
    "code": 4,
    "message": "Webhook call failed. Error: Request timeout."
  }
}

诊断信息-履行请求

{
  "responseId": "ca009ac6-a732-4427-8faa-922187fd8deb",
  "queryResult": {
    "queryText": "what is temperature",
    "parameters": {},
    "allRequiredParamsPresent": true,
    "fulfillmentMessages": [
      {
        "text": {
          "text": [
            ""
          ]
        }
      }
    ],
    "intent": {
      "name": "projects/sydneyiot-healthspace/agent/intents/d4450093-c128-4dc4-b4e1-d9c2bd9b2049",
      "displayName": "temperatureStatus"
    },
    "intentDetectionConfidence": 1,
    "diagnosticInfo": {
      "webhook_latency_ms": 5000
    },
    "languageCode": "en"
  },
  "webhookStatus": {
    "code": 4,
    "message": "Webhook call failed. Error: Request timeout."
  }
}

Diagnostic Info: Fulfillment Status

Webhook call failed. Error: Request timeout.

任何方向将不胜感激。

0 个答案:

没有答案