6

I tried to connect DialogFlow and Actions on Google, so I created some intents, connected the services, added explicit and implicit invocations etc, but when I try the bot in the simulator https://console.actions.google.com/project/[projectId]/simulator/ it always gives me the error:

"Failed to parse Dialogflow response into AppResponse, exception thrown with message: Empty speech response"

even tough inputType was "KEYBOARD".

What I tried so far:

Unfortunately the docs don't say anything about this error. Any ideas?

Here a screenshot of the error on the Actions integration: enter image description here

This is the full debug output:

{
  "agentToAssistantDebug": {
    "agentToAssistantJson": {
      "message": "Failed to parse Dialogflow response into AppResponse, exception thrown with message: Empty speech response",
      "apiResponse": {
        "id": "c12e1389-e887-49d4-b399-a332188ca946",
        "timestamp": "2018-01-27T03:55:30.931Z",
        "lang": "en-us",
        "result": {},
        "status": {
          "code": 200,
          "errorType": "success"
        },
        "sessionId": "1517025330705"
      }
    }
  },
  "assistantToAgentDebug": {
    "assistantToAgentJson": {
      "user": {
        "userId": "USER_ID",
        "locale": "en-US",
        "lastSeen": "2018-01-27T03:55:03Z"
      },
      "conversation": {
        "conversationId": "1517025330705",
        "type": "NEW"
      },
      "inputs": [
        {
          "intent": "actions.intent.MAIN",
          "rawInputs": [
            {
              "inputType": "KEYBOARD",
              "query": "Talk to Mica, the Hipster Cat Bot"
            }
          ]
        }
      ],
      "surface": {
        "capabilities": [
          {
            "name": "actions.capability.MEDIA_RESPONSE_AUDIO"
          },
          {
            "name": "actions.capability.WEB_BROWSER"
          },
          {
            "name": "actions.capability.AUDIO_OUTPUT"
          },
          {
            "name": "actions.capability.SCREEN_OUTPUT"
          }
        ]
      },
      "isInSandbox": true,
      "availableSurfaces": [
        {
          "capabilities": [
            {
              "name": "actions.capability.AUDIO_OUTPUT"
            },
            {
              "name": "actions.capability.SCREEN_OUTPUT"
            }
          ]
        }
      ]
    },
    "curlCommand": "curl -v 'https://api.api.ai/api/integrations/google?token=TOKEN' -H 'Content-Type: application/json;charset=UTF-8' -H 'Google-Actions-API-Version: 2' -H 'Authorization: AUTH_TOKEN'  -A 'Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)' -X POST -d '{\"user\":{\"userId\":\"USER_ID\",\"locale\":\"en-US\",\"lastSeen\":\"2018-01-27T03:55:03Z\"},\"conversation\":{\"conversationId\":\"1517025330705\",\"type\":\"NEW\"},\"inputs\":[{\"intent\":\"actions.intent.MAIN\",\"rawInputs\":[{\"inputType\":\"KEYBOARD\",\"query\":\"Talk to Mica, the Hipster Cat Bot\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"},{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]}]}'"
  },
  "sharedDebugInfo": [
    {
      "name": "ResponseValidation",
      "subDebugEntry": [
        {
          "debugInfo": "API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\".",
          "name": "UnparseableJsonResponse"
        }
      ]
    }
  ]
}

Also "debugInfo" sounds like an internal problem:

"API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\"."

Here a screenshot of the welcome intent: enter image description here

ps. It took me AGES to figure out, what

"Query pattern is missing for custom intent"

means - so I just document it here: In Dialog Flow - Intent - "User says" you have to DOUBLE CLICK on a word in the text input field when you want to set it as query parameter - which seems to be required for Actions on Google.

Prags
  • 2,457
  • 2
  • 21
  • 38
