Language

TeamsBotApplicationHostingExtensions.UseTeamsBotApplication Method

Definition

Overloads

Name Description
UseTeamsBotApplication(IHost)

Configures the default TeamsBotApplication on a host, using the transport chosen in AddTeamsBotApplication(IServiceCollection, Action<TeamsBotApplicationOptions>, String).

UseTeamsBotApplication(WebApplication, String)

Configures the default TeamsBotApplication to receive activities over HTTP on a web application.

UseTeamsBotApplication(IEndpointRouteBuilder, String)

Configures the default TeamsBotApplication to receive activities over HTTP on the endpoint route builder.

UseTeamsBotApplication<TApp>(IHost)

Configures a custom TApp on a host, using the transport chosen in AddTeamsBotApplication<TApp>(IServiceCollection, Action<TeamsBotApplicationOptions>, String).

UseTeamsBotApplication<TApp>(WebApplication, String)

Configures a custom TApp to receive activities over HTTP on a web application.

UseTeamsBotApplication<TApp>(IEndpointRouteBuilder, String)

Configures a custom TApp to receive activities over HTTP on the endpoint route builder.

UseTeamsBotApplication(IHost)

public static Microsoft.Teams.Apps.TeamsBotApplication UseTeamsBotApplication(this Microsoft.Extensions.Hosting.IHost host);
static member UseTeamsBotApplication : Microsoft.Extensions.Hosting.IHost -> Microsoft.Teams.Apps.TeamsBotApplication
<Extension()>
Public Function UseTeamsBotApplication (host As IHost) As TeamsBotApplication

Parameters

host
IHost

The built host.

Returns

The registered TeamsBotApplication instance.

Exceptions

Thrown when the host cannot use the chosen transport, or when the application is not registered.

Remarks

When Socket Mode is enabled with UseSocketMode(Boolean), the host must not include a web server, such as one built with Host.CreateApplicationBuilder(). The transport starts with the host, which does not finish starting until every geo is connected. Otherwise the host must also be an endpoint route builder, such as a WebApplication, and activities are received over HTTP at api/messages.

Applies to

UseTeamsBotApplication(WebApplication, String)

Configures the default TeamsBotApplication to receive activities over HTTP on a web application.

public static Microsoft.Teams.Apps.TeamsBotApplication UseTeamsBotApplication(this Microsoft.AspNetCore.Builder.WebApplication app, string routePath = "api/messages");
static member UseTeamsBotApplication : Microsoft.AspNetCore.Builder.WebApplication * string -> Microsoft.Teams.Apps.TeamsBotApplication
<Extension()>
Public Function UseTeamsBotApplication (app As WebApplication, Optional routePath As String = "api/messages") As TeamsBotApplication

Parameters

app
WebApplication

The web application.

routePath
String

The route path to listen on. Default is "api/messages".

Returns

The configured TeamsBotApplication instance.

Exceptions

Thrown when Socket Mode is enabled with UseSocketMode(Boolean).

Remarks

Receives activities at routePath. This overload exists so that a WebApplication, which is both an IHost and an IEndpointRouteBuilder, binds unambiguously. Socket Mode runs without a web server; build a Socket Mode bot with Host.CreateApplicationBuilder() and call UseTeamsBotApplication(IHost) instead.

Applies to

UseTeamsBotApplication(IEndpointRouteBuilder, String)

Configures the default TeamsBotApplication to receive activities over HTTP on the endpoint route builder.

public static Microsoft.Teams.Apps.TeamsBotApplication UseTeamsBotApplication(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string routePath = "api/messages");
static member UseTeamsBotApplication : Microsoft.AspNetCore.Routing.IEndpointRouteBuilder * string -> Microsoft.Teams.Apps.TeamsBotApplication
<Extension()>
Public Function UseTeamsBotApplication (endpoints As IEndpointRouteBuilder, Optional routePath As String = "api/messages") As TeamsBotApplication

Parameters

endpoints
IEndpointRouteBuilder

The endpoint route builder.

routePath
String

The route path to listen on. Default is "api/messages".

Returns

The configured TeamsBotApplication instance.

Exceptions

Thrown when Socket Mode is enabled.

Remarks

