API.ai Actions on Google API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: “: Cannot find field.”

青春壹個敷衍的年華 提交于 2019-12-11 09:52:56

问题


I am using python to create webhook for Assistat app. I am able to ask user for location permission, but as soon as user gives consent, I receive following error

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

I have checked my webhook server and no request comes to it. This looks like some issue at API.ai side.
Below is the Debug response from Actions console when using Python client

{
  "assistantToAgentDebug": {
    "curlCommand": "curl -v '<URL>'{\"user\":{\"userId\":\"<USED_ID>\",\"locale\":\"en-US\"},\"conversation\":{\"conversationId\":\"1504592665563\",\"type\":\"ACTIVE\",\"conversationToken\":\"[\\\"defaultwelcomeintent-followup\\\"]\"},\"inputs\":[{\"intent\":\"actions.intent.PERMISSION\",\"rawInputs\":[{\"inputType\":\"VOICE\",\"query\":\"yes\"}],\"arguments\":[{\"name\":\"PERMISSION\",\"textValue\":\"true\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"}]},\"device\":{\"location\":{\"coordinates\":{\"latitude\":37.4219806,\"longitude\":-122.0841979}}},\"isInSandbox\":true}'",
    "assistantToAgentJson": {
      "user": {
        "userId": "<USED_ID>",
        "locale": "en-US"
      },
      "conversation": {
        "conversationId": "1504592665563",
        "type": "ACTIVE",
        "conversationToken": "[\"defaultwelcomeintent-followup\"]"
      },
      "inputs": [
        {
          "intent": "actions.intent.PERMISSION",
          "rawInputs": [
            {
              "inputType": "VOICE",
              "query": "yes"
            }
          ],
          "arguments": [
            {
              "name": "PERMISSION",
              "textValue": "true"
            }
          ]
        }
      ],
      "surface": {
        "capabilities": [
          {
            "name": "actions.capability.AUDIO_OUTPUT"
          },
          {
            "name": "actions.capability.SCREEN_OUTPUT"
          }
        ]
      },
      "device": {
        "location": {
          "coordinates": {
            "latitude": 37.4219806,
            "longitude": -122.0841979
          }
        }
      },
      "isInSandbox": true
    }
  },
  "agentToAssistantDebug": {
    "agentToAssistantJson": {
      "message": "Unexpected apiai response format: Empty speech response",
      "apiResponse": {
        "id": "<ID>",
        "timestamp": "2017-09-05T06:24:41.711Z",
        "lang": "en",
        "result": {},
        "status": {
          "code": 200,
          "errorType": "success"
        },
        "sessionId": "1504592665563"
      }
    }
  },
  "sharedDebugInfo": [
    {
      "name": "GOOGLE_SYSTEM_ACTION",
      "debugInfo": "Your query was handled by Actions on Google."
    },
    {
      "name": "GOOGLE_SYSTEM_ACTION",
      "debugInfo": "Your query was handled by Actions on Google."
    },
    {
      "name": "ResponseValidation",
      "subDebugEntry": [
        {
          "name": "UnparseableJsonResponse",
          "debugInfo": "API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: \": Cannot find field.\"."
        }
      ]
    }
  ]
}

Using Python library Flask-Assistant

How can I resolve this issue?

UPDATE Node JS client works... what is the issue with Python client?

Action Console Debug response

