Lizozom
Lizozom

Reputation: 2311

Google Actions - Open Link from carousel

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

Answers (4)

Lijo Abraham
Lijo Abraham

Reputation: 881

Google has recently introduced Browse carousel card for this feature.

Link

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

Antonio Cucciniello
Antonio Cucciniello

Reputation: 653

If I understand what you were trying to do, I did something similar:

  1. Have an intent to generate a carousel
  2. Create an intent that has an Event: actions_intent_OPTION
  3. This intent accesses the carousel through: const param = app.getSelectedOption()
  4. You create a card with a button that links to that product page.

Upvotes: 1

J Shubham
J Shubham

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:

  • Add an output context (say, caro_link) to the intent generating carousel.
  • Make a fallback intent with event actions_intent_OPTION and input context caro_link
  • Now, using fallback intent, check key passed from the carousel and return the link of your product using card or suggestionLink or whatever.

Upvotes: 2

Ido Green
Ido Green

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

Related Questions