electrobabe
  • 1,549
  • 18
  • 17
  • Can you update your question to include a screen shot of the welcome Intent? Do you have the fulfillment checkbox checked for the Intent? If so, can you also update the question to include the JSON that you are returning from the webhook and what Dialogflow version you're using? – Prisoner Jan 27 '18 at 05:14
  • As the one who posted as per your link, I had a different error message ('Cannot find field') than you - see also https://stackoverflow.com/questions/48158417/simulator-error-unparseablejsonresponse-cannot-find-field/48195773?noredirect=1#comment83379611_48195773 And this was thanks to @Prisoner who is kind enough to add a comment above. – Colin G Jan 27 '18 at 18:28
  • I've seen this error when a failure happens on my webhook and I never get to return any text, or there's some other text issue. – Nick Felker Jan 27 '18 at 18:55
  • @prisoner I updated my question (screenshots and what I tried). The problem also occurs when I disable the Fulfillment webhook. I also tried v1 and v2, – electrobabe Jan 29 '18 at 21:12
  • Ok, good. Can you also include a screenshot that includes having the "Response -> Default" tab selected? When you had the fulfillment webhook configured, what was the JSON you were sending back? – Prisoner Jan 29 '18 at 21:45
  • @Prisoner in the "Response -> Default" secion I just have some texts - the default texts from Dialog Flow itself. As I said before, the webhook is working within Dialog Flow itself. https://imgur.com/a/Ri3zu In V1 I respond with JSON {"speech":"blabla", "displayText":"blabla"} which works fine in Dialog Flow e.g. in the Web Demo https://bot.dialogflow.com/994dda8b-4849-4a8a-ab24-c0cd03b5f420 – electrobabe Jan 29 '18 at 22:16

6 Answers6

9

This happened to me. If this happens for an Intent you just added in the Dialogflow console and you are using Webhook fulfillment for the action, check the intent's fulfillment settings and ensure that the Webhook fulfillment slider is on. Evidently new intents don't automatically get webhook fulfillment: you have to opt each one in piecemeal (or at least, that was my experience).

Femi
  • 64,273
  • 8
  • 118
  • 148
  • I did that, however, I am still getting "empty response". This is inspite of the fact that from my webhook server running on my machine, it shows a 200 status. – Anshuman Kumar Dec 01 '20 at 12:04
2

I experienced this situation too. My problem was that I used a SimpleResponse in my fulfillment index.js without referencing to it. So the solution for me was to add SimpleResponse like this in index.js:

const {dialogflow, SimpleResponse} = require('actions-on-google');

So, always check if you aren't using any dependencies without including it in your js-file. Probably not the most common cause of the problem, but it can be.

1

I got this when running through the codelabs tutorial (https://codelabs.developers.google.com/codelabs/actions-1/index.html#4) and didn't name my intent the same name as it is referenced in the webhook script: Name Intent Use Intent

patrickbadley
  • 2,510
  • 2
  • 29
  • 30
0

I came across this error when trying to develop my own WebHook. I first verified that my code was called by looking into the Nginx log, after which I knew there was a problem in my JSON output because I based my output on outdated examples.

The (up-to-date) documentation for both V1 and V2 of the API can be found here: https://dialogflow.com/docs/fulfillment/how-it-works

This example response for v2 of the dialogflow webhook API helped me to resolve this error:

{
  "payload": {
    "google": {
      "expectUserResponse": true,
      "richResponse": {
        "items": [
          {
            "simpleResponse": {
              "textToSpeech": "this is a simple response"
            }
          }
        ]
      }
    }
  }
}

Source: https://github.com/dialogflow/fulfillment-webhook-json/blob/master/responses/v2/ActionsOnGoogle/RichResponses/SimpleResponse.json

You can find more examples in the official github repository linked above.

Bertware
  • 297
  • 8
  • 16
0

Another possibility is if you have a text response (even an empty one) like so: Responses Box

Then you need to click the trash can next to the response to clear it out to use the webhook.

patrickbadley
  • 2,510
  • 2
  • 29
  • 30
-5

The Actions on Google support helped me fix this problem:

I needed to add a text as Default Response to the intent used for Explicit Invocation.

electrobabe
  • 1,549
  • 18
  • 17