@microsoft/agents-hosting-extensions-teams
Version:
Microsoft 365 Agents SDK for JavaScript. Teams extensions
73 lines (72 loc) • 3.94 kB
TypeScript
import { AgentApplication, RouteHandler, RouteSelector, TurnContext, TurnState } from '@microsoft/agents-hosting';
import { TaskModuleTaskInfo } from './taskModuleTaskInfo';
export declare enum TaskModuleInvokeNames {
CONFIG_FETCH_INVOKE_NAME = "config/fetch",
CONFIG_SUBMIT_INVOKE_NAME = "config/submit",
FETCH_INVOKE_NAME = "task/fetch",
SUBMIT_INVOKE_NAME = "task/submit",
DEFAULT_TASK_DATA_FILTER = "verb"
}
interface TaskModuleOptions {
taskDataFilter?: string;
}
/**
* Class that exposes Teams task module-related events.
* Provides an organized way to handle task module operations in Microsoft Teams.
*/
export declare class TaskModule<TState extends TurnState> {
_app: AgentApplication<TState>;
_options: TaskModuleOptions;
/**
* Creates a new instance of the TaskModule class.
* @param app - The agent application
*/
constructor(app: AgentApplication<TState>, options?: TaskModuleOptions);
/**
* Handles task module fetch events. These occur when a task module is requested to be displayed.
* @param handler - The handler to call when a task module fetch event occurs
* @returns this (for method chaining)
*/
onFetch(handler: RouteHandler<TurnState>): this;
/**
* Registers a handler to process the submission of a task module.
* @remarks
* Handlers should respond with another TaskInfo object, message string, or `null` to indicate
* the task is completed.
* @template TData Optional. Type of the data object being passed to the handler.
* @param {string | RegExp | RouteSelector | string[] | RegExp[] | RouteSelector[]} verb - Name of the verb(s) to register the handler for.
* @param {(context: TurnContext, state: TState, data: TData) => Promise<TaskModuleTaskInfo | string | null | undefined>} handler - Function to call when the handler is triggered.
* @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 - Data object passed to the handler.
* @returns {Application<TState>} The application for chaining purposes.
*/
submit<TData extends Record<string, any> = Record<string, any>>(verb: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[], handler: (context: TurnContext, state: TState, data: TData) => Promise<TaskModuleTaskInfo | string | null | undefined>): AgentApplication<TState>;
/**
* Handles specific task module fetch events based on a verb/action.
* @param verb - The verb or action identifier to match against in the task module data
* @param handler - The handler to call when a matching task module fetch event occurs
* @returns this (for method chaining)
*/
onFetchByVerb(verb: string, handler: RouteHandler<TurnState>): this;
/**
* Handles specific task module submit events based on a verb/action.
* @param verb - The verb or action identifier to match against in the task module data
* @param handler - The handler to call when a matching task module submit event occurs
* @returns this (for method chaining)
*/
onSubmitByVerb(verb: string, handler: RouteHandler<TurnState>): this;
/**
* Handles configuration fetch events. These occur when an agent configuration is requested.
* @param handler - The handler to call when a configuration fetch event occurs
* @returns this (for method chaining)
*/
onConfigurationFetch(handler: RouteHandler<TurnState>): this;
/**
* Handles configuration submit events. These occur when an agent configuration is submitted.
* @param handler - The handler to call when a configuration submit event occurs
* @returns this (for method chaining)
*/
onConfigurationSubmit(handler: RouteHandler<TurnState>): this;
}
export {};