Asp.net Microsoft团队:如何在没有机器人的情况下从外部应用程序向用户发送消息/卡
我们有一个外部ASP.NET 4.7应用程序(在Azure应用程序服务中),它应该将消息/卡片发送给团队中的一个特定用户(没有机器人) 我设法通过Connector/WebHook将卡发送到频道,但无法针对特定用户 我如何做/需要哪些服务 请尽量简单:-) 多谢各位 ========================== 更新:示例代码:Asp.net Microsoft团队:如何在没有机器人的情况下从外部应用程序向用户发送消息/卡,asp.net,api,webhooks,microsoft-teams,Asp.net,Api,Webhooks,Microsoft Teams,我们有一个外部ASP.NET 4.7应用程序(在Azure应用程序服务中),它应该将消息/卡片发送给团队中的一个特定用户(没有机器人) 我设法通过Connector/WebHook将卡发送到频道,但无法针对特定用户 我如何做/需要哪些服务 请尽量简单:-) 多谢各位 ========================== 更新:示例代码: Private Shared Sub SendToTeams(ChannelPath As AppSettingsKey, Card As TeamsCard)
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
Friend类TeamsCard
公共属性上下文为字符串=”https://schema.org/extensions"
公共属性类型为String=“MessageCard”
公共属性主题颜色为String=“ff6100”
公共财产标题为String=“title”
公共属性摘要为String=“summary”
公共属性文本为String=“text”
作为新名单的公共财产潜在行动(团队合作)
末级
朋友级团队合作
公共属性类型为String=“OpenUri”
公共属性名称为String=“ButtonText”
公共财产目标作为新列表(TeamsCardButtonTarget)
Public Sub New(文本作为字符串,URI作为字符串)
名称=文本
Add(带有{.uri=uri}的新TeamsCardButtonTarget)
端接头
末级
朋友级团队ScardButtoTarget
公共属性操作系统为String=“default”
公共属性uri为字符串=”https://google.com"
末级
目前,Office 365仅支持频道。这些用户不能向单个用户发送消息/卡
向Microsoft团队发送消息的唯一选项是使用 你能发布你当前的代码吗?是的,我已经发现了,但是仅仅为这个简单的任务构建一个机器人是非常过分的:-(