如何在Microsoft Teams Webhook中添加可正常跳转的超链接
在Microsoft Teams Webhook中发送可正常点击的超链接
你的问题核心在于链接缺少完整协议头(http/https),部分场景还存在自适应卡片配置不规范的问题,以下是两种可行的解决方式:
一、普通文本消息(Markdown/HTML格式)
Teams Webhook支持Markdown和HTML格式的链接,但必须提供完整的URL(包含https://或http://),否则只会渲染样式无法跳转。
Markdown格式示例:
POST /webhookb2/path HTTP/1.1 Host: my.host.com Content-Type: application/json Content-Length: 72 { "text": "This is the [BBC](https://www.bbc.com)" }
HTML格式示例:
POST /webhookb2/path HTTP/1.1 Host: my.host.com Content-Type: application/json Content-Length: 82 { "text": "This is the <a href=\"https://www.bbc.com\">BBC</a>" }
二、自适应卡片(可点击链接的正确配置)
你之前的自适应卡片有两个问题:一是TextBlock默认是纯文本模式,未启用Markdown解析;二是URL缺少协议头。修正后的配置如下:
带Markdown链接的自适应卡片:
POST /webhookb2/path HTTP/1.1 Host: my.host.com Content-Type: application/json Content-Length: 610 { "type":"message", "attachments":[ { "contentType":"application/vnd.microsoft.card.adaptive", "contentUrl":null, "content":{ "$schema":"http://adaptivecards.io/schemas/adaptive-card.json", "type":"AdaptiveCard", "version":"1.2", "body":[ { "type": "TextBlock", "text": "This is the [BBC](https://www.bbc.com)", "markdown": true } ] } } ] }
按钮式跳转链接(更可靠的方式)
如果需要更明确的交互引导,推荐使用自适应卡片的Action.OpenUrl按钮,这是Teams中最稳定的跳转实现:
POST /webhookb2/path HTTP/1.1 Host: my.host.com Content-Type: application/json Content-Length: 700 { "type":"message", "attachments":[ { "contentType":"application/vnd.microsoft.card.adaptive", "contentUrl":null, "content":{ "$schema":"http://adaptivecards.io/schemas/adaptive-card.json", "type":"AdaptiveCard", "version":"1.2", "body":[ { "type": "TextBlock", "text": "This is the BBC" } ], "actions": [ { "type": "Action.OpenUrl", "title": "访问BBC官网", "url": "https://www.bbc.com" } ] } } ] }
核心注意事项
- 所有可跳转链接必须包含完整的
https://或http://协议头,Teams不会识别无协议的短链接; - 自适应卡片的TextBlock需要显式设置
markdown: true才能解析Markdown格式的内容; - 按钮式链接(Action.OpenUrl)是Teams自适应卡片中最推荐的跳转方式,兼容性和稳定性最佳。
内容的提问来源于stack exchange,提问作者runnerpaul
相关产品推荐
相关产品推荐

