TeamsSelectItemRouteAttribute 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 Teams message extension select item events.
[Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Extensions.MSTeams.MessageExtensions.SelectItemHandler<>))]
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)]
public class TeamsSelectItemRouteAttribute : Attribute, Microsoft.Agents.Builder.App.IRouteAttribute
[<Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Extensions.MSTeams.MessageExtensions.SelectItemHandler<>))>]
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)>]
type TeamsSelectItemRouteAttribute = class
inherit Attribute
interface IRouteAttribute
Public Class TeamsSelectItemRouteAttribute
Inherits Attribute
Implements IRouteAttribute
- Inheritance
-
TeamsSelectItemRouteAttribute
- Attributes
- Implements
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.
Constructors
| Name | Description |
|---|---|
| TeamsSelectItemRouteAttribute(Boolean, UInt16, String) |
Attribute to define a route that handles Teams message extension select item events. |
Methods
| Name | Description |
|---|---|
| AddRoute(AgentApplication, MethodInfo) | |