You need to enable JavaScript to run this app.
优惠活动
大模型
产品
解决方案
定价
更多

Bot Framework机器人在MS Teams中无法显示缩略图卡片轮播

问题:Bot Framework缩略图卡片轮播在MS Teams中无法显示(Web Chat/模拟器正常)

我正在用Bot Framework开发机器人,想要在MS Teams里以轮播形式展示一组缩略图卡片。这个轮播在Web Chat和Bot模拟器里都能正常渲染,但到了MS Teams中就完全不显示。确认过轮播的实现方法已经被调用,机器人的其他功能都运行正常。

原实现代码

var reply = context.MakeMessage();
reply.AttachmentLayout = AttachmentLayoutTypes.Carousel;
List<Attachment> attachments = new List<Attachment>();
foreach (Models.Cars car in cars)
{
    Attachment att = new Attachment();
    List<CardAction> buttons = new List<CardAction>();
    CardAction button = new CardAction(ActionTypes.PostBack, "Show car", value : car.id);
    buttons.Add(button);
    var heroCard = new ThumbnailCard
    {
        Title = car.Title ?? "",
        Subtitle = car.Model ?? "2",
        Text = $"{car.Description}" ?? $"Text is not available for this car.",
        Images = null,
        Buttons = buttons
    };
    att = heroCard.ToAttachment();
    attachments.Add(att);
}
reply.Attachments = attachments;
await context.Wait(AfterIDInsert);

AfterIDInsert方法代码

private async Task AfterIDInsert(IDialogContext context, IAwaitable<IMessageActivity> result)
{
    var carid= await result;
    await showcar(context, carid.Text);
}

解决方案
感谢JasonSowers的解答,我找到了问题所在!显然MS Teams和其他测试渠道(比如Bot模拟器)相比,对CardAction的参数要求更严格,需要填写完整的参数项。

我参考JasonSowers的代码,修改了CardAction的实例化语句:

CardAction button = new CardAction(ActionTypes.PostBack,displayText:car.Title,title: "Show car", image: null, value: car.Id);

修改后,轮播卡片在MS Teams中就能正常显示了!

内容的提问来源于stack exchange,提问作者Kraishan

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.05.27 09:56:41