如何添加/添加轮播选择以对Google上的操作进行预览订购?

时间:2018-12-15 08:08:17

标签: javascript transactions dialogflow actions-on-google

我正在尝试在Google应用上执行一项操作,该操作将能够订购我想要的商品,以便能够将我从轮播中选择的所有商品添加到订单预览中。我遵循了Google针对“书店”操作提供的教程(我将在下面发布链接),但是我似乎找不到任何有关如何将轮播选择添加到您的订单预览中的教程或文档。

编辑具体来说,这是我要尝试的操作:

用户问:

"talk to my app"
>> "Welcome to the app!"
"I would like to order a coffee"
>> Okay, what would you like to order?
   * Carousel appears with different options
*User selects an option and that option gets added to the bill*
 >> Okay, are you ready to check out?
"Yes"

从那里,用户可以在订单预览/帐单上看到他或她刚刚从carosuel中选择的内容

我该怎么做?

感谢您的帮助!

链接here

1 个答案:

答案 0 :(得分:3)

以下是使用Node.js客户端库为Google Assistant创建浏览轮播的示例:

// Create a browse carousel
conv.ask(new BrowseCarousel({
  items: [
    new BrowseCarouselItem({
      title: 'Title of item 1',
      url: googleUrl,
      description: 'Description of item 1',
      image: new Image({
        url: IMG_URL_AOG,
        alt: a11yText,
      }),
      footer: 'Item 1 footer',
    }),
    new BrowseCarouselItem({
      title: 'Title of item 2',
      url: googleUrl,
      description: 'Description of item 2',
      image: new Image({
        url: IMG_URL_AOG,
        alt: a11yText,
      }),
      footer: 'Item 2 footer',
    }),
  ],
}));

此处的文档中有更多信息:https://developers.google.com/actions/assistant/responses#browsing_carousel

相关问题