应用程序现在没有响应。MalformedResponse - 在平台响应中找不到 RichResponse 或 SystemIntent

SRo*_*Rod 1 actions-on-google dialogflow-es

我正在尝试通过 Google Actions 的 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": ""
}
Run Code Online (Sandbox Code Playgroud)

我的代码:

'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);
Run Code Online (Sandbox Code Playgroud)

“错误”选项卡中也没有任何内容。我试过追查 的含义,clientError: 0看看是否有帮助但无济于事。我也试过寻找 MalformedResponse 错误,但我没有得到很多有用的信息。

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

此操作的此处日志 ( 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
Run Code Online (Sandbox Code Playgroud)

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

我注意到的另一件事是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: 
Run Code Online (Sandbox Code Playgroud)

有一次,这些日志在 旁边写着“未定义” dialogflowFirebaseFulfillment:,但有些变化,我不知道是什么。

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

SRo*_*Rod 5

好吧,我终于想通了。我不确定发生了什么变化,但我认为这是 Dialog Flow 中从 V1 到 V2 的迁移(因此本教程不是很正确),我在错误的 github 文档中寻找帮助。

这条线...

exports.dialogflowFirebaseFulfillment = functions.https.onRequest(app);
Run Code Online (Sandbox Code Playgroud)

需要改成...

exports.fulfillment = functions.https.onRequest(app);
Run Code Online (Sandbox Code Playgroud)

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

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

希望这可以帮助其他处于类似情况的人:)