简体   繁体   English

是否可以从外部渠道向微软团队发送消息

[英]Is it possible to send messages to microsoft team from external channel

I have a MS teams bot .我有一个 MS 团队机器人。 Now, I need to introduce this to users.现在,我需要向用户介绍这一点。 So, the bot should be able to send messages to set of specific users introducing itself in Microsoft Teams .因此,机器人应该能够向在 Microsoft Teams 中介绍自己的一组特定用户发送消息。 I have list of people in database.我有数据库中的人员名单。 Now, is it possible to send messages to all of them in teams .现在,是否可以向团队中的所有人发送消息。 If yes, how?如果是,如何?

I haven't tried this, but presumably an Admin could install the app for the users.我还没有尝试过,但大概管理员可以为用户安装该应用程序。 At which point the bot should receive a conversationUpdate and the bot should be able to message the user in the event handler.此时,机器人应该收到一个conversationUpdate ,并且机器人应该能够在事件处理程序中向用户发送消息。

As @Abhijit-MSFT mentioned in comments, here is an example of using Graph to add an App for a user: https://github.com/microsoftgraph/contoso-airlines-teams-sample/blob/283523d45f5ce416111dfc34b8e49728b5012739/project/Models/GraphService.cs#L176正如@Abhijit-MSFT 在评论中提到的,以下是使用 Graph 为用户添加应用程序的示例: https : //github.com/microsoftgraph/contoso-airlines-teams-sample/blob/283523d45f5ce416111dfc34b8e49728b5012739/project/Models/ GraphService.cs#L176

        public async Task InstallAppToAllUsers()
        {
            string appid = "f46ad259-0fe5-4f12-872d-c737b174bcb4"; // Adobe

            var graph = GetAuthenticatedClient();
            var users = await graph.Users.Request().Select("id,displayName").GetAsync();
            foreach (User user in users)
            {
                if (user.DisplayName.StartsWith("Megan"))
                {
                    // Check if the app is already installed for that user.
                    // Use $expand to populate the teamsAppDefinition property,
                    // and $filter to search for the one app we care about
                    TeamsAppInstallation[] installs = await HttpGetList<TeamsAppInstallation>(
                        $"/users/{user.Id}/teamwork/installedApps?$expand=teamsAppDefinition&$filter=teamsAppDefinition/teamsAppId eq '{appid}'", 
                        endpoint: graphBetaEndpoint);
                    if (installs.Length == 0)
                    {
                        // install app
                        await HttpPost($"/users/{user.Id}/teamwork/installedApps",
                                new TeamsAppInstallation()
                                {
                                    AdditionalData = new Dictionary<string, object>() { ["teamsApp@odata.bind"] = $"{graphBetaEndpoint}/appCatalogs/teamsApps/{appid}" }
                                },
                                endpoint: graphBetaEndpoint);
                        // Bot will get a notification about the new user and the chat thread ID for that user
                    }

                    // If you've forgotten the chat thread ID for that user, you can find it again:
                    var chats = await HttpGetList<Chat>($"/users/{user.Id}/chats?$filter=installedApps/any(a:a/teamsApp/id eq '{appid}')", endpoint: graphBetaEndpoint);
                    string threadId = chats[0].Id;

                    // Wait a little before installing the next app to avoid throttling
                    Thread.Sleep(1000); 
                }
            }
        }

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何使用 Microsoft Graph API 在 Microsoft Team Channel 中发布带有附加图像的消息 - How to post messages in Microsoft Team Channel with an image as attached using Microsoft Graph API Microsoft Bot Framework-如何从团队渠道获取用户数据 - Microsoft Bot Framework - How to get user data from team channel 无法通过客户端凭据提供程序流在通道中发送消息 - Microsoft Graph API - Can't send messages in Channel through Client credentials provider flow - Microsoft Graph API 使用外部数据库中的数据向 Microsoft Teams 发送卡片 - Send a card to microsoft Teams with data from external database 阅读 Microsoft Teams 频道消息(Microsoft graph API、C#) - Read Microsoft Teams channel messages (Microsoft graph API, C#) 使用 Microsoft Graph 将消息发送到团队频道时出现问题 - Problem to send message to teams channel with Microsoft graph 将频道添加到 Microsoft Team 时出现问题(C# 代码,将频道类型转换为界面) - Problem with add channel to Microsoft Team (C# code, cast channel type to interface) 如何从频道检索消息列表 - How to retrieve a list of messages from a channel 如何使用 csharp 向 Microsoft Teams 频道发送简单消息? - How to send simple message to Microsoft Teams channel using csharp? 使用Microsoft Bot Framework V4主动向Microsoft Teams中的团队聊天发送消息 - Proactively send message to a Team chat in Microsoft Teams using Microsoft Bot Framework V4
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM