The API Client
BotBuilder exposes a static class TeamsInfo that allows you to query the api. In Teams SDK
we pass an instance of our ApiClient into all our activity handlers through the context.
tip
The Teams SDK ApiClient uses a fluent API pattern that makes it easier to discover available methods through IDE autocompletion.
- Diff
- BotBuilder
- Teams SDK
- import {
- CloudAdapter,
- ConfigurationBotFrameworkAuthentication,
- TeamsInfo,
- } from 'botbuilder';
+ import { App } from '@microsoft/teams.apps';
- const auth = new ConfigurationBotFrameworkAuthentication(process.env);
- const adapter = new CloudAdapter(auth);
+ const app = new App();
- export class ActivityHandler extends TeamsActivityHandler {
- constructor() {
- super();
- this.onMessage(async (context) => {
- const members = await TeamsInfo.getMembers(context);
- });
- }
- }
+ app.on('message', async ({ api, activity }) => {
+ const members = await api.conversations.members(activity.conversation.id).get();
+ });
import {
CloudAdapter,
ConfigurationBotFrameworkAuthentication,
TeamsInfo,
} from 'botbuilder';
const auth = new ConfigurationBotFrameworkAuthentication(process.env);
const adapter = new CloudAdapter(auth);
export class ActivityHandler extends TeamsActivityHandler {
constructor() {
super();
this.onMessage(async (context) => {
const members = await TeamsInfo.getMembers(context);
});
}
}
import { App } from '@microsoft/teams.apps';
const app = new App();
app.on('message', async ({ api, activity }) => {
const members = await api.conversations.members(activity.conversation.id).get();
});
Mapping TeamsInfo APIs to Teams SDK ApiClient Methods​
The following table shows common BotBuilder TeamsInfo methods and their equivalent Teams SDK ApiClient methods:
| BotBuilder (TeamsInfo) | Teams SDK (ApiClient) |
|---|---|
TeamsInfo.getMember(context, userId) | api.conversations.members.getById(conversationId, userId) |
TeamsInfo.getTeamDetails(context, teamId) | api.teams.getById(teamId) |
TeamsInfo.getMeetingInfo(context, meetingId) | api.meetings.getById(meetingId) |
TeamsInfo.sendMessageToTeamsChannel(context, teamId, message) | api.conversations.create() then api.conversations.activities.create(conversationId, activity) |