Reputation: 2311
I'm using google actions node.js SDK for my Google Action.
At some point, I'm showing users a carousel with a list of items:
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));
I get a response, and I managed to get the item code with
var itemKey = assistant.getContextArgument('actions_intent_option', 'OPTION');
Now I want to open a browser and redirect the user to the matching product page. How do I achieve this?
Upvotes: 1
Views: 1774
Reputation: 881
Google has recently introduced Browse carousel card for this feature.
The below will the message object format for browse carousel card.
"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"
}
]
}
Note that simple_response message is mandatory for this feature and number of items should be more than 2 and less than 10.
Upvotes: 1
Reputation: 653
If I understand what you were trying to do, I did something similar:
actions_intent_OPTION
const param = app.getSelectedOption()
Upvotes: 1
Reputation: 609
Currently, AoG doesn't support external link for Carousel or List, you can only keep a key for each item.
Though there is one way to handle that:
caro_link
) to the intent generating
carousel.actions_intent_OPTION
and input context caro_link
Upvotes: 2
Reputation: 2813
You could offer the user your URL with: https://developers.google.com/actions/reference/nodejs/RichResponse you should use: addSuggestionLink
However, you want first to make sure what is the surface (you get this info in the JSON obj) and return it only for the cases where there is screen.
Upvotes: 0