Google API版本2上的API.ai操作:无法解析带有“ INVALID_ARGUMENT”错误的JSON响应字符串:“:找不到字段”。 [英] API.ai Actions on Google API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: ": Cannot find field."

查看:76
本文介绍了Google API版本2上的API.ai操作:无法解析带有“ INVALID_ARGUMENT”错误的JSON响应字符串:“:找不到字段”。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用python为Assistat应用创建webhook。我可以向用户请求位置许可,但是一旦用户同意,我就会收到以下错误消息

  UnparseableJsonResponse 
API版本2:无法解析带有 INVALID_ARGUMENT错误的JSON响应字符串::找不到字段。。

我已经检查了Webhook服务器,但没有请求。这看起来像API.ai方面的问题。
以下是使用Python客户端时来自Actions控制台的Debug响应

  {
assistantToAgentDebug:{
curlCommand: curl -v'< URL>'{\ user\:{\ userId\:\< USED_ID> \,\区域设置\:\ zh-cn\},\会话\:{\ conversationId\:\ 1504592665563\,\类型\:\ 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: [default defaultwelcomeintent-followup\]
},
inputs:[
{
intent : actions.intent.PERMISSION,
rawInputs:[
{
inputType: VOICE,
query:是
}
],
参数:[
{
name: PERMISSION,
textValue: true
}
]
}
],
表面:{
功能:[
{
名称:动作。 Capacity.AUDIO_OUTPUT
},
{
name: actions.capability.SCREEN_OUTPUT
}
]
},
设备:{
l ocation:{
coordinates:{
latitude:37.4219806,
longitude:-122.0841979
}
}
},
isInSandbox:真
}
},
agentToAssistantDebug:{
agentToAssistantJson:{
message:意外的apiai响应格式:空语音回复,
apiResponse:{
id:< ID>,
timestamp: 2017-09-05T06:24:41.711Z ,
lang: en,
result:{},
status:{
code:200,
errorType :成功
},
sessionId: 1504592665563
}
}
},
sharedDebugInfo:[
{
name: GOOGLE_SYSTEM_ACTION,
debugInfo:您的查询由Google的Action处理。
},
{
name: GOOGLE_SYSTEM_ACTION,
debugInfo:您的查询由Google的Action处理。
},
{
name: ResponseValidation,
subDebugEntry:[
{
name: UnparseableJsonResponse,
debugInfo: API版本2:无法解析带有'INVALID_ARGUMENT'错误的JSON响应字符串:\:找不到字段。\。
}
]
}
]
}

使用Python库

解决方案

您在Webhook上未获得任何点击的最可能原因是您没有注册获取回复的意图。



您可以通过将事件设置为 actions_intent_PERMISSION 来创建一个Intent。



另请参见以下答案:




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

解决方案

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:

这篇关于Google API版本2上的API.ai操作:无法解析带有“ INVALID_ARGUMENT”错误的JSON响应字符串:“:找不到字段”。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