简体   繁体   English

在列表中获取更多项目的问题(谷歌上的操作)

[英]Issue of getting more items in List(Actions on google)

I am developing a shopping bot in that user will ask for the product and then i will be fetching the results from the database and the results will be more than 10 items.我正在开发一个购物机器人,该用户将要求该产品,然后我将从数据库中获取结果,结果将超过 10 个项目。 I know that the default items for the list is 10 items.我知道列表的默认项目是 10 个项目。 My question here is how to add a more button at the end of the list so that i can load more of the items into the list.我的问题是如何在列表末尾添加更多按钮,以便我可以将更多项目加载到列表中。

for(var p=0;p<=countforchunk;p++)
{
  items[p] = {
    optionInfo: {
      key: (p + 1).toString(),
      synonyms: temparray[p],
    },
    title: temparray[p],
    url: "https://www.google.com/imgres?imgurl=https%3A%2F%2Fcdn.pixabay.com%2Fphoto%2F2015%2F04%2F23%2F22%2F00%2Ftree-736885__340.jpg&imgrefurl=https%3A%2F%2Fpixabay.com%2Fimages%2Fsearch%2Fnature%2F&tbnid=_2JirDBiGzi3lM&vet=12ahUKEwi71YPNxdrnAhVJGbcAHVi_BdEQMygAegUIARCFAg..i&docid=Ba_eiczVaD9-zM&w=546&h=340&q=images&ved=2ahUKEwi71YPNxdrnAhVJGbcAHVi_BdEQMygAegUIARCFAg",
    image: new Image({
      url: imgarray1[p],
      alt: imgarray1[p]
    }),
  }
  conv.ask(new List({
    title: 'Search Results',
    items: items
  }));
  resolve();
}

在此处输入图片说明

Please help me out, Thanks.请帮帮我,谢谢。

You have to keep track of loaded item.您必须跟踪加载的项目。 There is limitation of loading 30 items at a time.一次加载 30 个项目有限制。

When user wants more item, you have handle that voice intent and can store current page index in context and based on that you can add another 30 items by replacing existing one.当用户想要更多项目时,您已经处理了该语音意图并可以在上下文中存储当前页面索引,并基于此您可以通过替换现有项目来添加另外 30 个项目。

1-30 items = page 1 30-60 items = page 2 and so on. 1-30 项 = 第 1 页 30-60 项 = 第 2 页,依此类推。

Call an api accordingly.相应地调用 api。

As far as I can tell - there is no technical limit of 10 items.据我所知 - 没有 10 个项目的技术限制。 If you put 12 items in a list, for example, it will show 12 items.例如,如果您将 12 个项目放在一个列表中,它将显示 12 个项目。

This is not, however, a very good idea.然而,这不是一个很好的主意。 (Even 10 items is a lot, and you should be thinking about voice interaction, where you might not want to read back more than 2 or 3). (即使 10 个项目也很多,你应该考虑语音交互,你可能不想读超过 2 或 3 个)。 So at some point you will want to think about paging anyway.所以在某些时候你会想要考虑分页。

If you do, you need to implement this as another Intent and Intent Handler.如果这样做,则需要将其实现为另一个 Intent 和 Intent Handler。 You can do this by offering a suggestion chip that says "Show me more" and accepting training phrases such as "more", "what else", and "show me more" in the Intent.您可以通过在 Intent 中提供一个显示“给我更多”的建议芯片并接受诸如“更多”、“还有什么”和“给我更多”之类的训练短语来做到这一点。 You can use a Context to keep track of where you are in the result list.您可以使用上下文来跟踪您在结果列表中的位置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM