2017-05-26 52 views
1

我有一個天藍色的功能應用程序,我用作我的谷歌助理行動的webhook。我試圖按照正確的響應文檔,但在測試我的webhook時,我不斷在模擬器中出現以下錯誤。我的回覆消息中是否有任何錯誤?實現對話Webhook作爲Azure功能應用程序

無法從HTTP_RESPONSE解析SDKResponse:

HTTP/1.1 200 OK 
Cache-Control: no-cache 
Pragma: no-cache 
Content-Length: 451 
Content-Type: application/json; charset=utf-8 
Content-Encoding: gzip 
Expires: -1 
Vary: Accept-Encoding 
Server: Microsoft-IIS/8.0 
X-AspNet-Version: 4.0.30319 
X-Powered-By: ASP.NET 
Date: Sun, 28 May 2017 19:00:13 GMT 

{"conversationToken":"cee44ab4-97dd-4e18-99c7-2b8613eb7584","expectUserResponse":true,"expectedInputs":[{"inputPrompt":{"richInitialPrompt":{"items":[{"simpleResponse":{"textToSpeech":"So, you want to become a great swordsman? First, you must learn the proper technique of insult sword fighting. The current difficulty level is Easy. Say 'Tutorial' for some quick instructions. Say 'Start Game' to start the game. Say 'Options' for more options. "}}]}}}]} 

這裏是格式化的可讀性JSON:

{ 
    "conversationToken": "cee44ab4-97dd-4e18-99c7-2b8613eb7584", 
    "expectUserResponse": true, 
    "expectedInputs": [ 
    { 
     "inputPrompt": { 
     "richInitialPrompt": { 
      "items": [ 
      { 
       "simpleResponse": { 
       "textToSpeech": "So, you want to become a great swordsman? ... " 
       } 
      } 
      ] 
     } 
     } 
    } 
    ] 
} 

用我的最新測試中,我嘗試發送履行頁面上給出確切的例子響應指令仍然失敗:https://developers.google.com/actions/components/fulfillment

{ 
    "conversationToken": "{\"state\":null,\"data\":{}}", 
    "expectUserResponse": true, 
    "expectedInputs": [ 
    { 
     "inputPrompt": { 
     "richInitialPrompt": { 
      "items": [ 
      { 
       "simpleResponse": { 
       "textToSpeech": "Howdy! I can tell you fun facts about almost any number, like 42. What do you have in mind?", 
       "displayText": "Howdy! I can tell you fun facts about almost any number. What do you have in mind?" 
       } 
      } 
      ], 
      "suggestions": [] 
     } 
     }, 
     "possibleIntents": [ { "intent": "actions.intent.TEXT" } ] 
    } 
    ] 
} 
+0

需要明確的是 - 您使用API​​.AI網絡掛接,或者一個動作包?無論在哪種情況下,這個JSON正文都是你正在返回的內容嗎? – Prisoner

+0

不使用API​​.AI,只是簡單的操作包。我沒有交換響應文本,所以Content-Length不正確,但json結構正是我返回的(格式化/縮進以提高可讀性) –

+0

我試過忽略conversationToken,我嘗試添加空建議陣列向richInitialPrompt致敬,均無濟於事。 –

回答

1

看起來您的items的輸入略有失效。 Item對象被定義爲聯合字段,指示必須設置三個屬性(simpleResponse,​​或structuredResponse)中的一個及其相應的值。

所以textToSpeech屬性不應該是下richInitialPrompt.item直接,相反,你應該有一個simpleResponse屬性,並根據這一點,textToSpeech屬性(或者,讓您的SimpleResponse對象意義上的其他屬性中的一個。你必須在至少一個SimpleResponse(並且它必須是第一個),並且您可能不超過兩個。

但是,在第二個響應中附加的文本在此上下文中沒有意義。一個用於在用戶動作延遲的情況下

v1協議有一種方式來支持細節的重新提示,但我在v2中看不到同樣的東西。

所以JSON應該看起來可能更像:

{ 
    "conversationToken": "fa3bfc17-de0a-4df8-900d-44dbb17b86c6", 
    "expectUserResponse": true, 
    "expectedInputs": [ 
     { 
      "inputPrompt": { 
       "richInitialPrompt": { 
        "items": [ 
         "simpleResponse": { 
          "textToSpeech": "Text for my response" 
         } 
        ] 
       } 
      } 
     } 
    ] 
} 
+0

我用更新的有效負載編輯了原始問題 –

+0

@ArtSherwood對此有何更新? – user849953

相關問題