1. 背景介绍
Teams Incoming webhooks 是 Teams与别的系统进行集成的一种重要方式
最近如果往Microsoft Teams的Incoming Webhook 发送一个信息,可能会收到如下提醒,
这个提醒信息意思是,后续我们可能不能继续用 Incoming Webhook Uri 往Microsoft Teams发送信息了。同时提供的建议是用Power Automate的方式来发送外部信息到Teams。
2.Teams Incoming webhook
这里简单介绍一下Teams Incoming webhook的使用,
2.1 配置 Webhook
打开一个 Teams Channel, 然后点击 More options,点击Manage channel
点击 Edit 按钮
点击 Incoming Webhook 旁边的 Configure按钮,
点击如下Create按钮创建一个 Incoming Webhook,
点击下图中的图标, 复制Webhook Uri,
2.2 使用 Webhook
有了上面创建的Incoming Webhook Uri, 我们就可以使用Postman给Webhook发送信息了,
Invoke-RestMethod -Method post -ContentType 'Application/Json' -Body '{"text":"Testing the Alerts endpoint."}' -Uri {Webhook Uri}
运行上面的PowerShell命令发送一个Post请求给Webhook Uri, 收到信息如下
这个就是前面提到的通知,按照建议需要用Power Automate来实现了
note, 试着用别的方式往Teams Webhook Uri发个信息,发现当前还能发过去,不过后续有可能也发送不过去了。
3.Power Automate replacement
以下是用Power Automate的方式来实现发送信息到Teams,
假定发送的信息还是adaptivecard
3.1 触发器
设置触发器 When a Teams webhook request is received,建议复制一下 HTTP POST URL
3.2 流程
利用 Power Automate的内置的Teams action, 往Teams Channel发送信息
3.3 测试工作流
3.3.1 Postman发送请求
这边使用Postman来发送一个adaptivecard 信息到上面的HTTP POST URL
note, 上面Post请求中的body部分是adaptive card 内容,可以使用微软提供的 adaptivecard designer 来制作。
3.3.2 查看工作流
查看Power Automate工作流 Run history,
发现adaptive card信息也被发送到了 Microsoft Teams的Chanel中,
4.总结
以上简单介绍了一下如何用Power Automate的方式往Microsoft Teams中发送信息,包括actionable message(adaptive cards)
Microsoft Teams正在进行的变更是
Retirement of Office 365 connectors within Microsoft Teams
本文如果哪里有错误的地方,麻烦告之,谢谢谢谢!