【问题标题】:Google Actions - Open Link from carouselGoogle Actions - 从轮播中打开链接
【发布时间】:2017-07-29 19:20:22
【问题描述】:

我正在为我的 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');

现在我想打开浏览器并将用户重定向到匹配的产品页面。 我如何实现这一目标?

【问题讨论】:

    标签: carousel dialogflow-es actions-on-google google-home


    【解决方案1】:

    目前,AoG 不支持 Carousel 或 List 的外部链接, 您只能为每个项目保留一个密钥。

    虽然有一种处理方法:

    • 将输出上下文(例如,caro_link)添加到意图生成中 轮播。
    • 使用事件 actions_intent_OPTION输入上下文 caro_link 制作后备意图
    • 现在,使用后备意图,检查从轮播中传递的 key 并使用 card 或SuggestionLink 或其他方式返回您的产品链接。

    【讨论】:

    • 这非常接近我现在所发现的,我也觉得你目前无法真正做到这一点。问题是它需要两次点击而不是一次(点击轮播项目->点击建议)。您希望只需单击一下即可实现此目的。谢谢!
    • 是的,当然会有两次点击,但是如果谷歌不允许我们怎么办。我有一个类似的案例,我只是用这种方式实现的。
    【解决方案2】:

    Google 最近为此功能推出了浏览轮播卡片。

    Link

    下面将是浏览轮播卡片的消息对象格式。

    "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

    【讨论】:

      【解决方案3】:

      如果我理解你想要做什么,我做了类似的事情:

      1. 有生成轮播的意图
      2. 创建具有事件的意图:actions_intent_OPTION
      3. 此意图通过以下方式访问轮播: const param = app.getSelectedOption()
      4. 您创建了一张卡片,其中包含一个链接到该产品页面的按钮。

      【讨论】:

        【解决方案4】:

        您可以向用户提供您的 URL:https://developers.google.com/actions/reference/nodejs/RichResponse 您应该使用:addSuggestionLink

        但是,您首先要确定表面是什么(您在 JSON obj 中获取此信息)并仅在有屏幕的情况下返回它。

        【讨论】:

        • 我已经检查了表面。谢谢。我希望用户查看项目列表(带图片),然后单击产品并专门导航到该产品。建议链接是否会引用列表中的项目? (我怀疑不是)。
        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2014-05-16
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        相关资源
        最近更新 更多