asp.net - Microsoft Teams:如何在没有机器人的情况下从外部应用程序向用户发送消息/卡片
问题描述
我们有一个外部 ASP.NET 4.7 应用程序(在 Azure 应用程序服务中),它应该将消息/卡片发送给团队中的一个特定用户(没有机器人)。
我设法通过连接器/WebHook 将卡片发送到频道,但无法针对特定用户。
我该怎么做/需要哪些服务?
请尽可能简单:-)
谢谢你
===========================
更新:示例代码:
Private Shared Sub SendToTeams(ChannelPath As AppSettingsKey, Card As TeamsCard)
If String.IsNullOrWhiteSpace(ChannelPath) Then Return
Dim Channel = AppSettings.GetAppSetting(ChannelPath)
If String.IsNullOrWhiteSpace(Channel) Then Return
Dim ChannelWebHook = "https://outlook.office.com"
Dim Client = New RestClient(ChannelWebHook)
Dim Req = New RestRequest(Method.POST) With {
.Resource = Channel,
.RequestFormat = DataFormat.Json
}
Dim JSON = Card.SaveJSON(False)
Req.AddParameter("application/json; charset=utf-8", JSON, ParameterType.RequestBody)
Dim Erg = Client.Execute(Req)
Logger.Info("Teams:", Erg.StatusCode)
End Sub
还有一些助手:
Friend Class TeamsCard
<JsonProperty(PropertyName:="@context")> Public Property context As String = "https://schema.org/extensions"
<JsonProperty(PropertyName:="@type")> Public Property type As String = "MessageCard"
Public Property themeColor As String = "ff6100"
Public Property title As String = "Title"
Public Property summary As String = "Summary"
Public Property text As String = "Text"
Public Property potentialAction As New List(Of TeamsCardAction)
End Class
Friend Class TeamsCardAction
<JsonProperty(PropertyName:="@type")> Public Property type As String = "OpenUri"
Public Property name As String = "ButtonText"
Public Property targets As New List(Of TeamsCardButtonTarget)
Public Sub New(Text As String, URI As String)
name = Text
targets.Add(New TeamsCardButtonTarget With {.uri = URI})
End Sub
End Class
Friend Class TeamsCardButtonTarget
Public Property os As String = "default"
Public Property uri As String = "https://google.com"
End Class
解决方案
推荐阅读
- javascript - 使用 Karma 进行 ngOnInit 和 MediaChange 测试
- php - 无法使用矩阵打印文件夹的图像(.svg)
- python - Python基础树可视化
- mysql - Perl / DBI 查询不保留 JSON 输出的整数值
- python - 为 NumPy 数组中的每个唯一元素选择一个随机索引,并考虑参考数组中缺失的索引
- java - 将快线程归还给池,而不是等待慢线程
- perl - dancer2 需要什么 perl 版本?
- c++ - 编译中的示例 C++ 项目警告
- sql - 如何执行仅获取唯一列的 SELECT COUNT 语句?
- r - e1071 包中 predict.naiveBayes 方法源代码中函数的未知用法