由于我们公司统一使用Teams作为通讯工具,所以告警消息需要考虑Teams。一旦线上出现问题,需要调接口来发送Teams消息
注意:
该方法只能发送到对应的团队频道,而不能实现发送到个人或者是聊天群
参考文档:
https://docs.microsoft.com/zh-cn/outlook/actionable-messages/send-via-connectors
步骤:
输入名称和上传好图像之后,点击创建,会生成一个URL
上面创建好了之后,会生成URL,复制这个URL到postman,选择POST方式,Headers为:Content-Type:application/json
Body为:
{
"@type": "MessageCard",
"@context": "https://schema.org/extensions",
"summary": "This is the summary property",
"themeColor": "0075FF",
"sections": [
{
"heroImage": {
"image": "https://messagecardplayground.azurewebsites.net/assets/FlowLogo.png"
}
},
{
"startGroup": true,
"title": "**告警消息**",
"facts": [
{
"name": "IP地址:",
"value": "192.168.1.1"
},
{
"name": "时间:",
"value": "2019.07.13 15:58:31"
},
{
"name": "报错信息:",
"value": "Uncaught Error Class Memcached not found in Memcachedchen.class.php:20"
},
{
"name": "链接:",
"value": "[查看更多报错信息](https://www.baidu.com)"
}
]
},
{
"potentialAction": [
{
"@type": "ActionCard",
"name": "点击处理",
"inputs": [
{
"@type": "TextInput",
"id": "comment",
"isMultiline": true,
"title": "备注"
}
],
"actions": [
{
"@type": "HttpPOST",
"name": "保存",
"target": "http://..."
}
]
},
{
"@type": "ActionCard",
"name": "取消",
"inputs": [
{
"@type": "TextInput",
"id": "comment",
"isMultiline": true,
"title": "取消原因"
}
],
"actions": [
{
"@type": "HttpPOST",
"name": "保存",
"target": "http://..."
}
]
}
]
},
{
"startGroup": true,
"activitySubtitle": "Grant approvals directly from your mobile device with the Microsoft Flow app. [Learn more](https://learnmode)\n\nThis message was created by an automated workflow in Microsoft Flow. Do not reply."
}
]
}
点击处理按钮或者是取消按钮,会进行原因和备注的编写,并且调用指定的链接:
另外,消息格式有很多,具体可以参考:
https://messagecardplayground.azurewebsites.net/