Basic Card不会显示在Google动作模拟器控制台中,也不会显示在使用Google Assistant的iPhone上
这是我发送的JSON代码:
{
"expectUserResponse": true,
"expectedInputs": [
{
"possibleIntents": [
{
"intent": "actions.intent.TEXT"
}
],
"inputPrompt": {
"richInitialPrompt": {
"items": [
{
"simpleResponse": {
"textToSpeech": "This is a basic card example."
}
},
{
"basicCard": {
"title": "Title: this is a title",
"subtitle": "This is a subtitle",
"formattedText": "This is a basic card. Text in a basic card can include \"quotes\" and\n most other unicode characters including emoji . Basic cards also support\n some markdown formatting like *emphasis* or _italics_, **strong** or\n __bold__, and ***bold itallic*** or ___strong emphasis___ as well as other\n things like line \nbreaks",
"image": {
"url": "https://example.com/image.png",
"accessibilityText": "Image alternate text"
},
"buttons": [
{
"title": "This is a button",
"openUrlAction": {
"url": "https://assistant.google.com/"
}
}
],
"imageDisplayOptions": "CROPPED"
}
}
]
}
}
}
]
}
这是我在模拟器中以及使用Google助手在iPhone上获得的内容:
[object Object]
模拟器中的调试返回:
{
"response": "[object Object]",
"expectUserResponse": true,
"conversationToken": "EroCS2w1Tm...",
"audioResponse": "//NExAAAAA...",
"ssmlMarkList": [],
"debugInfo": {
"assistantToAgentDebug": {
"curlCommand": "curl -v https://88.176.64.72:8081/ -H 'Content-Type: application/json;charset=UTF-8' -H 'Google-Actions-API-Version: 2' -H 'Authorization: eyJhbGciOiJSUzI1NiIsImtpZCI6IjM3ODJkM2YwYmM4OTAwOGQ5ZDJjMDE3MzBmNzY1Y2ZiMTlkM2I3MGUiLCJ0eXAiOiJKV1QifQ.eyJpc3MiOiJodHRwczovL2FjY291bnRzLmdvb2dsZS5jb20iLCJhdWQiOiJteS10ZXN0LWFwcC1kMTNkZSIsIm5iZiI6MTU1NTI3NTE2OCwiaWF0IjoxNTU1Mjc1NDY4LCJleHAiOjE1NTUyNzU1ODgsImp0aSI6IjVhZWM0ZjAwNzJiNmNjMTcyMDlmZTdiMmJlZDhjZDRlZTI4ZjExYTIifQ.P-SnzkjiWcr-GubTRdT_juTUVAPBn9J6spSRHPqykwsBq3AppsHg2GNBzlDfwhAXbxZAogW-Mdr4k_U2E1cQMGu-fdGnrkkg4UmjGvYz8za5SGaN-OVx3TNYsoayGIgTFn01gmZOIZfI_33-OucZtFSQCHo82YEmK6ypz3kBq5_vGAjdu01cgYEHAXdT6c53LGSEoewhK4F2M-KphlSx3eFYj2yLWJFn7w9w-Yf3W1n5Rm9q9ZGFJ4vNKIZlX0_J-T-6HhB84OX6k9qJYZ8_1FXp6CS9bPOAo_Nid9k1OeONDIJcCwp1GnQTQB4dek77xybmUn5Qo4-ad1IOzHOkNA' -A 'Mozilla/5.0 (compatible; Google-Cloud-Functions/2.1; +http://www.google.com/bot.html)' -X POST -d '{\"user\":{\"userId\":\"ABwppHGZMM6CHA-JcPkrCzVpkgGv953hFvVdAGAEGOWQSETGxFO18zXyIbXrhHAlw63M9Gz7dKcFxn3fIGKd2sw\",\"locale\":\"fr-CA\",\"lastSeen\":\"2019-04-14T20:53:31Z\",\"userStorage\":\"{\\\"data\\\":{}}\"},\"conversation\":{\"conversationId\":\"ABwppHEJaVmbTFuCLu0rK3SBxm_bviFYhyoY6oIa8o3MNqI2gHalTVPumj9cetdIsmtbVlfU-vNhIxBGsYRmWvs\",\"type\":\"ACTIVE\",\"conversationToken\":\"{}\"},\"inputs\":[{\"intent\":\"actions.intent.TEXT\",\"rawInputs\":[{\"inputType\":\"KEYBOARD\",\"query\":\"image\"}],\"arguments\":[{\"name\":\"text\",\"rawText\":\"image\",\"textValue\":\"image\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.ACCOUNT_LINKING\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.WEB_BROWSER\"}]}],\"requestType\":\"SIMULATOR\"}'",
"assistantToAgentJson": "{\"user\":{\"userId\":\"ABwppHGZMM6CHA-JcPkrCzVpkgGv953hFvVdAGAEGOWQSETGxFO18zXyIbXrhHAlw63M9Gz7dKcFxn3fIGKd2sw\",\"locale\":\"fr-CA\",\"lastSeen\":\"2019-04-14T20:53:31Z\",\"userStorage\":\"{\\\"data\\\":{}}\"},\"conversation\":{\"conversationId\":\"ABwppHEJaVmbTFuCLu0rK3SBxm_bviFYhyoY6oIa8o3MNqI2gHalTVPumj9cetdIsmtbVlfU-vNhIxBGsYRmWvs\",\"type\":\"ACTIVE\",\"conversationToken\":\"{}\"},\"inputs\":[{\"intent\":\"actions.intent.TEXT\",\"rawInputs\":[{\"inputType\":\"KEYBOARD\",\"query\":\"image\"}],\"arguments\":[{\"name\":\"text\",\"rawText\":\"image\",\"textValue\":\"image\"}]}],\"surface\":{\"capabilities\":[{\"name\":\"actions.capability.MEDIA_RESPONSE_AUDIO\"},{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.WEB_BROWSER\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.ACCOUNT_LINKING\"}]},\"isInSandbox\":true,\"availableSurfaces\":[{\"capabilities\":[{\"name\":\"actions.capability.AUDIO_OUTPUT\"},{\"name\":\"actions.capability.SCREEN_OUTPUT\"},{\"name\":\"actions.capability.WEB_BROWSER\"}]}],\"requestType\":\"SIMULATOR\"}",
"delegatedRequest": {
"delegatedRequest": ""
}
},
"agentToAssistantDebug": {
"agentToAssistantJson": "{\"conversationToken\":\"{}\",\"expectUserResponse\":true,\"expectedInputs\":[{\"inputPrompt\":{\"initialPrompts\":[{\"textToSpeech\":\"[object Object]\"}],\"noInputPrompts\":[]},\"possibleIntents\":[{\"intent\":\"actions.intent.TEXT\"}]}]}",
"delegatedResponse": {
"delegatedResponse": ""
}
},
"sharedDebugInfoList": []
},
"visualResponse": {
"visualElementsList": [
{
"displayText": {
"content": "[object Object]"
}
}
],
"suggestionsList": [],
"agentLogoUrl": "https://www.gstatic.com/voice/opa/partner_icons/generic_3p_avatar.png",
"agentStyle": {
"primaryColor": "",
"fontFamily": "",
"borderRadius": 0,
"backgroundColor": "",
"backgroundImageUrl": ""
}
},
"clientError": 0,
"is3pResponse": true,
"clientOperationList": [
{
"operationType": 1,
"micUpdatePayLoad": {
"micMode": 1
}
}
],
"projectName": ""
}
为什么我没有得到正确的结果?
我使用Node-Red和google-action-contrib来建立ation-on-google和我的机器之间的链接。一切正常,我可以创建一个对话框,接收和发送句子...现在,我想发送一个BasicCard(因为似乎帽子是发送图像的正确方法,还有许多其他事情,例如按钮等) ...)
我在该论坛中放入了尽可能多的数据,并附带了文件(wireshark捕获,调试信息,代码): https://discourse.nodered.org/t/google-action-response-with-an-image-basic-card/10145/7
感谢您的帮助
答案 0 :(得分:0)
看起来您实际上并没有以JSON的形式发送JSON,而是已经构建了一个对象,并正在发送其toString
版本。这是由记录的响应部分提示的
"response": "[object Object]"
在没有看到用于发送响应的代码的情况下,很难进一步提供帮助。
答案 1 :(得分:0)
我假设您在操作中使用了示例代码。但是,除非您更改url字段,否则您的操作将找不到imageUrl和openUrlAction。
如果您使用实际(而非“ http://example.com”)链接更改网址字段,则您的应用将正确响应。
还要确保您已经添加了必要的类。
例如
// Option: enables the storage of selected rows
rowSelected(items){
console.log(items[0].name)
items.forEach(item => {
const selectedIds = this.selected.map(selectedItem => selectedItem.id);
// I guess you don't want twice the same item in your array
if (!selectedIds.includes(item.id) {
this.selected.push(item)
}
})
},