首页 > 解决方案 > 如何在类似于 Who bot 的 Teams bot 中构建具有滚动条的列表卡?

问题描述

我正在使用 .NET Core 开发 MS Teams 机器人。来自 Microsoft 的 Who bot 有这张带有滚动条的列表卡。

列表卡示例图片

我没有找到实现它的代码,就像我们有缩略图卡,英雄卡等。请提前帮助和感谢。

标签: .net-corebotframeworkchatbotmicrosoft-teams

解决方案


我认为您需要尝试使用列表卡。由于它是 json 卡,因此您需要将其作为附件发送。

 private static Attachment CreateListCardAttachment()
    {
        // combine path for cross platform support
        string[] paths = { ".", "Resources", "listCard.json" };
        var listCardJson = File.ReadAllText(Path.Combine(paths));

        var listCardAttachment = new Attachment()
        {
            ContentType = "application/vnd.microsoft.teams.card.list",
            Content = JsonConvert.DeserializeObject(listCardJson),
        };

        return listCardAttachment;
    }

请使用json 代码作为参考。


推荐阅读