Skip to main content

App Basics

The app is the main entry point for your agent. In Teams SDK for .NET 2.1 it is a TeamsBotApplication, built on top of a standard ASP.NET Core web application. You register it at startup with builder.Services.AddTeamsBotApplication() and expose it as your bot's HTTP endpoint with app.UseTeamsBotApplication() — see the quickstart or code basics for the full setup.

It is responsible for:

  1. Hosting and running the server (via ASP.NET Core / Kestrel)
  2. Serving incoming requests on /api/messages and routing them to your handlers
  3. Handling authentication for your agent to the Teams backend (via your AzureAd configuration)
  4. Providing helpful utilities which simplify interacting with the Teams platform (context.SendAsync, context.ReplyAsync, the API client, etc.)
  5. Letting you extend behavior with standard ASP.NET Core middleware and dependency injection

Core Components​

Hosting (ASP.NET Core)

  • Runs the web server (Kestrel) and exposes your bot at /api/messages
  • Managed with the standard host lifecycle (IHostApplicationLifetime for start/stop)

Activity Routing

  • Routes incoming activities to the appropriate typed handler (OnMessage, OnEvent, OnMembersAdded, OnInstall, …)

Turn Middleware

  • Cross-cutting logic that runs on every turn (logging, metrics, etc.)
  • Implement ITurnMiddleware and register it with teams.UseMiddleware(...)

Utilities

  • Convenience methods for interacting with Teams (context.SendAsync, context.ReplyAsync, context.TypingAsync, the context.Api client, and streaming)

Auth

  • Handles authenticating your agent with the Teams backend using your AzureAd configuration
  • Validates inbound tokens before any handler runs (see Trust Model)

Dependency Injection

  • Register your own services in builder.Services and inject them into handlers and middleware, just like any ASP.NET Core app
SDK 2.0 (Legacy)

The SDK 2.0 model exposed the app as an App class with a plugin architecture — plugins sat both in front of the app (hosting it as a server) and behind it (reacting to activities being sent), and communicated through an event bus. The 2.1 removes plugins in favor of ASP.NET Core middleware and dependency injection. If you're upgrading from Bot Framework or 2.0 patterns, see the BotBuilder migration guide. The plugin-based model is still described below for the TypeScript and Python SDKs.