ภาษา

InvokeRouteAttribute(String, String, Boolean, UInt16, String) Constructor

Definition

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

public InvokeRouteAttribute(string name = default, string nameRegex = default, bool isAgenticOnly = false, ushort rank = 32767, string autoSignInHandlers = default);
new Microsoft.Agents.Builder.App.InvokeRouteAttribute : string * string * bool * uint16 * string -> Microsoft.Agents.Builder.App.InvokeRouteAttribute
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 invoke name to match (case-insensitive), e.g. Name. Mutually exclusive with nameRegex. When both are omitted, all invokes 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 invoke activities. Provide name for an exact match, nameRegex for a pattern match, or neither to match any invoke. name and nameRegex are mutually exclusive. The method must match the RouteHandler delegate signature.

// Match any invoke
[InvokeRoute]
public async Task OnAnyInvokeAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
    // Handle any invoke activity
}

// Match a specific invoke
[InvokeRoute("myInvoke")]
public async Task OnMyInvokeAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
    // Handle "myInvoke" invoke
}

// Match an invoke name pattern
[InvokeRoute(nameRegex: "my.*Invoke")]
public async Task OnMyInvokePatternAsync(ITurnContext turnContext, ITurnState turnState, CancellationToken cancellationToken)
{
    // Handle invokes matching pattern
}

Applies to