Language

MessageExtension.OnCardButtonClicked<TData> Method

Definition

Registers a handler that implements the logic when a user has clicked on a button in a Message Extension card.

public Microsoft.Agents.Extensions.MSTeams.MessageExtensions.MessageExtension OnCardButtonClicked<TData>(Microsoft.Agents.Extensions.MSTeams.MessageExtensions.CardButtonClickedHandler<TData> handler, string[] autoSignInHandlers = default, ushort rank = 32767);
member this.OnCardButtonClicked : Microsoft.Agents.Extensions.MSTeams.MessageExtensions.CardButtonClickedHandler<'Data> * string[] * uint16 -> Microsoft.Agents.Extensions.MSTeams.MessageExtensions.MessageExtension
Public Function OnCardButtonClicked(Of TData) (handler As CardButtonClickedHandler(Of TData), Optional autoSignInHandlers As String() = Nothing, Optional rank As UShort = 32767) As MessageExtension

Type Parameters

TData

The type of the cardData argument on the handler.

Parameters

handler
CardButtonClickedHandler<TData>

A delegate that handles the card button click event. The delegate receives the turn context, turn state, deserialized value payload of type TData, and a cancellation token. Cannot be null.

autoSignInHandlers
String[]

OAuth sign-in handler names for automatic sign-in before the route handler is invoked. Specify null to skip automatic sign-in.

rank
UInt16

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

Returns

The current MessageExtension instance for method chaining.

Remarks

``` TeamsExtension.MessageExtensions.OnCardButtonClicked<ApprovalAction>(async (ctx, state, cardData, ct) => { await _approvalService.RecordAsync(cardData.ItemId, cardData.Decision, ct); await ctx.SendActivityAsync($"Decision '{cardData.Decision}' recorded.", cancellationToken: ct); }); ``` Alternatively, the TeamsCardButtonClickedRouteAttribute can be used to decorate a CardButtonClickedHandler<TData> method for the same purpose.

Applies to