Application<TState>.OnMessage Method
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.
Overloads
| OnMessage(MultipleRouteSelector, 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.
|
| OnMessage(Regex, RouteHandler<TState>) |
Handles incoming messages with a given keyword.
|
OnMessage(MultipleRouteSelector, RouteHandler<TState>)
Handles incoming messages with a given keyword.
This method provides a simple way to have a bot respond anytime a user sends your bot a
message with a specific word or phrase.
public Microsoft.Teams.AI.Application<TState> OnMessage(Microsoft.Teams.AI.MultipleRouteSelector routeSelectors, Microsoft.Teams.AI.RouteHandler<TState> handler);
member this.OnMessage : Microsoft.Teams.AI.MultipleRouteSelector * Microsoft.Teams.AI.RouteHandler<'State (requires 'State :> Microsoft.Teams.AI.State.TurnState and 'State : (new : unit -> 'State))> -> Microsoft.Teams.AI.Application<'State (requires 'State :> Microsoft.Teams.AI.State.TurnState and 'State : (new : unit -> 'State))>
Public Function OnMessage (routeSelectors As MultipleRouteSelector, handler As RouteHandler(Of TState)) As Application(Of TState)
Parameters
- routeSelectors
- MultipleRouteSelector
Combination of String, Regex, and RouteSelectorAsync selectors.
- handler
- RouteHandler<TState>
Function to call when the route is triggered.
Returns
The application instance for chaining purposes.
Applies to
OnMessage(RouteSelectorAsync, RouteHandler<TState>)
Handles incoming messages with a given keyword.
This method provides a simple way to have a bot respond anytime a user sends your bot a
message with a specific word or phrase.
public Microsoft.Teams.AI.Application<TState> OnMessage(Microsoft.Teams.AI.RouteSelectorAsync routeSelector, Microsoft.Teams.AI.RouteHandler<TState> handler);
member this.OnMessage : Microsoft.Teams.AI.RouteSelectorAsync * Microsoft.Teams.AI.RouteHandler<'State (requires 'State :> Microsoft.Teams.AI.State.TurnState and 'State : (new : unit -> 'State))> -> Microsoft.Teams.AI.Application<'State (requires 'State :> Microsoft.Teams.AI.State.TurnState and 'State : (new : unit -> 'State))>
Public Function OnMessage (routeSelector As RouteSelectorAsync, handler As RouteHandler(Of TState)) As Application(Of TState)
Parameters
- routeSelector
- RouteSelectorAsync
Function that's used to select a route. The function returning true triggers the route.
- handler
- RouteHandler<TState>
Function to call when the route is triggered.
Returns
The application instance for chaining purposes.
Applies to
OnMessage(String, RouteHandler<TState>)
Handles incoming messages with a given keyword.
This method provides a simple way to have a bot respond anytime a user sends your bot 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, _) => ...);
public Microsoft.Teams.AI.Application<TState> OnMessage(string text, Microsoft.Teams.AI.RouteHandler<TState> handler);
member this.OnMessage : string * Microsoft.Teams.AI.RouteHandler<'State (requires 'State :> Microsoft.Teams.AI.State.TurnState and 'State : (new : unit -> 'State))> -> Microsoft.Teams.AI.Application<'State (requires 'State :> Microsoft.Teams.AI.State.TurnState and 'State : (new : unit -> 'State))>
Public Function OnMessage (text As String, handler As RouteHandler(Of TState)) As Application(Of TState)
Parameters
- text
- String
Substring of the incoming message text.
- handler
- RouteHandler<TState>
Function to call when the route is triggered.
Returns
The application instance for chaining purposes.
Applies to
OnMessage(Regex, RouteHandler<TState>)
Handles incoming messages with a given keyword.
This method provides a simple way to have a bot respond anytime a user sends your bot 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, _) => ...);
public Microsoft.Teams.AI.Application<TState> OnMessage(System.Text.RegularExpressions.Regex textPattern, Microsoft.Teams.AI.RouteHandler<TState> handler);
member this.OnMessage : System.Text.RegularExpressions.Regex * Microsoft.Teams.AI.RouteHandler<'State (requires 'State :> Microsoft.Teams.AI.State.TurnState and 'State : (new : unit -> 'State))> -> Microsoft.Teams.AI.Application<'State (requires 'State :> Microsoft.Teams.AI.State.TurnState and 'State : (new : unit -> 'State))>
Public Function OnMessage (textPattern As Regex, handler As RouteHandler(Of TState)) As Application(Of TState)
Parameters
- textPattern
- Regex
Regular expression to match against the text of an incoming message.
- handler
- RouteHandler<TState>
Function to call when the route is triggered.
Returns
The application instance for chaining purposes.