Подключение диалогового потока к ошибке Firebase: сбой вызова Webhook. Ошибка: время ожидания запроса - PullRequest
0 голосов
/ 28 марта 2019

Агент Dialogflow через встроенный редактор облачных функций выдает следующую ошибку: «Сбой вызова Webhook. Ошибка: истекло время ожидания». При запуске облачной функции «handleReadTemp»

Невозможно обнаружить какие-либо другие ошибки, проверил само намерение, и оно работает на другие базовые / не связанные с пожарной базой ответы.

Код облачной функции встроенного редактора;

'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.

Любое направление будет оценено.

...