Language

TeamsBotApplication Constructors

Definition

Overloads

Name Description
TeamsBotApplication(ApiClient, IHttpContextAccessor, ILogger<TeamsBotApplication>, TeamsBotApplicationOptions, TurnStateLoader)

Initializes a new TeamsBotApplication without a file downloader.

Preserves the exact signature shipped in 2.1.0. C# bakes optional arguments into the CALLER, so an assembly compiled against 2.1.0 emits a call to this five-parameter form. Without it that call resolves to nothing at runtime and throws MissingMethodException, which recompiling the consuming app cannot fix when the offending IL is inside a third-party library built against the older version.

Hidden from IntelliSense because it is a compatibility shim rather than an API to choose. New code should use the constructor that accepts a file downloader.

TeamsBotApplication(ApiClient, IHttpContextAccessor, ILogger<TeamsBotApplication>, TeamsBotApplicationOptions, TurnStateLoader, FileDownloader)

Initializes a new TeamsBotApplication.

TeamsBotApplication(ApiClient, IHttpContextAccessor, ILogger<TeamsBotApplication>, TeamsBotApplicationOptions, TurnStateLoader)

Initializes a new TeamsBotApplication without a file downloader.

Preserves the exact signature shipped in 2.1.0. C# bakes optional arguments into the CALLER, so an assembly compiled against 2.1.0 emits a call to this five-parameter form. Without it that call resolves to nothing at runtime and throws MissingMethodException, which recompiling the consuming app cannot fix when the offending IL is inside a third-party library built against the older version.

Hidden from IntelliSense because it is a compatibility shim rather than an API to choose. New code should use the constructor that accepts a file downloader.

public TeamsBotApplication(Microsoft.Teams.Apps.Clients.ApiClient teamsApiClient, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor, Microsoft.Extensions.Logging.ILogger<Microsoft.Teams.Apps.TeamsBotApplication> logger, Microsoft.Teams.Apps.TeamsBotApplicationOptions? options, Microsoft.Teams.Apps.State.TurnStateLoader? stateLoader);
new Microsoft.Teams.Apps.TeamsBotApplication : Microsoft.Teams.Apps.Clients.ApiClient * Microsoft.AspNetCore.Http.IHttpContextAccessor * Microsoft.Extensions.Logging.ILogger<Microsoft.Teams.Apps.TeamsBotApplication> * Microsoft.Teams.Apps.TeamsBotApplicationOptions * Microsoft.Teams.Apps.State.TurnStateLoader -> Microsoft.Teams.Apps.TeamsBotApplication
Public Sub New (teamsApiClient As ApiClient, httpContextAccessor As IHttpContextAccessor, logger As ILogger(Of TeamsBotApplication), options As TeamsBotApplicationOptions, stateLoader As TurnStateLoader)

Parameters

teamsApiClient
ApiClient

The Teams API facade. Also carries the underlying Core conversation and user-token clients.

httpContextAccessor
IHttpContextAccessor

Accessor used to write invoke responses back to the current HTTP request.

logger
ILogger<TeamsBotApplication>

Logger used by the bot and exposed as Log.

options
TeamsBotApplicationOptions

Optional Teams bot options (AppId, OAuth flows, etc.).

stateLoader
TurnStateLoader

Optional state loader for per-turn state management. Injected automatically when UseState() is configured.

Examples

public class MyBot : TeamsBotApplication
{
    public MyBot(ApiClient api, IHttpContextAccessor accessor, ILogger<MyBot> logger, TeamsBotApplicationOptions? options = null)
        : base(api, accessor, logger, options)
    {
        this.OnMessage(async (ctx, ct) =>
            await ctx.SendAsync("Hello!", ct));
    }
}

Applies to

TeamsBotApplication(ApiClient, IHttpContextAccessor, ILogger<TeamsBotApplication>, TeamsBotApplicationOptions, TurnStateLoader, FileDownloader)

Initializes a new TeamsBotApplication.

public TeamsBotApplication(Microsoft.Teams.Apps.Clients.ApiClient teamsApiClient, Microsoft.AspNetCore.Http.IHttpContextAccessor httpContextAccessor, Microsoft.Extensions.Logging.ILogger<Microsoft.Teams.Apps.TeamsBotApplication> logger, Microsoft.Teams.Apps.TeamsBotApplicationOptions? options = default, Microsoft.Teams.Apps.State.TurnStateLoader? stateLoader = default, Microsoft.Teams.Apps.Files.FileDownloader? fileDownloader = default);
new Microsoft.Teams.Apps.TeamsBotApplication : Microsoft.Teams.Apps.Clients.ApiClient * Microsoft.AspNetCore.Http.IHttpContextAccessor * Microsoft.Extensions.Logging.ILogger<Microsoft.Teams.Apps.TeamsBotApplication> * Microsoft.Teams.Apps.TeamsBotApplicationOptions * Microsoft.Teams.Apps.State.TurnStateLoader * Microsoft.Teams.Apps.Files.FileDownloader -> Microsoft.Teams.Apps.TeamsBotApplication
Public Sub New (teamsApiClient As ApiClient, httpContextAccessor As IHttpContextAccessor, logger As ILogger(Of TeamsBotApplication), Optional options As TeamsBotApplicationOptions = Nothing, Optional stateLoader As TurnStateLoader = Nothing, Optional fileDownloader As FileDownloader = Nothing)

Parameters

teamsApiClient
ApiClient

The Teams API facade. Also carries the underlying Core conversation and user-token clients.

httpContextAccessor
IHttpContextAccessor

Accessor used to write invoke responses back to the current HTTP request.

logger
ILogger<TeamsBotApplication>

Logger used by the bot and exposed as Log.

options
TeamsBotApplicationOptions

Optional Teams bot options (AppId, OAuth flows, etc.).

stateLoader
TurnStateLoader

Optional state loader for per-turn state management. Injected automatically when UseState() is configured.

fileDownloader
FileDownloader

Optional downloader used to fetch inbound file bytes. Injected automatically by the hosting extensions.

Examples

public class MyBot : TeamsBotApplication
{
    public MyBot(ApiClient api, IHttpContextAccessor accessor, ILogger<MyBot> logger, TeamsBotApplicationOptions? options = null)
        : base(api, accessor, logger, options)
    {
        this.OnMessage(async (ctx, ct) =>
            await ctx.SendAsync("Hello!", ct));
    }
}

Applies to