Application<TState> Class
Definition
Important
Some information relates to prerelease product that may be substantially modified before it’s released. Microsoft makes no warranties, express or implied, with respect to the information provided here.
Application class for routing and processing incoming requests.
public class Application<TState> : Microsoft.Bot.Builder.IBot where TState : TurnState, new()
type Application<'State (requires 'State :> TurnState and 'State : (new : unit -> 'State))> = class
interface IBot
Public Class Application(Of TState)
Implements IBot
Type Parameters
- TState
Type of the turnState. This allows for strongly typed access to the turn turnState.
- Inheritance
-
Application<TState>
- Implements
Remarks
The Application object replaces the traditional ActivityHandler that a bot would use. It supports a simpler fluent style of authoring bots versus the inheritance based approach used by the ActivityHandler class.
Additionally, it has built-in support for calling into the SDK's AI system and can be used to create bots that leverage Large Language Models (LLM) and other AI capabilities.
Constructors
| Application<TState>(ApplicationOptions<TState>) |
Creates a new Application instance. |
Properties
| Adapter |
Fluent interface for accessing the bot adapter used to configure the application. |
| AdaptiveCards |
Fluent interface for accessing Adaptive Card specific features. |
| AI |
Fluent interface for accessing AI specific features. |
| Authentication |
Accessing authentication specific features. |
| Meetings |
Fluent interface for accessing Meetings' specific features. |
| MessageExtensions |
Fluent interface for accessing Message Extensions' specific features. |
| Options |
The application's configured options. |
| TaskModules |
Fluent interface for accessing Task Modules' specific features. |
Methods
| AddRoute(RouteSelectorAsync, RouteHandler<TState>, Boolean) |
Adds a new route to the application. Developers won't typically need to call this method directly as it's used internally by all of the fluent interfaces to register routes for their specific activity types. Routes will be matched in the order they're added to the application. The first selector to
return Invoke-based activities receive special treatment and are matched separately as they typically have shorter execution timeouts. |
| GetTokenOrStartSignInAsync(ITurnContext, TState, String, CancellationToken) |
If the user is signed in, get the access token. If not, triggers the sign in flow for the provided authentication setting name and returns.In this case, the bot should end the turn until the sign in flow is completed. |
| OnActivity(MultipleRouteSelector, RouteHandler<TState>) |
Handles incoming activities of a given type. |
| OnActivity(Regex, RouteHandler<TState>) |
Handles incoming activities of a given type. |
| OnActivity(RouteSelectorAsync, RouteHandler<TState>) |
Handles incoming activities of a given type. |
| OnActivity(String, RouteHandler<TState>) |
Handles incoming activities of a given type. |
| OnAfterTurn(TurnEventHandlerAsync<TState>) |
Add a handler that will execute after the turn's activity handler logic is processed.
|
| OnBeforeTurn(TurnEventHandlerAsync<TState>) |
Add a handler that will execute before the turn's activity handler logic is processed.
|
| OnConfigFetch(ConfigHandlerAsync<TState>) |
Handles config fetch events for Microsoft Teams. |
| OnConfigSubmit(ConfigHandlerAsync<TState>) |
Handles config submit events for Microsoft Teams. |
| OnConversationUpdate(String, RouteHandler<TState>) |
Handles conversation update events. |
| OnConversationUpdate(String[], RouteHandler<TState>) |
Handles conversation update events. |
| OnFileConsentAccept(FileConsentHandler<TState>) |
Handles when a file consent card is accepted by the user. |
| OnFileConsentDecline(FileConsentHandler<TState>) |
Handles when a file consent card is declined by the user. |
| OnMessage(MultipleRouteSelector, RouteHandler<TState>) |
Handles incoming messages with a given keyword.
|
| OnMessage(Regex, RouteHandler<TState>) |
Handles incoming messages with a given keyword.
|
| OnMessage(RouteSelectorAsync, RouteHandler<TState>) |
Handles incoming messages with a given keyword.
|
| OnMessage(String, RouteHandler<TState>) |
Handles incoming messages with a given keyword.
|
| OnMessageDelete(RouteHandler<TState>) |
Handles message soft delete events. |
| OnMessageEdit(RouteHandler<TState>) |
Handles message edit events. |
| OnMessageReactionsAdded(RouteHandler<TState>) |
Handles message reactions added events. |
| OnMessageReactionsRemoved(RouteHandler<TState>) |
Handles message reactions removed events. |
| OnMessageUndelete(RouteHandler<TState>) |
Handles message undo soft delete events. |
| OnO365ConnectorCardAction(O365ConnectorCardActionHandler<TState>) |
Handles O365 Connector Card Action activities. |
| OnTeamsReadReceipt(ReadReceiptHandler<TState>) |
Handles read receipt events for messages sent by the bot in personal scope. |
| OnTurnAsync(ITurnContext, CancellationToken) |
Called by the adapter (for example, a CloudAdapter) at runtime in order to process an inbound Activity. |
| StartTypingTimer(ITurnContext) |
Manually start a timer to periodically send "typing" activities. |
| StopTypingTimer() |
Manually stop the typing timer. |