Azure Logic App中Teams自适应卡片响应未记录的问题求助
问题:Teams自适应卡片响应未在Azure Logic App中记录,无法获取输入文本
问题描述
尝试从Teams自适应卡片中获取用户输入文本并在Azure Logic App中使用,但卡片提交后,响应数据并未被Logic App记录。以下是当前使用的自适应卡片配置:
{ "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "actions": [ { "id": "Yes", "title": "Create Ticket", "type": "Action.Submit" }, { "style": "positive", "title": "View in SentinelOne Portal", "type": "Action.OpenUrl", "url": "@{replace(outputs('URL'), '[', '')}" } ], "body": [ { "size": "Large", "text": "@{triggerBody()?['subject']}", "type": "TextBlock", "wrap": true }, { "items": [ { "text": "@{outputs('Compose_9')}", "type": "TextBlock", "wrap": true } ], "type": "Container" }, { "type": "TextBlock", "text": "Ticket Info", "wrap": true } ], "msteams": { "width": "Full" }, "type": "AdaptiveCard", "version": "1.5", "verticalContentAlignment": "Top" }
解决方案
1. 补充输入控件(核心问题)
当前卡片仅包含文本展示组件,没有任何用于用户输入文本的控件(如Input.Text),导致用户无法输入内容,Logic App自然接收不到输入数据。需要在卡片的body中添加输入控件,并为每个控件设置唯一id,提交时这些控件的值会被自动携带。
修改后的自适应卡片示例:
{ "$schema": "http://adaptivecards.io/schemas/adaptive-card.json", "actions": [ { "id": "Yes", "title": "Create Ticket", "type": "Action.Submit", // 可选:携带固定上下文数据,比如动作标识 "data": { "actionType": "createTicket" } }, { "style": "positive", "title": "View in SentinelOne Portal", "type": "Action.OpenUrl", "url": "@{replace(outputs('URL'), '[', '')}" } ], "body": [ { "size": "Large", "text": "@{triggerBody()?['subject']}", "type": "TextBlock", "wrap": true }, { "items": [ { "text": "@{outputs('Compose_9')}", "type": "TextBlock", "wrap": true } ], "type": "Container" }, { "type": "TextBlock", "text": "Ticket Info", "wrap": true }, // 添加多行输入框用于工单描述 { "type": "Input.Text", "id": "ticketDesc", "placeholder": "请输入工单详细描述", "isMultiline": true, "wrap": true }, // 添加单行输入框用于优先级 { "type": "Input.Text", "id": "ticketPriority", "placeholder": "请输入工单优先级(高/中/低)" } ], "msteams": { "width": "Full" }, "type": "AdaptiveCard", "version": "1.5", "verticalContentAlignment": "Top" }
2. 在Logic App中接收提交数据
确保Logic App使用Microsoft Teams连接器的「When a message is received in a chat or channel (V3)」触发器,提交卡片后,触发器的Body中会包含data对象,里面存储着输入控件的id和对应值。
可以通过以下表达式获取数据:
- 工单描述:
triggerBody()?['data']?['ticketDesc'] - 工单优先级:
triggerBody()?['data']?['ticketPriority'] - 动作标识:
triggerBody()?['data']?['actionType']
建议添加一个「Compose」操作,将上述表达式的值输出,验证是否成功接收到数据。
3. 额外检查项
- 确认自适应卡片版本(1.5)与Teams客户端兼容;
- 检查Logic App触发器的权限,确保能读取Teams聊天/频道的消息;
- 查看Logic App运行历史,确认触发器是否被触发,以及
Body的数据结构是否符合预期。
内容的提问来源于stack exchange,提问作者Jeremy
相关产品推荐
相关产品推荐

