Language

TeamsSelectItemRouteAttribute(Boolean, UInt16, String) Constructor

Definition

Attribute to define a route that handles Teams message extension select item events.

public TeamsSelectItemRouteAttribute(bool isAgenticOnly = false, ushort rank = 32767, string signInHandlers = default);
new Microsoft.Agents.Extensions.MSTeams.MessageExtensions.TeamsSelectItemRouteAttribute : bool * uint16 * string -> Microsoft.Agents.Extensions.MSTeams.MessageExtensions.TeamsSelectItemRouteAttribute
Public Sub New (Optional isAgenticOnly As Boolean = false, Optional rank As UShort = 32767, Optional signInHandlers As String = Nothing)

Parameters

isAgenticOnly
Boolean

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

rank
UInt16

Route evaluation order. Lower values run first. Defaults to Unspecified.

signInHandlers
String

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

Remarks

Decorate a method with this attribute to register it as a handler for message extension select item events in Teams. The method must match the SelectItemHandler<TData> delegate signature, where TData is inferred from the method's third parameter type.

public record ProductSummary(string Id, string Name);

[TeamsSelectItemRoute]
public async Task<Response> OnSelectProductAsync(ITeamsTurnContext turnContext, ITurnState turnState, ProductSummary item, CancellationToken cancellationToken)
{
    var details = await _catalog.GetDetailsAsync(item.Id, cancellationToken);
    var card = details.ToHeroCard().ToMessagingExtensionAttachment();
    return new Response { ComposeExtension = new Result { Type = ResultType.List, Attachments = [card] } };
}

Alternatively, OnSelectItem<TData>(SelectItemHandler<TData>, String[], UInt16) can be used to register the handler via the fluent API.

Applies to