Add bot (ms-botbuilder) to the MS Teams Team/Channel programmatically

让人想犯罪 __ 提交于 2020-06-08 06:40:10

问题


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

  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,
        });

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

  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);

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?


回答1:


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.



来源:https://stackoverflow.com/questions/59796925/add-bot-ms-botbuilder-to-the-ms-teams-team-channel-programmatically

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!