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

时间:2018-08-20 20:19:32

标签: dialogflow actions-on-google

试图找出正确的Dialogflow实现webhook json响应。 Json由.NET Core在AWS Lambda上生成。

{
  "fulfillmentText": "<speak><p>Welcome to Alterians News. I provide news that is of interest to Alterianss from a variety of sources, and on a variety of topics.</p> \r\n              <p>You can say <emphasis>read</emphasis>, then the topic name. For example, you could say <emphasis>read today's news</emphasis>, or <emphasis>read <prosody rate=\"112%\">Banking and Finance</prosody> news</emphasis>.</p> \r\n              <p>I cover the following Alterians news topics: house cats, Agriculture, \r\n              <prosody rate=\"112%\">Banking and Finance</prosody>, Party Politics, <prosody rate=\"112%\">Police and Crime</prosody>, and the Military</p></speak>",
  "fulfillmentMessages": null,
  "source": null,
  "payload": {
    "google": {
      "text": null,
      "expectUserResponse": false,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": null,
              "displayText": null,
              "ssml": "<speak><p>Welcome to Alterians News. I provide news that is of interest to Alterianss from a variety of sources, and on a variety of topics.</p> \r\n              <p>You can say <emphasis>read</emphasis>, then the topic name. For example, you could say <emphasis>read today's news</emphasis>, or <emphasis>read <prosody rate=\"112%\">Banking and Finance</prosody> news</emphasis>.</p> \r\n              <p>I cover the following Alterians news topics: house cats, Agriculture, \r\n              <prosody rate=\"112%\">Banking and Finance</prosody>, Party Politics, <prosody rate=\"112%\">Police and Crime</prosody>, and the Military</p></speak>"
            }
          }
        ]
      },
      "SystemItent": null
    }
  },
  "outputContexts": null,
  "followupEventInput": null
}

我也尝试过这种格式:

{
    "payload":
    {
        "google":
        {
            "expectUserResponse":true,
            "richResponse":
            {
                "items":
                [
                    {
                        "simpleResponse":
                        {
                            "textToSpeech":"<speak><p>Welcome to Alterian News. I provide news that is of interest to Alterians from a variety of sources, and on a variety of topics.</p></speak>"
                        }
                    }
                ]
            }
        }
    }
}

在Google Simulator上的操作响应为:

{
  "responseMetadata": {
    "status": {
      "code": 10,
      "message": "Failed to parse Dialogflow response into AppResponse because of empty speech response",
      "details": [
        {
          "@type": "type.googleapis.com/google.protobuf.Value",
          "value": "{\"id\":\"f4fdf231-5316-454c-a969-6f36bd889d67\",\"timestamp\":\"2018-08-20T18:30:33.509Z\",\"lang\":\"en-us\",\"result\":{},\"status\":{\"code\":206,\"errorType\":\"partial_content\",\"errorDetails\":\"Webhook call failed. Error: 502 Bad Gateway\"},\"sessionId\":\"1534789833483\"}"
        }
      ]
    }
  }
}

模拟器的“错误”选项卡上有很多经过编码的Json,但我相信关键信息是:

  

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

最后,“错误”标签包含以下内容:

  

必须设置格式错误的响应“ final_response”。

我查看了DialogFlow实现Webhook的示例,并尝试遵循该示例。

这里有关于Node.js客户端库的全面文档,但是关于使用Ssml的正确Json响应格式的信息并不多。

任何帮助将不胜感激。 谢谢

1 个答案:

答案 0 :(得分:0)

如果您发回用于助手的回复:

  • 您可以忽略fulfillmentText字段。
  • 为空的字段应省略。包括fulfillmentMessages以及SimpleResponse字段textToSpeechdisplayText