Failed to parse Dialogflow response into AppRespon

2019-08-25 03:23发布

问题:

Trying to figure out the right Dialogflow fulfillment webhook json response. The Json is being generated by .NET Core on 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
}

I have also tried this format:

{
    "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>"
                        }
                    }
                ]
            }
        }
    }
}

The response from the actions on google Simulator was:

{
  "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\"}"
        }
      ]
    }
  }
}

The Error Tab of the simulator has a lot of encoded Json but I believe the key information was:

Failed to parse Dialogflow response into AppResponse because of empty speech response

Finally, the Errors Tab contained the following:

MalformedResponse 'final_response' must be set.

I have looked at the samples for the DialogFlow fulfillment webhook and tried to follow that.

There's comprehensive documentation of the Node.js client library, but not that much on the correct Json response formats that use Ssml.

Any help will be a appreciated. Thanks

回答1:

If you're sending back a reply to be used for the Assistant:

  • You can omit the fulfillmentText field.
  • Fields that are null should be omitted. Including fulfillmentMessages, and the SimpleResponse fields textToSpeech and displayText.