首页 > 解决方案 > 应用程序现在没有响应。MalformedResponse - 在平台响应中找不到 RichResponse 或 SystemIntent

问题描述

我正在尝试完成 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": ""
}

我的代码:

'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看看是否有帮助。我也尝试过寻找 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

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

我注意到的另一件事是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:,但发生了一些变化,我不知道是什么。

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

标签: dialogflow-esactions-on-google

解决方案


好吧,我终于想通了。我不确定发生了什么变化,但我认为这是 Dialog Flow 中从 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

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

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


推荐阅读