在自适应卡片中提及 Teams 标签

问题描述 投票:0回答:2

使用机器人框架,我尝试在自适应卡片文本块中提及 Teams 标签。通过电子邮件提及用户可以按预期进行。当我尝试通过 ID 提及标签时,它不起作用,也不会导致提及。

除非标签实体的格式必须不同,否则我看不到我在这里做错了什么。

请参阅下面我如何构建自适应卡(使用 AdaptiveCards NuGet 包)。

new AdaptiveCard(new AdaptiveSchemaVersion(1, 2))
{
    Body = new List<AdaptiveElement>
    {
        new AdaptiveTextBlock
        {
            Text = "Mention test: <at>mytag</at>"
        }
    },
    AdditionalProperties = new SerializableDictionary<string, object>()
    {
        {
            "msteams",
            new
            {
                width = "full", 
                entities = new []
                {
                    new Mention()
                    {
                        // Does work when a e-mail is mentioned, but not when I use a Teams tag ID
                        Mentioned = new ChannelAccount("[email protected]", "mytag"),
                        Text = "<at>mytag</at>"
                    }
                }
            }
        }
    }
};
c# botframework microsoft-teams
2个回答
0
投票

在撰写本文时,这是不可能的。我提交了请求此功能的反馈。

https://feedbackportal.microsoft.com/feedback/idea/daeb1976-f010-ee11-a81c-000d3a7a48db

我发现的一个解决方法是使用 Microsoft Graph API 请求标签中的成员列表。然后使用不可见的 TextBlock 在自适应卡中提及所有个人成员(通过电子邮件)。


0
投票

提及标签可以通过以下格式在自适应卡的 Bot 框架中使用。

enter image description here 这是自适应卡中标签的示例。将鼠标悬停在消息上时,组卡会显示详细信息。并且频道中提及的用户可以找到带有红色@标记的提及的消息。

主要变化是在附件中添加“msteams”来定义标签组。将用于在消息卡正文中定位标签。

{
    "type": "message",
    "attachments": [
        {
            "contentType": "application/vnd.microsoft.card.adaptive",
            "content": {
                "type": "AdaptiveCard",
                "version": "1.3",
                "body": [
                    {
                        "type": "TextBlock",
                        "text": "**And this mentions tag** <at>your tag name</at>!",
                        "size": "Medium",
                        "wrap": true
                    }
                ],
                "msteams": {
                    "entities": [
                        {
                            "type": "mention",
                            "text": "<at>your tag name</at>",
                            "mentioned": {
                                "id": "your tag GUID",
                                "name": "display string for the tag",
                                "type": "tag"
                            }
                        }
                    ]
                }
            }
        }
    ]
}
© www.soinside.com 2019 - 2024. All rights reserved.