Share via


AgentApplication Class

Definition

Application class for routing and processing incoming requests.

public class AgentApplication : Microsoft.Agents.Builder.IAgent
type AgentApplication = class
    interface IAgent
Public Class AgentApplication
Implements IAgent
Inheritance
AgentApplication
Derived
Implements

Constructors

AgentApplication(AgentApplicationOptions)

Creates a new AgentApplication instance.

Properties

AdaptiveCards

Fluent interface for accessing Adaptive Card specific features.

Options

The application's configured options.

RegisteredExtensions
UserAuthorization

Accessing user authorization features.

Methods

AddRoute(RouteSelector, RouteHandler, Boolean, UInt16, String[])

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 true when an activity is received will have its handler called.

Invoke-based activities receive special treatment and are matched separately as they typically have shorter execution timeouts.

OnActivity(MultipleRouteSelector, RouteHandler, UInt16, String[])

Handles incoming activities of a given type.

OnActivity(Regex, RouteHandler, UInt16, String[])

Handles incoming activities of a given type.

OnActivity(RouteSelector, RouteHandler, UInt16, String[])

Handles incoming activities of a given type.

OnActivity(String, RouteHandler, UInt16, String[])

Handles incoming activities of a given type.

OnAfterTurn(TurnEventHandler)

Add a handler that will execute after the turn's activity handler logic is processed.
Handler returns true to finish execution of the current turn. Handler returning false prevents the Agents state from being saved.

OnBeforeTurn(TurnEventHandler)

Add a handler that will execute before the turn's activity handler logic is processed.
Handler returns true to continue execution of the current turn. Handler returning false prevents the turn from running, but the Agents state is still saved, which lets you track the reason why the turn was not processed. It also means you can use this as a way to call into the dialog system. For example, you could use the OAuthPrompt to sign the user in before allowing the AI system to run.

OnConversationUpdate(RouteSelector, RouteHandler, UInt16, String[])

Handles conversation update events using a custom selector.

OnConversationUpdate(String, RouteHandler, UInt16, String[])

Handles conversation update events.

OnConversationUpdate(String[], RouteHandler, UInt16, String[])

Handles conversation update events.

OnEvent(Regex, RouteHandler, UInt16, String[])

Handles incoming Events matching a Name pattern.

OnEvent(RouteSelector, RouteHandler, UInt16, String[])

Handles incoming Events.

OnEvent(String, RouteHandler, UInt16, String[])

Handles incoming Event with a specific Name.

OnHandoff(HandoffHandler, UInt16, String[])

Handles handoff activities.

OnMessage(MultipleRouteSelector, RouteHandler, UInt16, String[])

Handles incoming messages with a given keyword.
This method provides a simple way to have a Agent respond anytime a user sends a message with a specific word or phrase.

OnMessage(Regex, RouteHandler, UInt16, String[])

Handles incoming messages with a given keyword.
This method provides a simple way to have a Agent respond anytime a user sends a message with a specific word or phrase.
For example, you can easily clear the current conversation anytime a user sends "/reset":
application.OnMessage(new Regex("reset"), (context, turnState, _) => ...);

OnMessage(RouteSelector, RouteHandler, UInt16, String[])

Handles incoming messages with a given keyword.
This method provides a simple way to have a Agent respond anytime a user sends a message with a specific word or phrase.

OnMessage(String, RouteHandler, UInt16, String[])

Handles incoming messages with a given keyword.
This method provides a simple way to have an Agent respond anytime a user sends a message with a specific word or phrase.
For example, you can easily clear the current conversation anytime a user sends "/reset":
application.OnMessage("/reset", (context, turnState, _) => ...);

OnMessageReactionsAdded(RouteHandler, UInt16, String[])

Handles message reactions added events.

OnMessageReactionsRemoved(RouteHandler, UInt16, String[])

Handles message reactions removed events.

OnTurnAsync(ITurnContext, CancellationToken)

Called by the adapter (for example, a CloudAdapter) at runtime in order to process an inbound Activity.

OnTurnError(AgentApplicationTurnError)

Allows the AgentApplication to provide error handling without having to change the Adapter.OnTurnError. This is beneficial since the application has more context.

RegisterExtension<TExtension>(TExtension, Action<TExtension>)

Registers extension with application, providing callback to specify extension features.

StartTypingTimer(ITurnContext)

Manually start a timer to periodically send "typing" activities.

StopTypingTimer()

Manually stop the typing timer.

Applies to