AdaptiveCardsActions class

A class to handle Adaptive Card actions such as executing actions, submitting actions, and performing searches.

Constructors

AdaptiveCardsActions<TState>(AgentApplication<TState>)

Constructs an instance of AdaptiveCardsActions.

Constructor Details

AdaptiveCardsActions<TState>(AgentApplication<TState>)

Constructs an instance of AdaptiveCardsActions.

new AdaptiveCardsActions(app: AgentApplication<TState>)

Parameters

app

AgentApplication<TState>

The Teams application instance.

Method Details

actionExecute<TData>(string | RegExp | Selector | (string | RegExp | Selector)[], (context: TurnContext, state: TState, data: TData) => Promise<string | AdaptiveCard>)

Registers a handler for the Action.Execute event.

function actionExecute<TData>(verb: string | RegExp | Selector | (string | RegExp | Selector)[], handler: (context: TurnContext, state: TState, data: TData) => Promise<string | AdaptiveCard>): AgentApplication<TState>

Parameters

verb

string | RegExp | Selector | (string | RegExp | Selector)[]

A string, RegExp, RouteSelector, or an array of these to match the action verb.

handler

(context: TurnContext, state: TState, data: TData) => Promise<string | AdaptiveCard>

A function to handle the action execution.

Returns

The Teams application instance.

Remarks

The delivery behavior depends on the action trigger and adaptiveCardsOptions.actionExecuteResponseType:

Response type Automatic trigger Manual trigger
REPLACE_FOR_INTERACTOR User response User response
REPLACE_FOR_ALL User response Shared update
NEW_MESSAGE_FOR_ALL User response New message
  • User response — Return an Adaptive Card invoke response only to the requesting or interacting user.
  • Shared update — Update the shared activity for all users and return an Adaptive Card invoke response to the interacting user.
  • New message — Send a new activity for all users and return a message acknowledgement to the interacting user.

Automatic refresh actions always return only an Adaptive Card invoke response. Updating or sending a refreshable card while processing an automatic refresh would cause Teams to invoke the refresh action again.

actionSubmit<TData>(string | RegExp | Selector | (string | RegExp | Selector)[], (context: TurnContext, state: TState, data: TData) => Promise<void>)

Registers a handler for the Action.Submit event.

function actionSubmit<TData>(verb: string | RegExp | Selector | (string | RegExp | Selector)[], handler: (context: TurnContext, state: TState, data: TData) => Promise<void>): AgentApplication<TState>

Parameters

verb

string | RegExp | Selector | (string | RegExp | Selector)[]

A string, RegExp, RouteSelector, or an array of these to match the action verb.

handler

(context: TurnContext, state: TState, data: TData) => Promise<void>

A function to handle the action submission.

Returns

The Teams application instance.

Registers a handler for the search event.

function search(dataset: string | RegExp | Selector | (string | RegExp | Selector)[], handler: (context: TurnContext, state: TState, query: Query<AdaptiveCardsSearchParams>) => Promise<AdaptiveCardSearchResult[]>): AgentApplication<TState>

Parameters

dataset

string | RegExp | Selector | (string | RegExp | Selector)[]

A string, RegExp, RouteSelector, or an array of these to match the dataset.

handler

(context: TurnContext, state: TState, query: Query<AdaptiveCardsSearchParams>) => Promise<AdaptiveCardSearchResult[]>

A function to handle the search query.

Returns

The Teams application instance.