{
  "assistantToAgentDebug": {
    "curlCommand": "curl -v '<URL>'{\"user\":{\"userId\":\"<USER_ID>\",\"locale\":\"en-US\"},\"conversation\":{\"conversationId\":\"<ID>\",\"type\":\"ACTIVE\",\"conversationToken\":\"[\\\"_actions_on_google_\\\",\\\"defaultwelcomeintent-followup\\\"]\"},\"inputs\":[{\"intent\":\"actions.intent.PERMISSION\",\"rawInputs\":[{\"inputType\":\"VOICE\",\"query\":\"yes\"}],\"arguments\":[{\"name\":\"PERMISSION\",\"textValue\":\"true\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"}]},\"device\":{\"location\":{\"coordinates\":{\"latitude\":37.4219806,\"longitude\":-122.0841979},\"formattedAddress\":\"Googleplex, Mountain View, CA 94043, United States\",\"zipCode\":\"94043\",\"city\":\"Mountain View\"}},\"isInSandbox\":true}'",
    "assistantToAgentJson": {
      "user": {
        "userId": "<USER_ID>",
        "locale": "en-US"
      },
      "conversation": {
        "conversationId": "<ID>",
        "type": "ACTIVE",
        "conversationToken": "[\"_actions_on_google_\",\"defaultwelcomeintent-followup\"]"
      },
      "inputs": [
        {
          "intent": "actions.intent.PERMISSION",
          "rawInputs": [
            {
              "inputType": "VOICE",
              "query": "yes"
            }
          ],
          "arguments": [
            {
              "name": "PERMISSION",
              "textValue": "true"
            }
          ]
        }
      ],
      "surface": {
        "capabilities": [
          {
            "name": "actions.capability.AUDIO_OUTPUT"
          }
        ]
      },
      "device": {
        "location": {
          "coordinates": {
            "latitude": 37.4219806,
            "longitude": -122.0841979
          },
          "formattedAddress": "Googleplex, Mountain View, CA 94043, United States",
          "zipCode": "94043",
          "city": "Mountain View"
        }
      },
      "isInSandbox": true
    }
  },
  "agentToAssistantDebug": {
    "agentToAssistantJson": {
      "conversationToken": "[\"_actions_on_google_\",\"defaultwelcomeintent-followup\"]",
      "expectUserResponse": true,
      "expectedInputs": [
        {
          "inputPrompt": {
            "richInitialPrompt": {
              "items": [
                {
                  "simpleResponse": {
                    "textToSpeech": "Given permission"
                  }
                }
              ]
            }
          },
          "possibleIntents": [
            {
              "intent": "assistant.intent.action.TEXT"
            }
          ]
        }
      ],
      "responseMetadata": {
        "status": {
          "code": 14
        },
        "queryMatchInfo": {
          "queryMatched": true,
          "intent": "Default Welcome Intent - fallback"
        }
      }
    }
  }
}

Request from Actions server to my Node JS webhook server

{ originalRequest: 
   { source: 'google',
     version: '2',
     data: 
      { isInSandbox: true,
        surface: [Object],
        inputs: [Array],
        user: [Object],
        device: [Object],
        conversation: [Object] } },
  id: '<ID>',
  timestamp: '2017-09-06T05:43:21.342Z',
  lang: 'en',
  result: 
   { source: 'agent',
     resolvedQuery: 'actions_intent_PERMISSION',
     speech: '',
     action: 'DefaultWelcomeIntent.DefaultWelcomeIntent-fallback',
     actionIncomplete: false,
     parameters: {},
     contexts: [ [Object], [Object], [Object], [Object], [Object] ],
     metadata: 
      { intentId: '<ID>',
        webhookUsed: 'true',
        webhookForSlotFillingUsed: 'false',
        nluResponseTime: 2,
        intentName: 'Default Welcome Intent - fallback' },
     fulfillment: { speech: 'Given permission', messages: [Array] },
     score: 1 },
  status: { code: 200, errorType: 'success' },
  sessionId: '<SID>' 
  }

API.ai Intent settings


回答1:


The most likely reason you're not getting any hits on your webhook is that you don't have an intent registered to get the reply.

You can do this by creating an Intent with the Event set to actions_intent_PERMISSION.

See also the following answers on SO:

  • Unable to accept the permission prompt on Actions on Google
  • Permission response not handled correctly


来源:https://stackoverflow.com/questions/46048317/api-ai-actions-on-google-api-version-2-failed-to-parse-json-response-string-wit

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!