我想通过JSON响应通过JSON响应向用户发送三张基本卡作为响应。那有什么办法吗?
PS
基本上,我想向用户显示三个call
,mail
和call on office
的按钮,但是由于基本卡仅显示一个链接,我认为可以显示多个按钮包含按钮的卡片!
这是我发送的回复。
{
"payload": {
"google": {
"expectUserResponse": "true",
"richResponse": {
"items": [{
"simpleResponse": {
"textToSpeech": "Here is the information of " + user_name
}
},
{
"basicCard": {
"title": name,
"subtitle": subtitle,
"image": {
"url": picture_url,
"accessibilityText": "Picture of " + name
},
"formattedText": msg,
"buttons": [{
"title": "Call " + user_name,
"openUrlAction": {
"url": "tel:+" + contact
if contact is not None
else "",
"androidApp": {
"packageName": "com.android.phone"
},
"versions": []
}
}
if contact is not None
else {
"title": "Send Mail to " + user_name,
"openUrlAction": {
"url": "mailto:" + email,
"androidApp": {
"packageName": "android.intent.extra.EMAIL"
},
"versions": []
}
},
{
"title": "Call on extention",
"openUrlAction": {
"url": "tel:+" + extension
if extension is not None
else "",
"androidApp": {
"packageName": "com.android.phone"
},
"versions": []
}
}
],
"imageDisplayOptions": "WHITE"
}
}
],
"suggestions": [{
"title": "Info of " + manager
if manager is not None
else ""
},
{
"title": "Info of " + hr_manager
if hr_manager is not None
else ""
}
]
}
}
}
}
答案 0 :(得分:4)
您不能发送多张卡片,尽管一张卡片上的按钮采用一个数组,但该数组中仅允许一个元素。
但是,您可以通过发送browsing carousel来执行类似的操作。这样一来,您就可以发送多个图块,这些图块包含标题,并且可能包含图像,正文和链接,其形式与卡上具有链接的形式相同。
一个问题是,我不确定该链接是否必须为http或https链接,或者不确定是否允许其他URL形式,但是请记住,并非所有可能支持链接的表面都支持电话。