![]() |
VOOZH | about |
dotnet add package Microsoft.Teams.Core --version 1.0.4
NuGet\Install-Package Microsoft.Teams.Core -Version 1.0.4
<PackageReference Include="Microsoft.Teams.Core" Version="1.0.4" />
<PackageVersion Include="Microsoft.Teams.Core" Version="1.0.4" />Directory.Packages.props
<PackageReference Include="Microsoft.Teams.Core" />Project file
paket add Microsoft.Teams.Core --version 1.0.4
#r "nuget: Microsoft.Teams.Core, 1.0.4"
#:package Microsoft.Teams.Core@1.0.4
#addin nuget:?package=Microsoft.Teams.Core&version=1.0.4Install as a Cake Addin
#tool nuget:?package=Microsoft.Teams.Core&version=1.0.4Install as a Cake Tool
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.
ITurnMiddleware chain for cross-cutting concernsCoreActivity model with JsonExtensionData for channel-specific propertiesCoreActivityJsonContextdotnet add package Microsoft.Teams.Core
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();
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>();
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());
public class MyChannelData : ChannelData
{
[JsonPropertyName("customField")]
public string? CustomField { get; set; }
}
public class MyActivity : CoreActivity
{
[JsonPropertyName("channelData")]
public new MyChannelData? ChannelData { get; set; }
}
Provide credentials via appsettings.json:
{
"AzureAd": {
"Instance": "https://login.microsoftonline.com/",
"TenantId": "<your-tenant-id>",
"ClientId": "<your-client-id>",
"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.
CoreActivity contains only strictly required fields; additional fields are captured via JsonExtensionDataSystem.Text.Json with source generationChannelData and ConversationAccount support extension properties; generics allow custom typesIServiceCollection extensions, reusing the existing HttpClient factory| 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 | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 net8.0 is compatible. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 is compatible. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
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. |
This package is not used by any popular GitHub repositories.