2017-09-05 47 views
1

我正在使用python为Assistat应用程序创建webhook。我可以询问用户位置的权限,但只要用户的同意下,我收到以下错误针对Google API版本2的API.ai操作:无法解析带有'INVALID_ARGUMENT'错误的JSON响应字符串:“:无法找到字段。”

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

我检查我的网络挂接服务器,并没有请求到达它。这看起来像是API.ai方面的一些问题。
下面是操作控制台调试响应使用Python客户端

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

我怎样才能解决这个问题是什么时候?

更新 节点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" 
     } 
     } 
    } 
    } 
} 

从操作服务器请求我的节点JS网络挂接服务器

{ 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意图设置
Fallback Intent for Welcome Intent Fallback Intent details

+1

你能告诉你在你履行响应的JSON。 –

+0

我正在使用烧瓶助手库http://flask-assistant.readthedocs.io/en/latest/quick_start.html但是对于这个问题,我的服务器上没有命中。 –

+0

您能否在API.AI中发布您认为应该处理用户同意的Intent截图? – Prisoner

回答

0

你没有在你的webhook上得到任何点击的最可能的原因是你没有注册的意图获得答复。

您可以通过创建事件设置为actions_intent_PERMISSION的意图来执行此操作。

又见SO如下回答:

+0

它正在使用节点。但用python我得到这个错误。 –

+0

请更新您的问题以表明此信息,以及您认为处理它的意图的屏幕截图。由于节点处理它,你还可以提供节点在工作时获得的JSON吗? – Prisoner

+0

已更新的问题..请检查 –

相关问题