2017-05-26 51 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

相关问题