UNPKG

2.27 kBTypeScriptView Raw
1/**
2 * @module botkit
3 */
4/**
5 * Copyright (c) Microsoft Corporation. All rights reserved.
6 * Licensed under the MIT License.
7 */
8import { BotkitMessage } from './core';
9import { BotWorker } from './botworker';
10import { TeamsInfo, MiddlewareSet, TurnContext } from 'botbuilder';
11/**
12 * This is a specialized version of [Botkit's core BotWorker class](core.md#BotWorker) that includes additional methods for interacting with Microsoft Teams.
13 * It includes all functionality from the base class, as well as the extension methods below.
14 * This BotWorker is used with the built-in Bot Framework adapter.
15 * @noInheritDoc
16 */
17export declare class TeamsBotWorker extends BotWorker {
18 /**
19 * Grants access to the TeamsInfo helper class
20 * See: https://docs.microsoft.com/en-us/javascript/api/botbuilder/teamsinfo?view=botbuilder-ts-latest
21 */
22 teams: TeamsInfo;
23 /**
24 * Reply to a Teams task module task/fetch or task/submit with a task module response.
25 * See https://docs.microsoft.com/en-us/microsoftteams/platform/task-modules-and-cards/task-modules/task-modules-bots
26 * @param message
27 * @param taskInfo an object in the form {type, value}
28 */
29 replyWithTaskInfo(message: BotkitMessage, taskInfo: any): Promise<any>;
30}
31/**
32 * When used, causes Botkit to emit special events for teams "invokes"
33 * Based on https://github.com/microsoft/botbuilder-js/blob/master/libraries/botbuilder/src/teamsActivityHandler.ts
34 * This allows Botkit bots to respond directly to task/fetch or task/submit events, as an example.
35 * To use this, bind it to the adapter before creating the Botkit controller:
36 * ```javascript
37 * const Botkit = new Botkit({...});
38 * botkit.adapter.use(new TeamsInvokeMiddleware());
39 *
40 * // can bind directly to task/fetch, task/submit and other invoke types used by teams
41 * controller.on('task/fetch', async(bot, message) => {
42 * await bot.replyWithTaskInfo(message, taskInfo);
43 * });
44 * ```
45 */
46export declare class TeamsInvokeMiddleware extends MiddlewareSet {
47 /**
48 * Not for direct use - implements the MiddlewareSet's required onTurn function used to process the event
49 * @param context
50 * @param next
51 */
52 onTurn(context: TurnContext, next: () => Promise<any>): Promise<void>;
53}