【发布时间】:2019-08-08 10:27:21
【问题描述】:
我正在尝试使用 Webhook 将 dialogflow 与 firebase 集成。 我收到的回复是:
“网络钩子状态”:{ “代码”:13, "message": "Webhook 调用失败。错误:500 内部服务器错误。" }
Webhook 是:https://us-central1-miarduino-844c8.cloudfunctions.net/receiveAssistantRequests
Firebase 规则是:
{
/* Visit https://firebase.google.com/docs/database/security to learn more about security rules. */
"rules": {
".read": true,
".write": true
}
}
我用过的index.js是:
const functions = require('firebase-functions');
// // Create and Deploy Your First Cloud Functions
// // https://firebase.google.com/docs/functions/write-firebase-functions
//
// exports.helloWorld = functions.https.onRequest((request, response) => {
// response.send("Hello from Firebase!");
// });
const admin = require('firebase-admin');
admin.initializeApp();
const DialogflowApp = require('actions-on-google').DialogflowApp;
exports.receiveAssistantRequests = functions.https.onRequest((request, response) => {
const app = new DialogflowApp({ request: request, response: response });
function handlerRequest(app) {
const device = app.getArgument('devices');
const status = app.getArgument('status');
return admin.database().ref(`/automation/${device}/value`).set(status)
.then(snapshot => {
app.ask(`Ok, switching ${device} ${status}. Do you want to control anything else?`);
});
}
app.handleRequest(handlerRequest);
});
如果我使用soapUI 发出请求:https://us-central1-miarduino-844c8.cloudfunctions.net/receiveAssistantRequests 我明白了:
HTTP/1.1 500 Internal Server Error
Content-Type=text/plain; charset=utf-8
X-Content-Type-Options=nosniff
X-Cloud-Trace-Context=7327cb053558c4598e01b0218e61e5cf;o=1
Date=Thu, 08 Aug 2019 10:19:12 GMT
Server=Google Frontend
Content-Length=36
Alt-Svc=quic=":443"; ma=2592000; v="46,43,39"
Error: could not handle the request
有人知道如何解决这个问题吗?
不确定问题出在 Dialogflow 还是 Firebase 中
【问题讨论】:
-
这听起来你的代码有问题。您可以通过转到console.firebase.google.com,选择左侧的“功能”,然后在顶部导航中选择“日志”来查看调用时的错误日志。如果您使用错误日志的内容更新您的问题,我们可能会提供进一步的帮助。
标签: javascript firebase google-cloud-functions dialogflow-es