在显示具有较大选择列表的自适应卡时(在botframework中),来自bot的大小限制(限制为262144字节)出现问题 [英] Issue with size limit (limit of 262144 bytes) from bot while displaying adaptive card with large choice list (in botframework)

查看:52
本文介绍了在显示具有较大选择列表的自适应卡时(在botframework中),来自bot的大小限制(限制为262144字节)出现问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的团队正在使用Microsoft bot框架开发聊天机器人,这是我们需要根据用户选择显示动态选择列表的要求.为此,我们需要使用API​​来获取自定义响应.请在下面找到响应示例.

  {项目":[{"val":{"Field1":"Hello World"},"_links":{自我":[{"href":"API_URL_FOR_THIS_OPTION"}]}},{"val":{"Field1":"Hi World";},"_links":{自我":[{"href":"API_URL_FOR_THIS_OPTION"}]}},],"_links":{自我":[{"href":"MAIN_API_URL"}]}} 

在这里,要在动态选择列表中显示的选项数量将等于项目数组的长度.以下代码用于将该响应转换为与自适应卡兼容的选择数组

  var arr1 = []for(var i = 0; i  

效果很好,但我遇到的大小限制约为250 Kb ,因为api响应的 items.length在某些情况下超过3000 .因此,在尝试将选择数组传递给自适应卡时,我收到以下错误:请求内容长度超过了262144字节的限制

问题:-

  1. 是否有任何方法可以增加大小限制,以容纳较大的 选择 数组,自适应卡?
  2. 是否有其他方法可以在Bot Framework中显示列表?

解决方案

如果您仍要使用卡片,则必须将选择分成多组,然后将其分配到单独的卡片中.

如果您使用的是简单的选择列表,则可能必须一次显示很多卡,因此最好使用轮播.您可以使用多个活动来显示多个轮播.如果您想拥有一个可以在单击其中一个卡片时禁用多个活动的库,则可能要表达对我即将推出的卡片库的支持: 解决方案

If you still want to use cards, you will have to split your choices into multiple sets and distribute them across separate cards.

If you're using a flat list of choices then you may have to display many cards at once, and it would be a good idea to use carousels for that. You can use multiple activities to display multiple carousels. If you're interested in having a library that can disable multiple activities for you when a card in one of them is clicked, you may want to voice your support for my upcoming cards library: https://github.com/BotBuilderCommunity/botbuilder-community-dotnet/issues/137

If you can categorize your choices, perhaps even just by the first letter of the title, then you may want to have the user select a category first and then select the actual choice from the smaller set within that category.

If you want to display each choice as a button, you could just use regular Bot Framework cards instead of Adaptive Cards. If you've ever tried a Web Chat sample then you may have noticed that MockBot displays its menu as a long list of cards with buttons. You could supposedly use suggested actions as well but it's generally not a good idea to display that many suggested actions at once.

Finally, you could just display all your choices as a numbered list so that the user could enter their choice as text.

这篇关于在显示具有较大选择列表的自适应卡时(在botframework中),来自bot的大小限制(限制为262144字节)出现问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