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

如何在Adaptive Cards的Body ColumnSet每行添加Action.Submit按钮

在Adaptive Card表格每行添加独立Action.Submit按钮的解决方案

我懂你现在的困扰——想给表格每一行都加专属的Action.Submit按钮,却发现直接塞到ColumnSet里行不通。其实核心问题是:Action类组件(比如Action.Submit)不能直接作为Column的items子元素,必须用ActionSet组件来包裹它,这样就能把按钮嵌入到表格行里了。

下面是调整后的完整Adaptive Card JSON示例,我把每行最后一列的Toggle替换成了带Action.Submit的ActionSet(你也可以保留Toggle,把按钮和它放在同一个Column里),并且给每个按钮添加了专属的行数据,方便后端识别是哪一行的操作:

{
  "$schema": "http://adaptivecards.io/schemas/adaptive-card.json",
  "type": "AdaptiveCard",
  "version": "1.0",
  "body": [
    {
      "type": "Container",
      "items": [
        {
          "type": "TextBlock",
          "text": "Pending Items",
          "weight": "bolder",
          "size": "medium"
        },
        {
          "type": "ColumnSet",
          "columns": [
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "Number",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "Module",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "Pending count",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "Action",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            }
          ]
        },
        {
          "type": "ColumnSet",
          "columns": [
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "1",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "Module 1",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "1",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "ActionSet",
                  "actions": [
                    {
                      "type": "Action.Submit",
                      "title": "Process",
                      "data": {
                        "rowNumber": "1",
                        "module": "Module 1",
                        "action": "process"
                      }
                    }
                  ]
                }
              ]
            }
          ]
        },
        {
          "type": "ColumnSet",
          "columns": [
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "2",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "Module 1",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "TextBlock",
                  "text": "10",
                  "weight": "bolder",
                  "wrap": true
                }
              ]
            },
            {
              "type": "Column",
              "width": "stretch",
              "items": [
                {
                  "type": "ActionSet",
                  "actions": [
                    {
                      "type": "Action.Submit",
                      "title": "Process",
                      "data": {
                        "rowNumber": "2",
                        "module": "Module 1",
                        "action": "process"
                      }
                    }
                  ]
                }
              ]
            }
          ]
        }
      ]
    }
  ],
  "actions": [
    {
      "type": "Action.ShowCard",
      "title": "Proceed Selected",
      "card": {
        "type": "AdaptiveCard",
        "body": [
          {
            "type": "TextBlock",
            "text": "Are you sure want to Proceed",
            "weight": "bolder",
            "wrap": true
          }
        ],
        "actions": [
          {
            "type": "Action.Submit",
            "title": "OK"
          }
        ]
      }
    },
    {
      "type": "Action.Submit",
      "title": "Cancel",
      "id": "c1"
    }
  ]
}

关键修改点说明:

  • 在每行的最后一列中添加了ActionSet组件,这是嵌入Action.Submit的必要容器
  • 每个Action.Submit的data字段携带了该行的专属信息,比如rowNumber和module,这样你的后端服务就能准确识别是哪一行的按钮被触发了
  • 如果需要保留原来的Input.Toggle,只需要把Toggle和ActionSet放在同一个Column的items数组里即可,两者可以共存

这样调整后,表格的每一行都会有自己独立的提交按钮,点击后会携带该行的特定数据发送给你的Bot,完美解决你的需求。

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

相关产品推荐
方舟 Agent Plan

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

最近更新时间:2026.05.29 08:25:22