通过云函数内联编辑器的 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.
任何方向将不胜感激。