简体   繁体   中英

DialogFlow Google Assistant Webhook Response: “Empty speech response”

I am having some trouble using the Fulfillment/Webhook of Dialogflow. I have created an Intent which accepts a parameter as input (pin number). The pin is "validated" at the server end using the Webhook call. That is, "Enable webhook call for this intent" is checked. The method returns a positive message on successful validation.

The whole scenario works perfectly as long as I use the Dialogflow console's "Try it Now" window. But when I try to test it in the Google Assistant Simulator, it responds with:

Screen from Actions on Google page > Response

Also,

Screen from Actions on Google page > Validation Errors

Here is the intent:

Intent screen from DialogFlow Agent page

The response I have set to return from the Webhook call:

"messages": [
  {
    "speech": "Thanks. Your pin has been confirmed.",
    "type": 0
  }

Sample response found here: https://dialogflow.com/docs/fulfillment

Please note, I have already checked Error "Empty speech response" . It didn't help.

That's a good question, and the documentation looks a bit unclear about valid responses.

When replying with a message for the Google Assistant, you should be using the speech and displayText parameters for the response. So the equivalent response would be something like

{
  "speech": "Thanks. Your pin has been confirmed.",
  "displayText": "Thank you. We have confirmed your PIN and you can proceed."
}

However, if you're going to be doing additional work with Actions on Google features (cards, feature requests, etc) or even just keep the conversation open while talking to the user, then you will need to use the data.google object as well and possibly include a simpleResponse as part of the reply . That might look something like this:

{
  "speech": "Thanks. Your pin has been confirmed.",
  "displayText": "Thank you. We have confirmed your PIN and you can proceed.",
  "data": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "Thanks. Your pin has been confirmed.",
              "displayText": "Thank you. We have confirmed your PIN and you can proceed."
            }
          }
        ]
      }
    }
  }
}

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM