【发布时间】:2019-11-19 08:31:56
【问题描述】:
我正在尝试创建一个 webhook,它将获取 Intent 和当前状态、更改状态并使用用于 node.js 的 actions-on-google 库发回回复。
index.js如下:
'use strict';
const {dialogflow} = require('actions-on-google');
const functions = require('firebase-functions');
const app = dialogflow({debug: true});
app.intent('welcome', conv => {
let replyState = setReplyState( conv, 'prompt' );
let intent = getIntentName( conv );
sendReply( conv, intent, replyState );
});
function getReplyState( conv ){
return conv.data['replyState'];
}
function setReplyState( conv, state ){
conv.data['replyState'] = state;
return state;
}
function getIntentName( conv ){
return conv.intent;
}
const welcomeReplies = [
"Welcome!"
];
const allReplies = {
welcome: welcomeReplies,
};
function sendReply( conv, intent, replyState ){
let repliesNamed = replyState;
let replies = allReplies[repliesNamed];
conv.add( reply );
}
exports.fulfillment = functions.https.onRequest(action);
package.json如下:
{
"scripts": {
"serve": "firebase serve --only functions",
"shell": "firebase functions:shell",
"start": "npm run shell",
"deploy": "firebase deploy --only functions",
"logs": "firebase functions:log"
},
"engines": {
"node": "8"
},
"dependencies": {
"firebase-admin": "~6.0.0",
"firebase-functions": "^2.0.3",
"actions-on-google": "~2.5.0"
},
"private": true
}
发生错误:
格式错误的响应 由于平台响应无效,无法将 Dialogflow 响应解析为 AppResponse:在 agentId:ab93fe46-9eb1-4a6c-aea7-1699d67d7369 和 intentId:1ec758db-d03a-40b7-85fe-189d9245e6e2 的平台响应中找不到 RichResponse 或 SystemIntent。
我推荐了https://github.com/afirstenberg/examples/tree/master/conversation-to-code-2-aog
【问题讨论】:
-
您可能希望使用函数本身运行中的任何错误日志来更新问题,而不仅仅是您在操作测试控制台中遇到的错误。
-
(个人笔记 - 感谢您阅读我的文章和来源。我希望它会有所帮助。)
标签: dialogflow-es actions-on-google google-home