MessageRouteAttribute 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.
Attribute to define a route that handles message activities, optionally matching specific text or a text pattern.
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)]
public class MessageRouteAttribute : Attribute, Microsoft.Agents.Builder.App.IRouteAttribute
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)>]
type MessageRouteAttribute = class
inherit Attribute
interface IRouteAttribute
Public Class MessageRouteAttribute
Inherits Attribute
Implements IRouteAttribute
- Inheritance
-
MessageRouteAttribute
- Attributes
- Implements
Remarks
Decorate a method with this attribute to register it as a handler for message activities. Provide text for an exact match, textRegex for a pattern match, or neither to match any message. text and textRegex are mutually exclusive. The method must match the RouteHandler delegate signature.
// Match any message
[MessageRoute]
public async Task OnMessageAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
// Handle any message
}
// Match a specific message
[MessageRoute("hello")]
public async Task OnHelloAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
// Handle "hello" message
}
// Match a text pattern
[MessageRoute(textRegex: "he.*o")]
public async Task OnHelloPatternAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
// Handle messages matching pattern
}
Constructors
| Name | Description |
|---|---|
| MessageRouteAttribute(String, String, Boolean, UInt16, String) |
Attribute to define a route that handles message activities, optionally matching specific text or a text pattern. |
Methods
| Name | Description |
|---|---|
| AddRoute(AgentApplication, MethodInfo) | |