以编程方式将机器人 (ms-botbuilder) 添加到 MS Teams 团队/频道 [英] Add bot (ms-botbuilder) to the MS Teams Team/Channel programmatically

本文介绍了以编程方式将机器人 (ms-botbuilder) 添加到 MS Teams 团队/频道的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在寻找一种将机器人添加到该机器人刚刚创建的团队的方法.

I'm looking to find a way to add a bot to a team that this bot just created.

  1. 机器人能够通过 MS Graph 创建群组JS-SDK

graphClient.api("/groups").post({
            displayName: "Some Name",
            mailNickname: "Name without Spaces",
            description: "Some Description",
            visibility: "Private",
            groupTypes: ["Unified"],
            mailEnabled: true,
            securityEnabled: false,
            "members@odata.bind": members, // array of url strings of members
            "owners@odata.bind": owners,
        });

membersowners 代表用户的字符串数组:https://graph.microsoft.com/v1.0/users/{user-id}.通过 /users 搜索找到他们

members and owners arrays of strings representing users: https://graph.microsoft.com/v1.0/users/{user-id}. Found them via /users search

  1. 然后将一个团队添加到此组(来源:https://docs.microsoft.com/en-us/graph/api/team-put-teams?view=graph-rest-beta&tabs=javascript)这样的:
    graphClient.api(`/groups/${group-id}/team`).put({});
  2. 和频道 - graphClient.api(`/teams/${group-id}/channels`).post(channel);

找不到将机器人添加到刚刚创建的团队或频道的方法.也许有一种方法可以找到它 guid 或某种 app-id 并将其添加到组中?

Couldn't find a way to add the bot to the team or channel that was just created. Maybe there is a way to locate it guid or some kind of app-id and add it to the group?

推荐答案

所以请记住,Bot 不是普通用户,它是一个应用程序.因此,要将其添加到团队中,您将使用 将应用添加到团队 对 Graph 的操作.为此,您需要使用 列出 Microsoft Teams 应用目录中已发布的应用.

So remember that a Bot is not a regular user, it's an App. As a result, to add it to a Team, you would use the Add app to team operation against the Graph. To do so, you need to use the app Id from List the published apps from the Microsoft Teams app catalog.

执行此操作后,您的机器人就是整个团队的一部分,并且可以从任何频道访问.因此,在将机器人安装到团队后,您不需要将其本身添加到频道(您可以看到这一点,因为从频道"中删除机器人的唯一方法是从应用程序中删除它整个团队的标签).在这方面,它有点像用户——将用户添加到团队可以让他们访问所有频道.但是,如果您的应用也包含选项卡,则可以将选项卡自动添加到单个频道 - 请参阅 添加标签到频道.

Once you do this, your bot is part of the entire Team, and can be accessed from any Channel. As a result, you don't need to also add your bot to a Channel per se after installing it to the Team (you can see this because the only way to remove the bot from a "channel" is by removing it from the App tab for the entire Team). It's kind of like a user in this regard - adding the user to the Team gives them access to all channels. However, if your app includes a tab as well, the tab can be added automatically to an individual channel - see add tab to channel.

这篇关于以编程方式将机器人 (ms-botbuilder) 添加到 MS Teams 团队/频道的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