MessageExtensions class
MessageExtensions class to enable fluent style registration of handlers related to Message Extensions.
Constructors
Message |
Creates a new instance of the MessageExtensions class. |
Methods
Constructor Details
MessageExtensions<TState>(Application<TState>)
Creates a new instance of the MessageExtensions class.
new MessageExtensions(app: Application<TState>)
Parameters
- app
-
Application<TState>
Top level application class to register handlers with.
Method Details
anonymousQueryLink((context: TurnContext, state: TState, url: string) => Promise<MessagingExtensionResult>)
Registers a handler for a command that performs anonymous link unfurling.
function anonymousQueryLink(handler: (context: TurnContext, state: TState, url: string) => Promise<MessagingExtensionResult>): Application<TState>
Parameters
- handler
-
(context: TurnContext, state: TState, url: string) => Promise<MessagingExtensionResult>
Function to call when the command is received. The handler should return a MessagingExtensionResult
.
Returns
Application<TState>
The application for chaining purposes.
Remarks
The composeExtension/anonymousQueryLink
INVOKE activity does not contain any sort of command ID,
so only a single select item handler can be registered.
For more information visit https://learn.microsoft.com/microsoftteams/platform/messaging-extensions/how-to/link-unfurling?#enable-zero-install-link-unfurling
botMessagePreviewEdit(string | RegExp | Selector | (string | RegExp | Selector)[], (context: TurnContext, state: TState, previewActivity: Partial<Activity>) => Promise<undefined | null | string | MessagingExtensionResult | TaskModuleTaskInfo>)
Registers a handler to process the 'edit' action of a message that's being previewed by the user prior to sending.
function botMessagePreviewEdit(commandId: string | RegExp | Selector | (string | RegExp | Selector)[], handler: (context: TurnContext, state: TState, previewActivity: Partial<Activity>) => Promise<undefined | null | string | MessagingExtensionResult | TaskModuleTaskInfo>): Application<TState>
Parameters
ID of the command(s) to register the handler for.
- handler
-
(context: TurnContext, state: TState, previewActivity: Partial<Activity>) => Promise<undefined | null | string | MessagingExtensionResult | TaskModuleTaskInfo>
Function to call when the command is received.
Returns
Application<TState>
The application for chaining purposes.
Remarks
This handler is called when the user clicks the 'Edit' button on a message that's being previewed prior to insertion into the current chat. The handler should return a new view that allows the user to edit the message.
botMessagePreviewSend(string | RegExp | Selector | (string | RegExp | Selector)[], (context: TurnContext, state: TState, previewActivity: Partial<Activity>) => Promise<void>)
Registers a handler to process the 'send' action of a message that's being previewed by the user prior to sending.
function botMessagePreviewSend(commandId: string | RegExp | Selector | (string | RegExp | Selector)[], handler: (context: TurnContext, state: TState, previewActivity: Partial<Activity>) => Promise<void>): Application<TState>
Parameters
ID of the command(s) to register the handler for.
- handler
-
(context: TurnContext, state: TState, previewActivity: Partial<Activity>) => Promise<void>
Function to call when the command is received.
Returns
Application<TState>
The application for chaining purposes.
Remarks
This handler is called when the user clicks the 'Send' button on a message that's being previewed prior to insertion into the current chat. The handler should complete the flow by sending the message to the current chat.
configureSettings<TData>((context: TurnContext, state: TState, settings: TData) => Promise<void>)
Registers a handler that implements the logic to invoke configuring Message Extension settings
function configureSettings<TData>(handler: (context: TurnContext, state: TState, settings: TData) => Promise<void>): Application<TState>
Parameters
- handler
-
(context: TurnContext, state: TState, settings: TData) => Promise<void>
Function defined by the developer to call when the command is received.
Returns
Application<TState>
The application for chaining purposes.
Remarks
The composeExtension/setting
INVOKE activity does not contain a command ID, so only a single select item handler can be registered.
fetchTask(string | RegExp | Selector | (string | RegExp | Selector)[], (context: TurnContext, state: TState) => Promise<string | TaskModuleTaskInfo>)
Registers a handler to process the initial fetch task for an Action based message extension.
function fetchTask(commandId: string | RegExp | Selector | (string | RegExp | Selector)[], handler: (context: TurnContext, state: TState) => Promise<string | TaskModuleTaskInfo>): Application<TState>
Parameters
ID of the command(s) to register the handler for.
- handler
-
(context: TurnContext, state: TState) => Promise<string | TaskModuleTaskInfo>
Function to call when the command is received.
Returns
Application<TState>
The application for chaining purposes.
Remarks
Handlers should response with either an initial TaskInfo object or a string containing a message to display to the user.
handleOnButtonClicked<TData>((context: TurnContext, state: TState, data: TData) => Promise<void>)
Registers a handler that implements the logic when a user has clicked on a button in a Message Extension card.
function handleOnButtonClicked<TData>(handler: (context: TurnContext, state: TState, data: TData) => Promise<void>): Application<TState>
Parameters
- handler
-
(context: TurnContext, state: TState, data: TData) => Promise<void>
Function defined by the developer to call when the command is received.
Returns
Application<TState>
The application for chaining purposes.
Remarks
The composeExtension/onCardButtonClicked
INVOKE activity does not contain any sort of command ID,
so only a single select item handler can be registered. Developers will need to include a
type name of some sort in the preview item they return if they need to support multiple select item handlers.
query<TParams>(string | RegExp | Selector | (string | RegExp | Selector)[], (context: TurnContext, state: TState, query: Query<TParams>) => Promise<MessagingExtensionResult>)
Registers a handler that implements a Search based Message Extension.
function query<TParams>(commandId: string | RegExp | Selector | (string | RegExp | Selector)[], handler: (context: TurnContext, state: TState, query: Query<TParams>) => Promise<MessagingExtensionResult>): Application<TState>
Parameters
ID of the command(s) to register the handler for.
- handler
-
(context: TurnContext, state: TState, query: Query<TParams>) => Promise<MessagingExtensionResult>
Function to call when the command is received.
Returns
Application<TState>
The application for chaining purposes.
Remarks
This handler is called when the user submits a query to a Search based Message Extension. The handler should return a MessagingExtensionResult containing the results of the query.
queryLink((context: TurnContext, state: TState, url: string) => Promise<MessagingExtensionResult>)
Registers a handler that implements a Link Unfurling based Message Extension.
function queryLink(handler: (context: TurnContext, state: TState, url: string) => Promise<MessagingExtensionResult>): Application<TState>
Parameters
- handler
-
(context: TurnContext, state: TState, url: string) => Promise<MessagingExtensionResult>
Function to call when the command is received.
Returns
Application<TState>
The application for chaining purposes.
queryUrlSetting((context: TurnContext, state: TState) => Promise<MessagingExtensionResult>)
Registers a handler that invokes the fetch of the configuration settings for a Message Extension.
function queryUrlSetting(handler: (context: TurnContext, state: TState) => Promise<MessagingExtensionResult>): Application<TState>
Parameters
- handler
-
(context: TurnContext, state: TState) => Promise<MessagingExtensionResult>
Function defined by the developer to call when the command is received.
Returns
Application<TState>
The application for chaining purposes.
Remarks
The composeExtension/querySettingUrl
INVOKE activity does not contain a command ID, so only a single select item handler can be registered.
selectItem<TItem>((context: TurnContext, state: TState, item: TItem) => Promise<MessagingExtensionResult>)
Registers a handler that implements the logic to handle the tap actions for items returned by a Search based message extension.
function selectItem<TItem>(handler: (context: TurnContext, state: TState, item: TItem) => Promise<MessagingExtensionResult>): Application<TState>
Parameters
- handler
-
(context: TurnContext, state: TState, item: TItem) => Promise<MessagingExtensionResult>
Function to call when the command is received.
Returns
Application<TState>
The application for chaining purposes.
Remarks
The composeExtension/selectItem
INVOKE activity does not contain any sort of command ID,
so only a single select item handler can be registered. Developers will need to include a
type name of some sort in the preview item they return if they need to support multiple
select item handlers.
submitAction<TData>(string | RegExp | Selector | (string | RegExp | Selector)[], (context: TurnContext, state: TState, data: TData) => Promise<undefined | null | string | MessagingExtensionResult | TaskModuleTaskInfo>)
Registers a handler that implements the submit action for an Action based Message Extension.
function submitAction<TData>(commandId: string | RegExp | Selector | (string | RegExp | Selector)[], handler: (context: TurnContext, state: TState, data: TData) => Promise<undefined | null | string | MessagingExtensionResult | TaskModuleTaskInfo>): Application<TState>
Parameters
ID of the command(s) to register the handler for.
- handler
-
(context: TurnContext, state: TState, data: TData) => Promise<undefined | null | string | MessagingExtensionResult | TaskModuleTaskInfo>
Function to call when the command is received.
Returns
Application<TState>
The application for chaining purposes.