要提供尽可能多的背景信息...
我已经使用Actions SDK为Google助手实现了一个代理;我参考了Conversation Webhook
协议的版本2来实现此目的。如果有帮助,则该代理已实现为在Apache Tomcat中运行的Java servlet,并且响应处理程序位于doPost()
方法中。
请尽我所能,我无法让Google Assistant接受我对会话版本2请求JSON的回复。在使用模拟器重现此错误后,我从Actions控制台中提取了日志,从本质上讲,它抱怨找不到"conversation_id
“关键字(即使我100%确信它是JSON响应的一部分,发回)。
这是原始日志供参考。
**"Received response from agent with body: HTTP/1.1 200
X-Frame-Options: SAMEORIGIN
X-Content-Type-Options: nosniff
X-XSS-Protection: 1; mode=block
Google-Assistant-API-Version: v2
Set-Cookie: JSESSIONID=D73C4430971C96C85990B7416906CDFB; Path=/; HttpOnly
Content-Type: application/json
Transfer-Encoding: chunked
Date: Wed, 20 Mar 2019 15:02:42 GMT
{""expectedInputs"":[{""possibleIntents"":[{""intent"":""actions.intent.TEXT""}],""inputPrompt"":{""richInitialPrompt"":{""items"":[{""simpleResponse"":{""textToSpeech"":""I'm work assist... your personal assistant. If this is your first time using this app, then I would recommend you go to https://flowharmonics.com and register a user. If you are an existing user, please provide your OTP.""}}]}}}],""conversation_token"":""ABwppHGjXZmjSUl2E-Qh9sUE0xKfT0tfQIdVaGUhbl1ouAU-0Km_NSUUumstFbQAc2gpuwd6fY1M06sIn8fJ22yOd9o"",""expectUserResponse"":true,""conversationId"":""ABwppHGjXZmjSUl2E-Qh9sUE0xKfT0tfQIdVaGUhbl1ouAU-0Km_NSUUumstFbQAc2gpuwd6fY1M06sIn8fJ22yOd9o"",""conversation_id"":""ABwppHGjXZmjSUl2E-Qh9sUE0xKfT0tfQIdVaGUhbl1ouAU-0Km_NSUUumstFbQAc2gpuwd6fY1M06sIn8fJ22yOd9o"",""conversationToken"":""ABwppHGjXZmjSUl2E-Qh9sUE0xKfT0tfQIdVaGUhbl1ouAU-0Km_NSUUumstFbQAc2gpuwd6fY1M06sIn8fJ22yOd9o""}.",efm4rzf9bwd2l,assistant_action,flowharmonics-173112,,actions.intent.MAIN,2019-03-20T15:03:26.869033624Z,DEBUG,preview,AOG_REQUEST_RESPONSE,GOOGLE_USER,projects/flowharmonics-173112/logs/actions.googleapis.com%2Factions,projects/876310722121/traces/ABwppHGjXZmjSUl2E-Qh9sUE0xKfT0tfQIdVaGUhbl1ouAU-0Km_NSUUumstFbQAc2gpuwd6fY1M06sIn8fJ22yOd9o,2019-03-20T15:03:26.901338329Z
"Sending request with post data: {""user"":{""userId"":""ABwppHF4KQ5nasLJ4QtawBJdbK2KrV25XJ0hfumhq0bNEestminCRU8fuCENGhtnInh1zFsSCnpgcFcj4r1VpfZ-7ik"",""locale"":""en-US"",""lastSeen"":""2019-03-20T14:53:21Z""},""conversation"":{""conversationId"":""ABwppHGjXZmjSUl2E-Qh9sUE0xKfT0tfQIdVaGUhbl1ouAU-0Km_NSUUumstFbQAc2gpuwd6fY1M06sIn8fJ22yOd9o"",""type"":""NEW""},""inputs"":[{""intent"":""actions.intent.MAIN"",""rawInputs"":[{""inputType"":""KEYBOARD"",""query"":""Talk to fallow mire""}]}],""surface"":{""capabilities"":[{""name"":""actions.capability.SCREEN_OUTPUT""},{""name"":""actions.capability.MEDIA_RESPONSE_AUDIO""},{""name"":""actions.capability.AUDIO_OUTPUT""},{""name"":""actions.capability.WEB_BROWSER""}]},""isInSandbox"":true,""availableSurfaces"":[{""capabilities"":[{""name"":""actions.capability.AUDIO_OUTPUT""},{""name"":""actions.capability.SCREEN_OUTPUT""},{""name"":""actions.capability.WEB_BROWSER""}]}],""requestType"":""SIMULATOR""}.",efm4rzf9bwd2j,assistant_action,flowharmonics-173112,,actions.intent.MAIN,2019-03-20T15:03:25.323688016Z,DEBUG,preview,AOG_REQUEST_RESPONSE,GOOGLE_USER,projects/flowharmonics-173112/logs/actions.googleapis.com%2Factions,projects/876310722121/traces/ABwppHGjXZmjSUl2E-Qh9sUE0xKfT0tfQIdVaGUhbl1ouAU-0Km_NSUUumstFbQAc2gpuwd6fY1M06sIn8fJ22yOd9o,2019-03-20T15:03:26.901338329Z
"UnparseableJsonResponse: API Version 2: Failed to parse JSON response string with 'INVALID_ARGUMENT' error: ""conversation_id: Cannot find field.""",rgxrihf9dzbpt,assistant_action,flowharmonics-173112,,actions.intent.MAIN,2019-03-20T14:53:23.160679259Z,ERROR,preview,JSON_RESPONSE_VALIDATION,GOOGLE_USER,projects/flowharmonics-173112/logs/actions.googleapis.com%2Factions,projects/876310722121/traces/ABwppHGEjHZfX8BEOL7kkYQd4-PJnERDHerrzajP0o27x1zh0Xt8Y0s9PC3bu9C4Jcj74S1MB8WCPZCcSwdakxowp_I,2019-03-20T14:53:23.191543799Z**
作为其他参考,这是我尝试过的事情:
gactions
来更新包,并确保将"fulfillmentApiVersion"
的值设置为“ 2”。OutputStreamwriter
来传输回复...我切换到OutputStream
以确保Content-Type不具有字符集编码由Tomcat中的servlet容器“附加”。我有两个怀疑:
我希望有人可以为此指出正确的方向。干杯!