Use this overload to map the messaging endpoint on a route group or other endpoint builder. To receive activities over Socket Mode, enable it with UseSocketMode(Boolean) and call UseTeamsBotApplication(IHost) on a host without a web server.

Applies to

UseTeamsBotApplication<TApp>(IHost)

Configures a custom TApp on a host, using the transport chosen in AddTeamsBotApplication<TApp>(IServiceCollection, Action<TeamsBotApplicationOptions>, String).

public static TApp UseTeamsBotApplication<TApp>(this Microsoft.Extensions.Hosting.IHost host) where TApp : Microsoft.Teams.Apps.TeamsBotApplication;
static member UseTeamsBotApplication : Microsoft.Extensions.Hosting.IHost -> 'App (requires 'App :> Microsoft.Teams.Apps.TeamsBotApplication)
<Extension()>
Public Function UseTeamsBotApplication(Of TApp As TeamsBotApplication) (host As IHost) As TApp

Type Parameters

TApp

The custom TeamsBotApplication type.

Parameters

host
IHost

The built host.

Returns

TApp

The registered TApp instance.

Exceptions

Thrown when the host cannot use the chosen transport, or when the application is not registered.

Remarks

When Socket Mode is enabled with UseSocketMode(Boolean), the host must not include a web server, such as one built with Host.CreateApplicationBuilder(). The transport starts with the host, which does not finish starting until every geo is connected. Otherwise the host must also be an endpoint route builder, such as a WebApplication, and activities are received over HTTP at api/messages.

Applies to

UseTeamsBotApplication<TApp>(WebApplication, String)

Configures a custom TApp to receive activities over HTTP on a web application.

public static TApp UseTeamsBotApplication<TApp>(this Microsoft.AspNetCore.Builder.WebApplication app, string routePath = "api/messages") where TApp : Microsoft.Teams.Apps.TeamsBotApplication;
static member UseTeamsBotApplication : Microsoft.AspNetCore.Builder.WebApplication * string -> 'App (requires 'App :> Microsoft.Teams.Apps.TeamsBotApplication)
<Extension()>
Public Function UseTeamsBotApplication(Of TApp As TeamsBotApplication) (app As WebApplication, Optional routePath As String = "api/messages") As TApp

Type Parameters

TApp

The custom TeamsBotApplication type.

Parameters

app
WebApplication

The web application.

routePath
String

The route path to listen on. Default is "api/messages".

Returns

TApp

The configured TApp instance.

Exceptions

Thrown when Socket Mode is enabled with UseSocketMode(Boolean).

Remarks

Receives activities at routePath. This overload exists so that a WebApplication, which is both an IHost and an IEndpointRouteBuilder, binds unambiguously. Socket Mode runs without a web server; build a Socket Mode bot with Host.CreateApplicationBuilder() and call UseTeamsBotApplication<TApp>(IHost) instead.

Applies to

UseTeamsBotApplication<TApp>(IEndpointRouteBuilder, String)

Configures a custom TApp to receive activities over HTTP on the endpoint route builder.

public static TApp UseTeamsBotApplication<TApp>(this Microsoft.AspNetCore.Routing.IEndpointRouteBuilder endpoints, string routePath = "api/messages") where TApp : Microsoft.Teams.Apps.TeamsBotApplication;
static member UseTeamsBotApplication : Microsoft.AspNetCore.Routing.IEndpointRouteBuilder * string -> 'App (requires 'App :> Microsoft.Teams.Apps.TeamsBotApplication)
<Extension()>
Public Function UseTeamsBotApplication(Of TApp As TeamsBotApplication) (endpoints As IEndpointRouteBuilder, Optional routePath As String = "api/messages") As TApp

Type Parameters

TApp

The custom TeamsBotApplication type.

Parameters

endpoints
IEndpointRouteBuilder

The endpoint route builder.

routePath
String

The route path to listen on. Default is "api/messages".

Returns

TApp

The configured TApp instance.

Exceptions

Thrown when Socket Mode is enabled.

Remarks

Use this overload to map the messaging endpoint on a route group or other endpoint builder. To receive activities over Socket Mode, enable it with UseSocketMode(Boolean) and call UseTeamsBotApplication<TApp>(IHost) on a host without a web server.

Applies to