应用现在没有响应。格式错误的响应 - 在平台响应中找不到 RichResponse 或系统意图



我正在尝试完成Google操作的Codelabs教程,但遇到了一些麻烦。我正在"为助手构建操作(级别 2)"。

当我尝试在模拟器中测试操作时,我收到"我的测试应用现在没有响应。请稍后再试。

请求或响应选项卡中没有任何内容。下面是调试选项卡输出:

{
"response": "My test app isn't responding right now. Try again soon.",
"expectUserResponse": false,
"conversationToken": "EvwCS2o5Wk...",
"audioResponse": "//NExAASeH...",
"ssmlMarkList": [],
"debugInfo": {
"sharedDebugInfoList": []
},
"visualResponse": {
"visualElementsList": [
{
"displayText": {
"content": "My test app isn't responding right now. Try again soon."
}
}
],
"suggestionsList": [],
"agentLogoUrl": ""
},
"clientError": 0,
"is3pResponse": true,
"clientOperationList": [],
"projectName": ""
}

我的代码:

'use strict';
// Import the Dialogflow module from the Actions on Google client library.
const {
dialogflow,
Permission,
Suggestions,
} = require('actions-on-google');
// Import the firebase-functions package for deployment.
const functions = require('firebase-functions');
// Instantiate the Dialogflow client.
const app = dialogflow({debug: true});
// Handle the Dialogflow intent named 'favorite color'.
// The intent collects a parameter named 'color'.
app.intent('favorite color', (conv, {color}) => {
const luckyNumber = color.length;
// Respond with the user's lucky number and end the conversation.
if (conv.data.userName) {
conv.close(`${conv.data.userName}, your lucky number is ${luckyNumber}.`);
} else {
conv.close(`Your lucky number is ${luckyNumber}.`);
};
});
app.intent('Default Welcome Intent', (conv) => {
const options = {
context: 'Hi there, to get to know you better',
permissions: ['NAME'],
};
conv.ask(new Permission(options));
});
// Handle the Dialogflow intent named 'actions_intent_PERMISSION'. If user
// agreed to PERMISSION prompt, then boolean value 'permissionGranted' is true.
app.intent('ask permission', (conv, params, permissionGranted) => {
// If they didn't give me permission to use their name...
const options = ['Blue', 'Red', 'Green'];
if (!permissionGranted) {
conv.ask("Ok, no worries. What's your favorite color?");
conv.ask(new Suggestions(options));
} else {
// Otherwise, they gave me permission to use it
conv.data.userName = conv.user.name.display;
conv.ask(`Thanks, ${conv.data.userName}. What's your favorite color?`);
conv.ask(new Suggestions(options));
};
});
// Set the DialogflowApp object to handle the HTTPS POST request.
exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);

"错误"选项卡中也没有任何东西。我试图寻找clientError: 0的含义,看看这是否无济于事。我也尝试过寻找格式错误的响应错误,但我没有得到很多有用的信息。

我已经尝试了各种移动代码或重写它,但没有任何改变错误消息。我不知道它为什么会破裂。

此操作的日志 (https://console.cloud.google.com) 显示:

MalformedResponse: ErrorId: a5421d80-def5-42ef-ba55-8ac95a879e14. Failed to parse Dialogflow response into AppResponse because of invalid platform response. : Could not find a RichResponse or SystemIntent in the platform response for agentId: 6edfe023-05da-4726-9ee7-6469f0a5fb3d and intentId: 8ad48133-dd71-496c-b5af-d4ec19e88309

我试过寻找它,但找不到太多有用的信息。

我注意到的另一件事是 https://console.firebase.google.com 此函数的日志似乎没有更新。我拥有的最后一个日志是在 6/2 上,当函数第一次损坏时。我不知道为什么它不会更新。如果我运行firebase functions:log,我将有更多最近的条目,如下所示:

2019-06-16T22:20:20.246Z I : 
2019-06-16T22:20:21.895Z N dialogflowFirebaseFulfillment: 
2019-06-16T22:21:01.674Z N dialogflowFirebaseFulfillment: 
2019-06-16T22:27:45.629Z I : 
2019-06-16T22:27:47.249Z N dialogflowFirebaseFulfillment: 
2019-06-16T22:28:15.351Z N dialogflowFirebaseFulfillment: 
2019-06-16T22:59:06.793Z I : 
2019-06-16T22:59:08.488Z N dialogflowFirebaseFulfillment: 
2019-06-16T22:59:49Z N dialogflowFirebaseFulfillment: 

有一次,这些日志在dialogflowFirebaseFulfillment:旁边写着"未定义",但有些事情发生了变化,我不知道是什么。

任何帮助将不胜感激,因为我已经用尽了目前能想到的所有选择。

好吧,我终于想通了。我不确定发生了什么变化,但我认为这是在对话流中从 V1 迁移到 V2(所以教程不是真的正确),我在错误的 github 文档中寻找帮助。

这条线...

exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);

需要更改为...

exports.fulfillment = functions.https.onRequest(app);

我有一种感觉,这与我部署到Firebase有关,但让我走上正轨的是查看此页面:https://github.com/actions-on-google/actions-on-google-nodejs

具体来说,该部分讨论框架并导出到适当的框架。

希望这对处于类似情况的其他任何人有所帮助:)

最新更新