Microsoft.Teams.Apps
2.1.0
Prefix Reserved
dotnet add package Microsoft.Teams.Apps --version 2.1.0
NuGet\Install-Package Microsoft.Teams.Apps -Version 2.1.0
<PackageReference Include="Microsoft.Teams.Apps" Version="2.1.0" />
<PackageVersion Include="Microsoft.Teams.Apps" Version="2.1.0" />
<PackageReference Include="Microsoft.Teams.Apps" />
paket add Microsoft.Teams.Apps --version 2.1.0
#r "nuget: Microsoft.Teams.Apps, 2.1.0"
#:package Microsoft.Teams.Apps@2.1.0
#addin nuget:?package=Microsoft.Teams.Apps&version=2.1.0
#tool nuget:?package=Microsoft.Teams.Apps&version=2.1.0
Microsoft.Teams.Apps
A high-level framework for building Microsoft Teams bots in .NET. Built on top of Microsoft.Teams.Core, it provides Teams-specific activity types, a typed routing and handler system, OAuth authentication flows, Teams API clients, and streaming message support.
Key Features
- Typed Activity Routing — Register handlers for specific activity types (
OnMessage,OnAdaptiveCardAction,OnQuery, etc.) with type-safe contexts - Teams Activity Schema — Rich type hierarchy (
MessageActivity,InvokeActivity<T>,ConversationUpdateActivity, etc.) with polymorphic deserialization - OAuth Flows — Built-in SSO token exchange, sign-in cards, and token management via
OAuthFlow - Teams API Clients — Typed clients for conversations, members, teams, channels, meetings, and batch operations
- Streaming Messages — Progressive response updates via
TeamsStreamingWriter - Conversation Helpers — Send, reply, quote, and typing helpers for reactive and proactive messaging
- Turn State — Conversation and user state backed by
IDistributedCache - Targeted Messages — Send messages visible only to a selected participant in supported conversations
- Observability — OpenTelemetry spans, metrics, and Agent 365 baggage propagation
- Fluent Configuration — Chainable handler registration and options-based service configuration
Installation
dotnet add package Microsoft.Teams.Apps
Quick Start
using Microsoft.Teams.Apps;
var builder = WebApplication.CreateBuilder(args);
builder.Services.AddTeamsBotApplication();
var app = builder.Build();
var teams = app.UseTeamsBotApplication(); // maps POST /api/messages
teams.OnMessage(async (context, ct) =>
{
await context.SendAsync($"You said: {context.Activity.Text}", ct);
});
app.Run();
Handler Registration
Handlers are registered as extension methods on TeamsBotApplication and can be chained:
Messages
// All messages
teams.OnMessage(async (context, ct) => { ... });
// Regex pattern match
teams.OnMessage(@"^help$", async (context, ct) =>
{
await context.SendAsync("Here's how to use the bot...", ct);
});
Conversation Helpers
teams.OnMessage(async (context, ct) =>
{
await context.TypingAsync(ct);
await context.ReplyAsync("This reply quotes the incoming message.", ct);
await context.QuoteAsync(context.Activity.Id!, "Explicitly quoted reply.", ct);
});
Invoke Activities
// Adaptive card actions
teams.OnAdaptiveCardAction(async (context, ct) =>
{
var value = context.Activity.Value;
return AdaptiveCardResponse.CreateMessageResponse("Action received.");
});
// Message extension search
teams.OnQuery(async (context, ct) =>
{
var query = context.Activity.Value;
var searchText = query?.Parameters
.FirstOrDefault(parameter => parameter.Name == "queryText")?
.Value;
return MessageExtensionResponse.CreateBuilder()
.WithType(MessageExtensionResponseTypes.Message)
.WithText($"Searching for: {searchText}")
.Build();
});
// Task modules
teams.OnFetchTask(async (context, ct) => { ... });
teams.OnTaskSubmit(async (context, ct) => { ... });
// Link unfurling
teams.OnQueryLink(async (context, ct) => { ... });
Other message extension handlers include OnSubmitAction, OnSelectItem,
OnAnonQueryLink, OnQuerySettingUrl, OnSetting, and
OnCardButtonClicked.
State and OAuth
Enable distributed turn state and register OAuth flows when adding the application:
builder.Services.AddTeamsBotApplication(options =>
{
options.UseState();
options.AddOAuthFlow("graph");
});
UseState() uses an in-memory IDistributedCache by default. Register another
IDistributedCache implementation, such as Redis, for state that must survive
process restarts or be shared across instances.
Main Types
| Type | Description |
|---|---|
TeamsBotApplication |
Main entry point — extends BotApplication with Teams-specific routing and features |
Context<TActivity> |
Per-turn context providing typed activity access, API clients, and helper methods |
TeamsActivity |
Base Teams activity with polymorphic deserialization into specific subtypes |
MessageActivity |
Text and attachment messages |
InvokeActivity<T> |
Invoke operations (adaptive cards, task modules, message extensions) |
ConversationUpdateActivity |
Membership, channel, and team lifecycle events |
OAuthFlow |
OAuth sign-in, token exchange (SSO), and sign-out management |
ApiClient |
Facade for Teams conversation, member, team, meeting, and bot APIs |
TeamsStreamingWriter |
Progressive message streaming with rate limiting |
MessageActivityInput |
Fluent outbound message model for text, cards, mentions, citations, and actions |
TurnStateContainer |
Per-turn access to conversation and user state |
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 is compatible. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
-
net10.0
- Microsoft.Teams.Core (>= 2.1.0)
- OpenTelemetry.Api (>= 1.15.3)
-
net8.0
- Microsoft.Teams.Core (>= 2.1.0)
- OpenTelemetry.Api (>= 1.15.3)
NuGet packages (10)
Showing the top 5 NuGet packages that depend on Microsoft.Teams.Apps:
| Package | Downloads |
|---|---|
|
Microsoft.Teams.Extensions.Configuration
Teams Configuration Extensions |
|
|
Microsoft.Teams.Extensions.Hosting
Teams Hosting Extensions |
|
|
Microsoft.Teams.Plugins.AspNetCore
Teams AspNetCore Plugin |
|
|
Microsoft.Teams.Plugins.AspNetCore.BotBuilder
Teams AspNetCore BotBuilder Plugin |
|
|
Microsoft.Teams.Plugins.AspNetCore.DevTools
[DEPRECATED] Teams AspNetCore DevTools Plugin. Use Microsoft 365 Agents Playground instead. |
GitHub repositories
This package is not used by any popular GitHub repositories.
| Version | Downloads | Last Updated |
|---|---|---|
| 2.1.0 | 5,361 | 8/3/2026 |
| 2.1.0-preview-0011 | 253 | 7/13/2026 |
| 2.1.0-preview-0010 | 110 | 7/7/2026 |
| 2.1.0-preview-0009 | 111 | 6/30/2026 |
| 2.1.0-preview-0008 | 128 | 6/26/2026 |
| 2.1.0-preview-0007 | 150 | 6/5/2026 |
| 2.1.0-preview-0006 | 115 | 5/28/2026 |
| 2.1.0-preview-0002 | 162 | 5/15/2026 |
| 2.0.9 | 11,329 | 6/5/2026 |
| 2.0.8 | 3,376 | 5/28/2026 |
| 2.0.7 | 7,050 | 5/15/2026 |
| 2.0.6 | 10,123 | 4/2/2026 |
| 2.0.6-preview-0046-g482dcafac4 | 268 | 4/2/2026 |
| 2.0.6-preview-0014 | 427 | 3/11/2026 |
| 2.0.6-preview-0010 | 293 | 2/25/2026 |
| 2.0.5 | 21,489 | 12/10/2025 |
| 2.0.4 | 2,287 | 11/11/2025 |
| 2.0.3 | 1,659 | 10/16/2025 |
| 2.0.2 | 2,378 | 9/30/2025 |
| 2.0.1 | 800 | 9/26/2025 |