【问题标题】:How to send a notification into Microsoft Teams activity feed from external source如何从外部源向 Microsoft Teams 活动源发送通知
【发布时间】:2019-05-03 13:52:50
【问题描述】:

有没有办法从外部来源向 Microsoft Teams 的 Activity Feed 发送通知?

我找到了this 链接,但似乎只有当用户将消息发布到频道时才会生成通知。

我们能否构建一个可以将通知推送到 Microsoft Teams 的Activity Feed 的服务?

【问题讨论】:

    标签: office365 botframework microsoft-teams


    【解决方案1】:

    要访问活动源,您需要使用Bot。此外,您可以仅针对 1:1 聊天对话中发送的消息/卡片发送通知。

    如果您的机器人将卡片/消息发布到频道中,如果用户关注了该频道,它们将自动显示在用户的供稿中。

    示例代码发送至Starting personal conversations

            var parameters = new ConversationParameters
            {
                Members = new ChannelAccount[] { new ChannelAccount(userId) },
                ChannelData = new TeamsChannelData
                {
                    Tenant = new TenantInfo(tenantId),
                    Notification = new NotificationInfo() { Alert = true }
                }
            };
    
             MicrosoftAppCredentials.TrustServiceUrl(serviceUrl, DateTime.MaxValue);
            var connectorClient = new ConnectorClient(new Uri(activity.ServiceUrl));
            var response = await connectorClient.Conversations.CreateConversationAsync(parameters);
    

    【讨论】:

    • 谢谢瓦吉德。我有一些问题 - 1. 您能否分享一个 Bot Framework API (C#) 的示例,我可以将“alert”属性设置为 true,如下面的链接所述? docs.microsoft.com/en-us/microsoftteams/platform/concepts/… 2. 我们可以从任何外部服务调用 Bot 并让它发布消息/卡片吗?
    • 是的,两者都可以。使用 C# 代码更新答案。您可以在不同的端点(如 api/SendProactive 消息)中调用此代码。
    • 谢谢瓦吉德。您能否分享我可以详细了解此代码的链接?一步一步的指南将不胜感激。特别是我需要了解这段代码中的userIdtenantIdserviceUrl是什么。
    • 这里是详细解释的链接:docs.microsoft.com/en-us/microsoftteams/platform/concepts/bots/…。在答案中也添加了相同的内容。
    • 谢谢瓦吉德。这很有帮助。接受你的回答。
    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2021-07-26
    相关资源
    最近更新 更多