以编程方式将Bot(ms-botbuilder)添加到MS Teams Team/Channel [英] Add bot (ms-botbuilder) to the MS Teams Team/Channel programmatically

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

问题描述

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

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

  1. 该机器人能够通过MS Graph创建组 JS-SDK
  1. Was able to create a group via MS Graph by the bot 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/zh-cn/graph/api/team-put-teams?view=graph-rest-beta&stabs=javascript ),如下所示:
    graphClient.api(`/groups/${group-id}/team`).put({});
  2. 和频道-graphClient.api(`/teams/${group-id}/channels`).post(channel);
  1. then added a team to this group (source: https://docs.microsoft.com/en-us/graph/api/team-put-teams?view=graph-rest-beta&tabs=javascript) like that:
    graphClient.api(`/groups/${group-id}/team`).put({});
  2. and channel - 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不是普通用户,它是一个应用程序.因此,要将其添加到团队中,您将使用

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.

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

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