TeamsCardButtonClickedRouteAttribute 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 card button clicked events.
[Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Extensions.MSTeams.MessageExtensions.CardButtonClickedHandler<>))]
[System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)]
public class TeamsCardButtonClickedRouteAttribute : Attribute, Microsoft.Agents.Builder.App.IRouteAttribute
[<Microsoft.Agents.Builder.App.RouteHandlerType(typeof(Microsoft.Agents.Extensions.MSTeams.MessageExtensions.CardButtonClickedHandler<>))>]
[<System.AttributeUsage(System.AttributeTargets.Method, Inherited=true)>]
type TeamsCardButtonClickedRouteAttribute = class
inherit Attribute
interface IRouteAttribute
Public Class TeamsCardButtonClickedRouteAttribute
Inherits Attribute
Implements IRouteAttribute
- Inheritance
-
TeamsCardButtonClickedRouteAttribute
- Attributes
- Implements
Remarks
Decorate a method with this attribute to register it as a handler for message extension card button click events in Teams. The method must match the CardButtonClickedHandler<TData> delegate signature, where TData is inferred from the method's third parameter type.
public record ApprovalAction(string ItemId, string Decision);
[TeamsCardButtonClickedRoute]
public async Task OnApprovalClickedAsync(ITeamsTurnContext turnContext, ITurnState turnState, ApprovalAction cardData, CancellationToken cancellationToken)
{
await _approvalService.RecordAsync(cardData.ItemId, cardData.Decision, cancellationToken);
await turnContext.SendActivityAsync($"Decision '{cardData.Decision}' recorded.", cancellationToken: cancellationToken);
}
Alternatively, OnCardButtonClicked<TData>(CardButtonClickedHandler<TData>, String[], UInt16) can be used to register the handler via the fluent API.
Constructors
| Name | Description |
|---|---|
| TeamsCardButtonClickedRouteAttribute(Boolean, UInt16, String) |
Attribute to define a route that handles Teams message extension card button clicked events. |
Methods
| Name | Description |
|---|---|
| AddRoute(AgentApplication, MethodInfo) | |