【问题标题】:Malformed Response 'final_response' must be set必须设置格式错误的响应“final_response”
【发布时间】:2018-06-23 20:57:45
【问题描述】:

我正在使用 DialogFlow 的 webhook,当我按如下方式发送 JSON 响应时:

{
  "fulfillmentText": "This is a text response",
  "source": "example.com",
  "payload": {
    "google": {
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "this is a simple response"
            }
          }
        ]
      }
    }
  }
}

但在网络服务器响应后我收到错误MalformedResponse 'final_response' must be set.

【问题讨论】:

  • 请分享您的 webhook 代码的相关部分。只是一个疯狂的猜测,您在 Dialogflow 控制台中的意图名称是否与 app.intent 中的字符串匹配?如果不匹配,您可能需要在控制台中删除意图并重新创建它。试试看。
  • 如果您通过模拟器进行测试,请更新您的问题以包含“调试”选项卡的内容。

标签: actions-on-google dialogflow-es


【解决方案1】:

该 JSON 响应对 Dialogflow Webhook 实现协议的 V2 有效。确保您已完成以下操作:

  1. 确保您已开启 V2 API。点击左上角的设置齿轮,点击V2 API按钮。

  2. 确保您为 webhook 的 URL 设置了 Fulfillment,并为您正在测试的 Intent 启用了它。

【讨论】:

    【解决方案2】:

    如果您为您的意图启用了 Webhook,请确保添加行 'WebhookClient.add('This is a sample response') 因为当为意图启用 Webhook 时,它期望用户设置了一些响应在 webhook 意图处理程序中。还要确保 add() 不在任何条件语句中,例如 ifwhileetc。

    exports.dialogflowFirebaseFulfillment = functions.https.onRequest((request, response) => {
        const agent = new WebhookClient({request, response});
    function webhookIntent(agent)
    {
        //All your custom logics.
        //Ensure the below line is not inside any conditional statements 
        agent.add(`You should hear this response without any error!`);
    }
    }

    或者

    如果您的意图中没有使用 webhook,请确保您的意图中设置了默认响应。

    我希望这会有所帮助!

    【讨论】:

      猜你喜欢
      • 2018-12-14
      • 1970-01-01
      • 2017-03-13
      • 2017-11-28
      • 1970-01-01
      • 2021-08-30
      • 2016-05-09
      • 2015-08-04
      • 1970-01-01
      相关资源
      最近更新 更多