Skip to content

frevds/BotBuilder-MicrosoftTeams-node

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

55 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

This functionality is moving into the core Bot Framework SDK

We are migrating the functionality of this SDK into the core Bot Framework SDK, and are targeting the 4.6 release (early November 2019). Please see our early example code for an early look at the new, improved, way easier to use, SDK!

Bot Builder SDK4 - Microsoft Teams Extensions

Build status

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!

Samples

Get started quickly with our samples:

This SDK allows you to easily...

  • 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!

Getting started

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 the TeamsContext 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}`);

Questions, bugs, feature requests, and contributions

Please review the information here.

Contributing

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.

About

BotBuilder v4 SDK extension for Microsoft Teams

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • TypeScript 97.6%
  • JavaScript 2.4%