我正在为我的 Google Action 使用 google actions node.js SDK。
在某些时候,我会向用户展示一个带有项目列表的轮播:
var responseText = utils.getResponseText(Response.BUY_PRODUCTS);
var items = self._getProductSuggestItems(); //each item has am item key
self.assistant.askWithCarousel(responseText, self.assistant.getIncomingCarousel().addItems(items));
我得到了回应,我设法得到了项目代码
var itemKey = assistant.getContextArgument('actions_intent_option', 'OPTION');
现在我想打开浏览器并将用户重定向到匹配的产品页面。我如何实现这一目标?
谷歌最近为此功能推出了浏览轮播卡。
下面是浏览轮播卡的消息对象格式。
"fulfillment": {
"speech": " Here is what we got for you.",
"messages": [
{
"type": "simple_response",
"platform": "google",
"textToSpeech": " Here is what we got for you."
},
{
"items": [
{
"description": "at price of Rs. 57,999",
"title": "Apple MacBook Air Core i5 5th Gen - (8 GB/128 GB SSD/Mac OS Sierra) MQD32HN/A A1466",
"footer": "Apple MacBook Air Core i5 5th Gen - (8 GB/128 GB SSD/Mac OS Sierra) MQD32HN/A A1466",
"image": {
"url": "https://rukminim1.flixcart.com/image/200/200/j4irlow0/computer/j/8/c/apple-na-notebook-original-imaevdrcvuksg2zv.jpeg?q=90",
"accessibilityText": "Apple MacBook Air Core i5 5th Gen - (8 GB/128 GB SSD/Mac OS Sierra) MQD32HN/A A1466"
},
"openUrlAction": {
"url": "https://dl.flipkart.com/dl/apple-macbook-air-core-i5-5th-gen-8-gb-128-gb-ssd-mac-os-sierra-mqd32hn-a/p/itmevcpqqhf6azn3?pid=COMEVCPQBXBDFJ8C&affid=HotDeals20&affExtParam2=pricee-desktop-search-21"
}
},
{
"description": "at price of Rs. 89,990",
"title": "Apple Macbook PRO MPXQ2/R2 Core i5 (6th Gen)/8 GB/128 GB/33.78 cm (13.3)/Mac OS)",
"footer": "Apple Macbook PRO MPXQ2/R2 Core i5 (6th Gen)/8 GB/128 GB/33.78 cm (13.3)/Mac OS)",
"image": {
"url": "https://assetscdn.paytm.com/images/catalog/product/L/LA/LAPAPPLE-MACBOOROSE73954D5B64792/1.jpg",
"accessibilityText": "Apple Macbook PRO MPXQ2/R2 Core i5 (6th Gen)/8 GB/128 GB/33.78 cm (13.3)/Mac OS)"
},
"openUrlAction": {
"url": "https://paytmmall.com/apple-macbook-pro-mpxq2-r2-core-i5-6th-gen-8-gb-128-gb-33-78-cm-13-3-mac-os-CMPLXLAPAPPLE-MACBOODUMM202563C836CCA-pdp?product_id=145129487&discoverability=online&src=grid&utm_source=NDTV&utm_medium=affiliate&utm_campaign=NDTV-recharge&utm_term=Gadget360"
}
},
{
"description": "at price of Rs. 105,185",
"title": "Apple MPXT2HN/A Core i5 (6th Gen)/8 GB/256 GB/33.78 cm (13.3)/Mac OS)",
"footer": "Apple MPXT2HN/A Core i5 (6th Gen)/8 GB/256 GB/33.78 cm (13.3)/Mac OS)",
"image": {
"url": "https://assetscdn.paytm.com/images/catalog/product/L/LA/LAPAPPLE-MPXT2HNAVK49295F2A396E0/1.jpg",
"accessibilityText": "Apple MPXT2HN/A Core i5 (6th Gen)/8 GB/256 GB/33.78 cm (13.3)/Mac OS)"
},
"openUrlAction": {
"url": "https://paytmmall.com/apple-mpxt2hn-a-core-i5-6th-gen-8-gb-256-gb-33-78-cm-13-3-mac-os-CMPLXLAPAPPLE-MPXT2HE-HU224691C3146BBC-pdp?product_id=145650181&discoverability=online&src=grid&utm_source=NDTV&utm_medium=affiliate&utm_campaign=NDTV-recharge&utm_term=Gadget360"
}
}
],
"platform": "google",
"type": "browse_carousel_card"
}
]
}
请注意,simple_response消息对于此功能是必需的,并且项目数应大于 2 且小于 10。
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句