Reputation: 79
I'm looking to find a way to add a bot to a team that this bot just created.
graphClient.api("/groups").post({
displayName: "Some Name",
mailNickname: "Name without Spaces",
description: "Some Description",
visibility: "Private",
groupTypes: ["Unified"],
mailEnabled: true,
securityEnabled: false,
"[email protected]": members, // array of url strings of members
"[email protected]": owners,
});
members
and owners
arrays of strings representing users:
https://graph.microsoft.com/v1.0/users/{user-id}
. Found them via /users
search
graphClient.api(`/groups/${group-id}/team`).put({});
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?
Upvotes: 1
Views: 1368
Reputation: 10804
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.
Upvotes: 2