EventRouteAttribute(String, String, Boolean, UInt16, String) Constructor

Definition

Attribute to define a route that handles event activities, optionally matching a specific event name or name pattern.

public EventRouteAttribute(string name = default, string nameRegex = default, bool isAgenticOnly = false, ushort rank = 32767, string autoSignInHandlers = default);
new Microsoft.Agents.Builder.App.EventRouteAttribute : string * string * bool * uint16 * string -> Microsoft.Agents.Builder.App.EventRouteAttribute
Public Sub New (Optional name As String = Nothing, Optional nameRegex As String = Nothing, Optional isAgenticOnly As Boolean = false, Optional rank As UShort = 32767, Optional autoSignInHandlers As String = Nothing)

Parameters

name
String

The exact event name to match (case-insensitive), e.g. Name. Mutually exclusive with nameRegex. When both are omitted, all events are matched.

nameRegex
String

A regular expression pattern matched against Name. Mutually exclusive with name.

isAgenticOnly
Boolean

When true, the route only fires for agentic turns. Defaults to false.

rank
UInt16

Route evaluation order. Lower values run first. When no name filter is specified, defaults to Last so specific-name routes take priority.

autoSignInHandlers
String

A comma/space/semicolon-delimited list of OAuth sign-in handler names, or the name of an instance or static method on the agent class matching Func<ITurnContext, string[]>.

Remarks

Decorate a method with this attribute to register it as a handler for event activities. Provide name for an exact match, nameRegex for a pattern match, or neither to match any event. name and nameRegex are mutually exclusive. The method must match the RouteHandler delegate signature.

// Match any event
[EventRoute]
public async Task OnAnyEventAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
    // Handle any event activity
}

// Match a specific event
[EventRoute("myEvent")]
public async Task OnMyEventAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
    // Handle "myEvent" event
}

// Match an event name pattern
[EventRoute(nameRegex: "my.*Event")]
public async Task OnMyEventPatternAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
    // Handle events matching pattern
}

Applies to