TeamsActivityRouteAttribute 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 activities matching a specific type or type pattern.
[Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Extensions.MSTeams.App.TeamsRouteHandler))]
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)]
public class TeamsActivityRouteAttribute : 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 TeamsActivityRouteAttribute = class
inherit Attribute
interface IRouteAttribute
Public Class TeamsActivityRouteAttribute
Inherits Attribute
Implements IRouteAttribute
- Inheritance
-
TeamsActivityRouteAttribute
- Attributes
- Implements
Remarks
Decorate a method with this attribute to register it as a handler for activities of the specified type. Provide either type for an exact match or typeRegex for a pattern match; they are mutually exclusive. When neither is provided the route matches any activity type and defaults to Last. The method must match the TeamsRouteHandler delegate signature.
// Match by exact type
[TeamsActivityRoute(ActivityTypes.Event)]
public async Task OnEventAsync(ITeamsTurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
// Handle any event activity
}
// Match by type pattern
[TeamsActivityRoute(typeRegex: "event|invoke")]
public async Task OnEventOrInvokeAsync(ITeamsTurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
// Handle event or invoke activities
}
// Match any activity type (fires last, after all specific routes)
[TeamsActivityRoute]
public async Task OnAnyAsync(ITeamsTurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
// Handle any unmatched activity
}
Constructors
| Name | Description |
|---|---|
| TeamsActivityRouteAttribute(String, String, Boolean, UInt16, String) |
Attribute to define a route that handles activities matching a specific type or type pattern. |
Methods
| Name | Description |
|---|---|
| AddRoute(AgentApplication, MethodInfo) | |