TeamsMessageRouteAttribute 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.
[Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Extensions.MSTeams.App.TeamsRouteHandler))]
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)]
public class TeamsMessageRouteAttribute : Attribute, Microsoft.Agents.Builder.App.IRouteAttribute
[<Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Extensions.MSTeams.App.TeamsRouteHandler))>]
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)>]
type TeamsMessageRouteAttribute = class
inherit Attribute
interface IRouteAttribute
Public Class TeamsMessageRouteAttribute
Inherits Attribute
Implements IRouteAttribute
- Inheritance
-
TeamsMessageRouteAttribute
- 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 TeamsRouteHandler delegate signature.
// Match any message
[TeamsMessageRoute]
public async Task OnMessageAsync(ITeamsTurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
// Handle any message
}
// Match a specific message
[TeamsMessageRoute("hello")]
public async Task OnHelloAsync(ITeamsTurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
// Handle "hello" message
}
// Match a text pattern
[TeamsMessageRoute(textRegex: "he.*o")]
public async Task OnHelloPatternAsync(ITeamsTurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
// Handle messages matching pattern
}
Constructors
| Name | Description |
|---|---|
| TeamsMessageRouteAttribute(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) | |