This functionality has been moved into the core Bot Framework SDK. You should update your Bot Framework SDK to version 4.6 rather than using this SDK.
This SDK will be deprecated, and will not receive further updates.
The Microsoft Bot Builder SDK Teams Extensions allow bots built using Bot Builder SDK to consume Teams functionality easily. Review the documentation to get started!
Get started quickly with our samples:
- Sample bots here
- Fetch a list of channels in a team
- Fetch profile info about all members of a team
- Fetch tenant-id from an incoming message to bot
- Create 1:1 chat with a specific user
- Mention a specific user
- Consume various events like channel-created, team-renamed, etc.
- Accept messages only from specific tenants
- Write Compose Extensions
- and more!
-
This SDK is the extension of Bot Framework SDK 4, so you may start with the quickstart or the example for Azure Web app bot if you never have experience for it.
-
Once you've got your bot scaffolded out, install the Teams BotBuilder package:
npm install botbuilder-teams@4.0.0-beta1
- To extend your bot to support Microsoft Teams, add middleware to adapter:
// use Teams middleware
adapter.use(new teams.TeamsMiddleware());
- Now in the
onTurn
method of your bot, to do any Teams specific stuff, first grab theTeamsContext
as shown below:
import { TeamsContext } from 'botbuilder-teams';
export class Bot {
async onTurn(turnContext: TurnContext) {
const teamsCtx: TeamsContext = TeamsContext.from(ctx);
}
}
- And once you have
teamsContext
, you may utilize code autocomplete provided by Visual Studio Code to discover all the operations you can do. For instance, here's how you can fetch the list of channels in the team and fetch information about the team:
// Now fetch the Team ID, Channel ID, and Tenant ID off of the incoming activity
const incomingTeamId = teamsCtx.team.id;
const incomingChannelid = teamsCtx.channel.id;
const incomingTenantId = teamsCtx.tenant.id;
// Make an operation call to fetch the list of channels in the team, and print count of channels.
var channels = await teamsCtx.teamsConnectorClient.teams.fetchChannelList(incomingTeamId);
await turnContext.sendActivity(`You have ${channels.conversations.length} channels in this team`);
// Make an operation call to fetch details of the team where the activity was posted, and print it.
var teamInfo = await teamsCtx.teamsConnectorClient.teams.fetchTeamDetails(incomingTeamId);
await turnContext.sendActivity(`Name of this team is ${teamInfo.name} and group-id is ${teamInfo.aadGroupId}`);
Please review the information here.
This project has adopted the Microsoft Open Source Code of Conduct. For more information see the Code of Conduct FAQ or contact opencode@microsoft.com with any additional questions or comments.