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

在Teams中提交AdaptiveCard的Input.ChoiceSet后如何保留卡片文本?

在Teams提交AdaptiveCard的ChoiceSet后保留卡片内容的方法

要实现提交Input.ChoiceSet后保留原有卡片文本,核心是通过后端逻辑更新原频道消息,以下是两种可行方案:

方案1:替换原卡片为结果展示版

当用户点击Submit按钮后,你的后端会收到提交的选择数据。基于原卡片结构,将Input.ChoiceSet替换为显示已选结果的文本块,同时完整保留所有原有文本内容,再通过Microsoft Graph API替换原消息。这样所有成员看到的都是更新后的卡片,无需查看新版本。

修改后的示例卡片JSON:

{
"$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
"type": "AdaptiveCard",
"version": "1.0",
"body": [
    {
        "type": "TextBlock",
        "text": "Poll Request",
        "id": "Title",
        "spacing": "Medium",
        "horizontalAlignment": "Center",
        "size": "ExtraLarge",
        "weight": "Bolder",
        "color": "Accent"
    },
    {
        "type": "TextBlock",
        "text": "Neue Bayernmeldung für BR-Text",
        "id": "acHeaderTagLine",
        "separator": true
    },
    {
        "type": "TextBlock",
        "text": "Poll Header",
        "weight": "Bolder",
        "size": "ExtraLarge",
        "spacing": "None",
        "id": "acHeader"
    },
    {
        "type": "TextBlock",
        "text": "Hier steht die Meldung. ",
        "id": "acInstructions",
        "wrap": true
    },
    {
        "type": "TextBlock",
        "text": "Poll Question",
        "id": "acPollQuestion"
    },
    {
        "type": "TextBlock",
        "text": "已选择:Choice 1",
        "weight": "Bolder",
        "color": "Good"
    }
],
"actions": []
}

方案2:保留选择控件并展示结果

如果需要保留ChoiceSet供成员查看选项,可在提交后更新卡片时,添加已选结果文本块,并将ChoiceSet设为只读状态回显已选值,原有文本完全保留。

示例修改部分代码:

{
    "type": "TextBlock",
    "text": "已选择:Choice 2",
    "weight": "Bolder",
    "color": "Good",
    "spacing": "Small"
},
{
    "type": "Input.ChoiceSet",
    "placeholder": "Select from these choices",
    "choices": [
        {
            "title": "Choice 1",
            "value": "Choice 1"
        },
        {
            "title": "Choice 2",
            "value": "Choice 2"
        },
        {
            "title": "Choice 3",
            "value": "Choice 3"
        }
    ],
    "id": "acPollChoices",
    "style": "expanded",
    "isReadOnly": true,
    "value": "Choice 2"
}

关键注意事项

  • 必须通过后端处理提交事件,前端无法直接修改Teams频道消息
  • 应用需具备ChannelMessage.ReadWrite.All的Microsoft Graph API权限
  • 替换原消息后,所有成员看到的是同一版本,无需额外操作查看更新

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.07.12 10:43:24