UNPKG

@microsoft/teams-ai

Version:

SDK focused on building AI based applications for Microsoft Teams.

92 lines 5.74 kB
/** * @module teams-ai */ /** * Copyright (c) Microsoft Corporation. All rights reserved. * Licensed under the MIT License. */ import { BotConfigAuth, TaskModuleResponse, TaskModuleTaskInfo, TurnContext } from 'botbuilder'; import { Application, RouteSelector } from './Application'; import { TurnState } from './TurnState'; 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" } /** * Options for TaskModules class. */ export interface TaskModulesOptions { /** * Data field to use to ide1ntify the verb of the handler to trigger. * @remarks * When a task module is triggered, the field name specified here will be used to determine * the name of the verb for the handler to route the request to. * * Defaults to a value of 'verb'. */ taskDataFilter?: string; } /** * TaskModules class to enable fluent style registration of handlers related to Task Modules. * @template TState Type of the turn state object being persisted. */ export declare class TaskModules<TState extends TurnState> { private readonly _app; /** * Creates a new instance of the TaskModules class. * @param {Application} app Top level application class to register handlers with. */ constructor(app: Application<TState>); /** * Registers a handler to process the initial fetch of the task module. * @remarks * Handlers should respond with either an initial TaskInfo object or a string containing * a message to display to the user. * @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>} 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. */ fetch<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>): Application<TState>; /** * 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>): Application<TState>; /** * Registers a handler for fetching Teams config data for Auth or Task Modules * @template TData Optional. Type of the data object being passed to the handler. * @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. */ configFetch<TData extends Record<string, any>>(handler: (context: TurnContext, state: TState, data: TData) => Promise<BotConfigAuth | TaskModuleResponse>): Application<TState>; /** * Registers a handler for submitting Teams config data for Auth or Task Modules * @template TData Optional. Type of the data object being passed to the handler. * @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. */ configSubmit<TData extends Record<string, any>>(handler: (context: TurnContext, state: TState, data: TData) => Promise<BotConfigAuth | TaskModuleResponse>): Application<TState>; } //# sourceMappingURL=TaskModules.d.ts.map