@microsoft/teams-ai
Version:
SDK focused on building AI based applications for Microsoft Teams.
150 lines • 6.17 kB
TypeScript
/**
* @module teams-ai
*/
/**
* Copyright (c) Microsoft Corporation. All rights reserved.
* Licensed under the MIT License.
*/
import { TurnContext } from 'botbuilder';
import { Application, RouteSelector, Query } from './Application';
import { TurnState } from './TurnState';
/**
* @private
*/
export declare const ACTION_INVOKE_NAME = "adaptiveCard/action";
/**
* Strongly typed Adaptive Card.
* @remarks
* see https://adaptivecards.io/explorer/ for schema details.
*/
export interface AdaptiveCard {
/**
* Required type field.
*/
type: 'AdaptiveCard';
/**
* Additional card fields.
*/
[key: string]: any;
}
/**
* Options for AdaptiveCards class.
*/
export interface AdaptiveCardsOptions {
/**
* Data field used to identify the Action.Submit handler to trigger.
* @remarks
* When an Action.Submit is triggered, the field name specified here will be used to determine
* the handler to route the request to.
*
* Defaults to a value of 'verb'.
*/
actionSubmitFilter?: string;
/**
* Data field used to specify how the response card will be presented after an action is executed.
* @remarks
* When an Action.Execute is triggered, the field name specified here will be used to determine
* how the response card will be presented.
*/
actionExecuteResponseType?: AdaptiveCardActionExecuteResponseType;
}
export declare enum AdaptiveCardActionExecuteResponseType {
/**
* The response card will be replaced the current one for the interactor who trigger the action.
*/
REPLACE_FOR_INTERACTOR = 0,
/**
* The response card will be replaced the current one for all users in the chat.
*/
REPLACE_FOR_ALL = 1,
/**
* The response card will be sent as a new message for all users in the chat.
*/
NEW_MESSAGE_FOR_ALL = 2
}
/**
* Parameters passed to AdaptiveCards.search() handler.
*/
export interface AdaptiveCardsSearchParams {
/**
* The query text.
*/
queryText: string;
/**
* The dataset to search.
*/
dataset: string;
}
/**
* Individual result returned from AdaptiveCards.search() handler.
*/
export interface AdaptiveCardSearchResult {
/**
* The title of the result.
*/
title: string;
/**
* The subtitle of the result.
*/
value: string;
}
/**
* AdaptiveCards class to enable fluent style registration of handlers related to Adaptive Cards.
* @template TState Type of the turn state object being persisted.
*/
export declare class AdaptiveCards<TState extends TurnState> {
private readonly _app;
/**
* Creates a new instance of the AdaptiveCards class.
* @param {Application<TState>} app The top level application class to register handlers with.
* @template TState The type of the state object used by the application.
*/
constructor(app: Application<TState>);
/**
* Adds a route to the application for handling Adaptive Card Action.Execute events.
* @template TData Optional. Type of the data associated with the action.
* @param {string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[]} verb The named action(s) to be handled.
* @param {(context: TurnContext, state: TState, data: TData) => Promise<AdaptiveCard | string>} handler The code to execute when the action is triggered.
* @param {TurnContext} handler.context The current turn context.
* @param {TState} handler.state The current turn state.
* @param {TData} handler.data The data associated with the action.
* @returns {Application<TState>} The application for chaining purposes.
*/
actionExecute<TData = Record<string, any>>(verb: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[], handler: (context: TurnContext, state: TState, data: TData) => Promise<AdaptiveCard | string>): Application<TState>;
/**
* Adds a route to the application for handling Adaptive Card Action.Submit events.
* @remarks
* The route will be added for the specified verb(s) and will be filtered using the
* `actionSubmitFilter` option. The default filter is to use the `verb` field.
*
* For outgoing AdaptiveCards you will need to include the verb's name in the cards Action.Submit.
* For example:
*
* ```JSON
* {
* "type": "Action.Submit",
* "title": "OK",
* "data": {
* "verb": "ok"
* }
* }
* ```
* @template TData Optional. Type of the data associated with the action.
* @param {string | RegExp | RouteSelector | string[] | RegExp[] | RouteSelector[]} verb The named action(s) to be handled.
* @param {(context: TurnContext, state: TState, data: TData) => Promise<AdaptiveCard | string>} handler The code to execute when the action is triggered.
* @returns {Application} The application for chaining purposes.
*/
actionSubmit<TData = Record<string, any>>(verb: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[], handler: (context: TurnContext, state: TState, data: TData) => Promise<void>): Application<TState>;
/**
* Adds a route to the application for handling the `Data.Query` request for an `Input.ChoiceSet`.
* @param {string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[]} dataset The named dataset(s) to be handled.
* @callback handler
* @param {Function} handler The code to execute when the query is triggered.
* @param {TurnContext} handler.context The current turn context for the handler callback.
* @param {TState} handler.state The current turn state for the handler callback.
* @param {Query<AdaptiveCardsSearchParams>} handler.query The query parameters for the handler callback.
* @returns {this} The application for chaining purposes.
*/
search(dataset: string | RegExp | RouteSelector | (string | RegExp | RouteSelector)[], handler: (context: TurnContext, state: TState, query: Query<AdaptiveCardsSearchParams>) => Promise<AdaptiveCardSearchResult[]>): Application<TState>;
}
//# sourceMappingURL=AdaptiveCards.d.ts.map