簡體   English   中英

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.”

我正在使用python為Assistat應用程序創建webhook。 我可以向用戶請求位置許可,但是一旦用戶同意,我就會收到以下錯誤消息

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

我已經檢查了我的webhook服務器,但沒有任何請求。 這看起來像API.ai方面的問題。
以下是使用Python客戶端時來自Actions控制台的Debug響應

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

使用Python庫Flask-Assistant

我該如何解決這個問題?

UPDATE Node JS客戶端可以工作... Python客戶端有什么問題?

操作控制台調試響應

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

從Actions服務器到我的Node JS webhook服務器的請求

{ 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意向設置
后備意圖,歡迎意圖 后備意圖詳細信息

您沒有在Webhook上獲得任何點擊的最可能原因是您沒有注冊意圖來獲取答復。

您可以通過將事件設置為actions_intent_PERMISSION來創建一個Intent。

另請參閱以下關於SO的答案:

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM