【问题标题】:Failed to parse Dialogflow response into AppResponse because of empty speech response when response size exceeds 1021 characters响应大小超过 1021 个字符时,由于语音响应为空,无法将 Dialogflow 响应解析为 AppResponse
【发布时间】:2019-02-15 04:43:15
【问题描述】:

我正在开发一个带有 Dialogflow 实现的 Google Action,但出现了一个奇怪的错误。 在某些时候,尽管答案是正确的,但它并没有被正确地解析为 AppResponse。

唯一的不同似乎是尺寸。我测量了大小,发现当后端的 JSON 响应超过 1021 个字符(文本中多一个字符就足够了)时,它给了我这个错误:

由于语音响应为空,无法将 Dialogflow 响应解析为 AppResponse

在响应文本中只添加一个额外的字符是可重现的,这会让响应失败。

我找不到关于 JSON 响应的任何大小限制。响应文本和卡片中的所有限制对于我的示例来说已经足够了。

{
"payload": {
    "google": {
        "expectUserResponse": true,
        "richResponse": {
            "items": [
                {
                    "simpleResponse": {
                        "textToSpeech": "328 characters here"
                    }
                },
                {
                    "basicCard": {
                        "title": "39 characters",
                        "subtitle": "16 characters",
                        "formattedText": "82 characters here"
                    }
                }
            ],
            "suggestions": [
                {
                    "title": "13 characters"
                },
                {
                    "title": "14 characters"
                },
                {
                    "title": "6 characters"
                }
            ]
        }
    }
},
"outputContexts": [
    {
        "name": "default",
        "lifespanCount": 99,
        "parameters": {
            "data": "54 characters"
        }
    }
]
}

【问题讨论】:

    标签: dialogflow-es actions-on-google dialogflow-es-fulfillment


    【解决方案1】:

    问题实际上与 NodeJS Express 服务器压缩以及 AWS API 网关有关。 在某个阈值之后,Express 服务器激活 GZIP 内容编码,这是 AWS API Gateway 无法理解的。禁用压缩解决了这个问题。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2019-01-27
      • 2019-01-25
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-08-09
      • 1970-01-01
      相关资源
      最近更新 更多