Microsoft.Teams.Core 1.0.2

Prefix Reserved
dotnet add package Microsoft.Teams.Core --version 1.0.2
                    
NuGet\Install-Package Microsoft.Teams.Core -Version 1.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Microsoft.Teams.Core" Version="1.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Microsoft.Teams.Core" Version="1.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Microsoft.Teams.Core" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Microsoft.Teams.Core --version 1.0.2
                    
#r "nuget: Microsoft.Teams.Core, 1.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Microsoft.Teams.Core@1.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Microsoft.Teams.Core&version=1.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Microsoft.Teams.Core&version=1.0.2
                    
Install as a Cake Tool

Microsoft.Teams.Core

The foundational .NET library for building Microsoft Teams bots. It implements the Activity Protocol, providing the core bot application framework, conversation client, user token client, middleware pipeline, and support for both Bot and Agentic identities.

Key Features

  • Activity Processing — Receive, deserialize, and dispatch activities through a middleware pipeline
  • Conversation Client — Send, update, and delete activities; manage conversation members and metadata
  • User Token Client — OAuth token management, sign-in flows, and token exchange (SSO)
  • Middleware Pipeline — Extensible ITurnMiddleware chain for cross-cutting concerns
  • Flexible Authentication — Client secrets, managed identities (system/user-assigned), federated identities, and agentic (user-delegated) tokens via MSAL
  • Extensible Schema — Loose CoreActivity model with JsonExtensionData for channel-specific properties
  • AOT-Compatible — Source-generated JSON serialization via CoreActivityJsonContext

Installation

dotnet add package Microsoft.Teams.Core

Quick Start

Register Services & Map Endpoint

var builder = WebApplication.CreateBuilder(args);
builder.AddBotApplication();

var app = builder.Build();
var bot = app.UseBotApplication(); // maps POST /api/messages

bot.OnActivity = async (activity, ct) =>
{
    if (activity.Type == ActivityType.Message)
    {
        var reply = CoreActivity.CreateBuilder()
            .WithType(ActivityType.Message)
            .WithConversation(activity.Conversation)
            .WithServiceUrl(activity.ServiceUrl)
            .WithProperty("text", "Hello from the bot!")
            .Build();

        await bot.SendActivityAsync(reply, ct);
    }
};

app.Run();

Custom Bot Subclass

public class MyBot : BotApplication
{
    public MyBot(
        ConversationClient conversationClient,
        UserTokenClient tokenClient,
        ILogger<MyBot> logger)
        : base(conversationClient, tokenClient, logger)
    {
        OnActivity = HandleActivityAsync;
    }

    private async Task HandleActivityAsync(CoreActivity activity, CancellationToken ct)
    {
        // your logic here
    }
}

// Registration
builder.AddBotApplication<MyBot>();
var bot = app.UseBotApplication<MyBot>();

Middleware

public class LoggingMiddleware : ITurnMiddleware
{
    public async Task OnTurnAsync(
        BotApplication bot, CoreActivity activity, NextTurn next, CancellationToken ct)
    {
        Console.WriteLine($"Activity: {activity.Type} from {activity.From?.Name}");
        await next(ct);
    }
}

bot.UseMiddleware(new LoggingMiddleware());

Extensible Activity Schema

public class MyChannelData : ChannelData
{
    [JsonPropertyName("customField")]
    public string? CustomField { get; set; }
}

public class MyActivity : CoreActivity
{
    [JsonPropertyName("channelData")]
    public new MyChannelData? ChannelData { get; set; }
}

Configuration

Provide credentials via appsettings.json:

{
  "AzureAd": {
    "Instance": "https://login.microsoftonline.com/",
    "TenantId": "<your-tenant-id>",
    "ClientId": "<your-client-id>",
    "Scope": "https://api.botframework.com/.default",
    "ClientCredentials": [
      {
        "SourceType": "ClientSecret",
        "ClientSecret": "<your-secret>"
      }
    ]
  }
}

Or via environment variables:

AzureAd__TenantId=<your-tenant-id>
AzureAd__ClientId=<your-client-id>
AzureAd__ClientCredentials__0__SourceType=ClientSecret
AzureAd__ClientCredentials__0__ClientSecret=<your-secret>

When no MSAL configuration is provided, communication happens as anonymous REST calls, suitable for localhost testing.

Design Principles

  • Loose schemaCoreActivity contains only strictly required fields; additional fields are captured via JsonExtensionData
  • Simple serialization — No custom converters; standard System.Text.Json with source generation
  • Extensible schemaChannelData and ConversationAccount support extension properties; generics allow custom types
  • MSAL-based auth — Token acquisition built on top of Microsoft Identity Web
  • ASP.NET DI — All dependencies configured via IServiceCollection extensions, reusing the existing HttpClient factory
  • ILogger & IConfiguration — Standard .NET logging and configuration throughout

Main Types

Type Description
BotApplication Core entry point — processes HTTP requests, runs middleware, dispatches to handlers
ConversationClient HTTP client for Bot Framework conversation APIs (send, update, delete, members)
UserTokenClient HTTP client for Bot Framework Token Service (OAuth, SSO, sign-in)
CoreActivity Activity data model following the Activity Protocol specification
CoreActivityBuilder Fluent builder for constructing CoreActivity instances
ITurnMiddleware Interface for middleware in the activity processing pipeline
AgenticIdentity Represents user-delegated token acquisition identity
BotHandlerException Exception wrapper preserving the activity that caused the error
Product 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages (2)

Showing the top 2 NuGet packages that depend on Microsoft.Teams.Core:

Package Downloads
Microsoft.Teams.Apps

Create Microsoft Teams Bot Applications with ease.

Microsoft.Teams.Apps.BotBuilder

Bridge to support smooth migration from BotFramework SDK into Teams SDK.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.2 129 5/15/2026