Dialogflow es 尝试在voice assistant中测试google操作时出错
我正在尝试创建一个webhook,它将获取意图和当前状态,更改状态,并使用googlelibrary for node.js上的操作返回回复 index.js如下所示:Dialogflow es 尝试在voice assistant中测试google操作时出错,dialogflow-es,actions-on-google,google-home,Dialogflow Es,Actions On Google,Google Home,我正在尝试创建一个webhook,它将获取意图和当前状态,更改状态,并使用googlelibrary for node.js上的操作返回回复 index.js如下所示: 'use strict'; const {dialogflow} = require('actions-on-google'); const functions = require('firebase-functions'); const app = dialogflow({debug: true}); app.intent
'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);
{
"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
}
package.json如下所示:
'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);
{
"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
我提到您没有显示函数执行日志,但它看起来好像没有在任何地方定义
操作
,因此调用functions.https.onRequest(action)代码>返回一个错误
在您工作的源代码中,操作
定义为
const action = dialogflow();
所有的意图处理程序都注册到
action.intent(...)
而你有一个类似的定义
const app = dialogflow({debug: true});
因此,您可以将定义函数的行更改为
exports.fulfillment = functions.https.onRequest(app);
解决您眼前的问题。您可能希望使用函数运行过程中的任何错误日志来更新问题,而不仅仅是操作测试控制台中的错误。(个人说明-感谢阅读我的文章和来源。我希望它能有所帮助。)