/** * @module teams-ai */ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { Activity, MessagingExtensionResult, TaskModuleTaskInfo, TurnContext } from 'botbuilder'; import { Application, RouteSelector, Query } from './Application'; import { TurnState } from './TurnState'; /** * Names of the invoke activities for Message Extensions. */ export declare enum MessageExtensionsInvokeNames { /** * Name of the invoke activity for anonymous link unfurling. */ ANONYMOUS_QUERY_LINK_INVOKE = "composeExtension/anonymousQueryLink", /** * Name of the invoke activity for fetching task module. */ FETCH_TASK_INVOKE = "composeExtension/fetchTask", /** * Name of the invoke activity for query. */ QUERY_INVOKE = "composeExtension/query", /** * Name of the invoke activity for query link. */ QUERY_LINK_INVOKE = "composeExtension/queryLink", /** * Name of the invoke activity for selecting an item. */ SELECT_ITEM_INVOKE = "composeExtension/selectItem", /** * Name of the invoke activity for submit action. */ SUBMIT_ACTION_INVOKE = "composeExtension/submitAction", /** * Name of the invoke activity for querying configuration settings. */ QUERY_SETTING_URL = "composeExtension/querySettingUrl", /** * Name of the invoke activity for configuring settings. */ CONFIGURE_SETTINGS = "composeExtension/setting", /** * Name of the invoke activity for handling on card button clicked. */ QUERY_CARD_BUTTON_CLICKED = "composeExtension/onCardButtonClicked" } /** * MessageExtensions class to enable fluent style registration of handlers related to Message Extensions. * @template TState Type of the turn state object being persisted. */ export declare class MessageExtensions { private readonly _app; /** * Creates a new instance of the MessageExtensions class. * @param {Application} app Top level application class to register handlers with. */ constructor(app: Application); /** * Registers a handler for a command that performs anonymous link unfurling. * @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 * @param {(context: TurnContext, state: TState, url: string) => Promise} handler - Function to call when the command is received. The handler should return a `MessagingExtensionResult`. * @param {TurnContext} handler.context - Context for the current turn of conversation with the user. * @param {TState} handler.state - Current state of the turn. * @param {string} handler.url - URL to unfurl. * @returns {Application} The application for chaining purposes. */ anonymousQueryLink(handler: (context: TurnContext, state: TState, url: string) => Promise): Application; /** * Registers a handler to process the 'edit' action of a message that's being previewed by the * user prior to sending. * @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. * @param {string | RegExp | RouteSelector | string[] | RegExp[] | RouteSelector[]} commandId - ID of the command(s) to register the handler for. * @param {(context: TurnContext, state: TState, previewActivity: Partial) => Promise} handler - Function to call when the command is received. * @param {TurnContext} handler.context - Context for the current turn of conversation with the user. * @param {TState} handler.state - Current state of the turn. * @param {Partial} handler.previewActivity - The activity that's being previewed by the user. * @returns {Application} The application for chaining purposes. */ botMessagePreviewEdit(commandId: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[], handler: (context: TurnContext, state: TState, previewActivity: Partial) => Promise): Application; /** * Registers a handler to process the 'send' action of a message that's being previewed by the * user prior to sending. * @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. * @param {string | RegExp | RouteSelector | string[] | RegExp[] | RouteSelector[]} commandId - ID of the command(s) to register the handler for. * @param {(context: TurnContext, state: TState, previewActivity: Partial) => Promise} handler - Function to call when the command is received. * @param {TurnContext} handler.context - Context for the current turn of conversation with the user. * @param {TState} handler.state - Current state of the turn. * @param {Partial} handler.previewActivity - The activity that's being previewed by the user. * @returns {Application} The application for chaining purposes. */ botMessagePreviewSend(commandId: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[], handler: (context: TurnContext, state: TState, previewActivity: Partial) => Promise): Application; /** * Registers a handler to process the initial fetch task for an Action based message extension. * @remarks * Handlers should response with either an initial TaskInfo object or a string containing * a message to display to the user. * @param {string | RegExp | RouteSelector | string[] | RegExp[] | RouteSelector[]} commandId - ID of the command(s) to register the handler for. * @param {(context: TurnContext, state: TState) => Promise} handler - Function to call when the command is received. * @param {TurnContext} handler.context - Context for the current turn of conversation with the user. * @param {TState} handler.state - Current state of the turn. * @returns {Application} The application for chaining purposes. */ fetchTask(commandId: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[], handler: (context: TurnContext, state: TState) => Promise): Application; /** * Registers a handler that implements a Search based Message Extension. * @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. * @param {string | RegExp | RouteSelector | string[] | RegExp[] | RouteSelector[]} commandId - ID of the command(s) to register the handler for. * @template TParams * @param {(context: TurnContext, state: TState, query: Query) => Promise} handler - Function to call when the command is received. * @param {TurnContext} handler.context - Context for the current turn of conversation with the user. * @param {TState} handler.state - Current state of the turn. * @param {Query} handler.query - The query parameters that were sent by the client. * @returns {Application} The application for chaining purposes. */ query = Record>(commandId: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[], handler: (context: TurnContext, state: TState, query: Query) => Promise): Application; /** * Registers a handler that implements a Link Unfurling based Message Extension. * @param {(context: TurnContext, state: TState, url: string) => Promise} handler - Function to call when the command is received. * @param {TurnContext} handler.context - Context for the current turn of conversation with the user. * @param {TState} handler.state - Current state of the turn. * @param {string} handler.url - The URL that should be unfurled. * @returns {Application} The application for chaining purposes. */ queryLink(handler: (context: TurnContext, state: TState, url: string) => Promise): Application; /** * Registers a handler that implements the logic to handle the tap actions for items returned * by a Search based message extension. * @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. * @template TItem Optional. Type of the item being selected. * @param {(context: TurnContext, state: TState, item: TItem) => Promise} handler Function to call when the command is received. * @param {TurnContext} handler.context Context for the current turn of conversation with the user. * @param {TState} handler.state Current state of the turn. * @param {TItem} handler.item The item that was selected. * @returns {Application} The application for chaining purposes. */ selectItem = Record>(handler: (context: TurnContext, state: TState, item: TItem) => Promise): Application; /** * Registers a handler that implements the submit action for an Action based Message Extension. * @template TData Optional. Type of data being submitted. * @param {string | RegExp | RouteSelector | string[] | RegExp[] | RouteSelector[]} commandId ID of the command(s) to register the handler for. * @param {(context: TurnContext, state: TState, data: TData) => Promise} handler Function to call when the command is received. * @param {TurnContext} handler.context Context for the current turn of conversation with the user. * @param {TState} handler.state Current state of the turn. * @param {TData} handler.data The data that was submitted. * @returns {Application} The application for chaining purposes. */ submitAction>(commandId: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[], handler: (context: TurnContext, state: TState, data: TData) => Promise): Application; /** * Sends the response for a submit action. * @param {TurnContext} context The context object for the current turn of conversation with the user. * @param {MessagingExtensionResult | TaskModuleTaskInfo | string | null | undefined} result The result of the submit action. * @private */ private returnSubmitActionResponse; /** * Registers a handler that invokes the fetch of the configuration settings for a Message Extension. @remarks * The `composeExtension/querySettingUrl` INVOKE activity does not contain a command ID, so only a single select item handler can be registered. * @param {(context: TurnContext, state: TState) => Promise} handler Function defined by the developer to call when the command is received. * @param {TurnContext} handler.context Context for the current turn of conversation with the user. * @param {TState} handler.state Current state of the turn. * @returns {Application} The application for chaining purposes. */ queryUrlSetting(handler: (context: TurnContext, state: TState) => Promise): Application; /** * Registers a handler that implements the logic to invoke configuring Message Extension settings * @remarks * The `composeExtension/setting` INVOKE activity does not contain a command ID, so only a single select item handler can be registered. * @template TData Message Extension settings to be configured. * @param {(context: TurnContext, state: TState, settings: TData) => Promise} handler Function defined by the developer to call when the command is received. * @param {TurnContext} handler.context Context for the current turn of conversation with the user. * @param {TState} handler.state Current state of the turn. * @param {TData} handler.settings The configuration settings that was submitted. * @returns {Application} The application for chaining purposes. */ configureSettings>(handler: (context: TurnContext, state: TState, settings: TData) => Promise): Application; /** * Registers a handler that implements the logic when a user has clicked on a button in a Message Extension card. * @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. * @template TData Message Extension data passed on invoke. * @param {(context: TurnContext, state: TState, data: TData) => Promise} handler Function defined by the developer to call when the command is received. * @param {TurnContext} handler.context Context for the current turn of conversation with the user. * @param {TState} handler.state Current state of the turn. * @param {TData} handler.data The data that was submitted. * @returns {Application} The application for chaining purposes. */ handleOnButtonClicked>(handler: (context: TurnContext, state: TState, data: TData) => Promise): Application; } //# sourceMappingURL=MessageExtensions.d.ts.map