2017-09-05 11 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

已更新的問題..請檢查 –

相關問題