UNPKG

25.2 kBTypeScriptView Raw
1/**
2 * @module botbuilder
3 */
4/**
5 * Copyright (c) Microsoft Corporation. All rights reserved.
6 * Licensed under the MIT License.
7 */
8import { ActivityHandler, AdaptiveCardInvokeResponse, AppBasedLinkQuery, ChannelInfo, FileConsentCardResponse, InvokeResponse, MeetingStartEventDetails, MeetingEndEventDetails, MessagingExtensionAction, MessagingExtensionActionResponse, MessagingExtensionQuery, MessagingExtensionResponse, O365ConnectorCardActionQuery, SigninStateVerificationQuery, TabRequest, TabResponse, TabSubmit, TaskModuleRequest, TaskModuleResponse, TeamsChannelAccount, TeamInfo, TurnContext } from 'botbuilder-core';
9/**
10 * Adds support for Microsoft Teams specific events and interactions.
11 * @remarks
12 * Developers may handle Conversation Update activities sent from Microsoft Teams via two methods:
13 * 1. Overriding methods starting with `on..` and *not* ending in `..Event()` (e.g. `onTeamsMembersAdded()`), or instead
14 * 2. Passing callbacks to methods starting with `on..` *and* ending in `...Event()` (e.g. `onTeamsMembersAddedEvent()`),
15 * to stay in line with older {@see ActivityHandler} implementation.
16 *
17 * Developers should use either #1 or #2, above for all Conversation Update activities and not *both* #2 and #3 for the same activity. Meaning,
18 * developers should override `onTeamsMembersAdded()` and not use both `onTeamsMembersAdded()` and `onTeamsMembersAddedEvent()`.
19 *
20 * Developers wanting to handle Invoke activities *must* override methods starting with `handle...()` (e.g. `handleTeamsTaskModuleFetch()`).
21 */
22export declare class TeamsActivityHandler extends ActivityHandler {
23 /**
24 * Invoked when an invoke activity is received from the connector.
25 * Invoke activities can be used to communicate many different things.
26 * @param context A context object for this turn.
27 * @returns An Invoke Response for the activity.
28 */
29 protected onInvokeActivity(context: TurnContext): Promise<InvokeResponse>;
30 /**
31 * Handles a Teams Card Action Invoke activity.
32 * @param context A context object for this turn.
33 * @returns An Invoke Response for the activity.
34 */
35 protected handleTeamsCardActionInvoke(context: TurnContext): Promise<InvokeResponse>;
36 /**
37 * Receives invoke activities with Activity name of 'fileConsent/invoke'. Handlers registered here run before
38 * `handleTeamsFileConsentAccept` and `handleTeamsFileConsentDecline`.
39 * Developers are not passed a pointer to the next `handleTeamsFileConsent` handler because the _wrapper_ around
40 * the handler will call `onDialogs` handlers after delegating to `handleTeamsFileConsentAccept` or `handleTeamsFileConsentDecline`.
41 * @param context A context object for this turn.
42 * @param fileConsentCardResponse Represents the value of the invoke activity sent when the user acts on a file consent card.
43 * @returns A promise that represents the work queued.
44 */
45 protected handleTeamsFileConsent(context: TurnContext, fileConsentCardResponse: FileConsentCardResponse): Promise<void>;
46 /**
47 * Receives invoke activities with Activity name of 'fileConsent/invoke' with confirmation from user
48 * @remarks
49 * This type of invoke activity occur during the File Consent flow.
50 * @param context A context object for this turn.
51 * @param fileConsentCardResponse Represents the value of the invoke activity sent when the user acts on a file consent card.
52 * @returns A promise that represents the work queued.
53 */
54 protected handleTeamsFileConsentAccept(context: TurnContext, fileConsentCardResponse: FileConsentCardResponse): Promise<void>;
55 /**
56 * Receives invoke activities with Activity name of 'fileConsent/invoke' with decline from user
57 * @remarks
58 * This type of invoke activity occur during the File Consent flow.
59 * @param context A context object for this turn.
60 * @param fileConsentCardResponse Represents the value of the invoke activity sent when the user acts on a file consent card.
61 * @returns A promise that represents the work queued.
62 */
63 protected handleTeamsFileConsentDecline(context: TurnContext, fileConsentCardResponse: FileConsentCardResponse): Promise<void>;
64 /**
65 * Receives invoke activities with Activity name of 'actionableMessage/executeAction'.
66 * @param context A context object for this turn.
67 * @param query The O365 connector card HttpPOST invoke query.
68 * @returnsa A promise that represents the work queued.
69 */
70 protected handleTeamsO365ConnectorCardAction(context: TurnContext, query: O365ConnectorCardActionQuery): Promise<void>;
71 /**
72 * Invoked when a signIn invoke activity is received from the connector.
73 * @param context A context object for this turn.
74 * @returns A promise that represents the work queued.
75 */
76 protected onSignInInvoke(context: TurnContext): Promise<void>;
77 /**
78 * Receives invoke activities with Activity name of 'signin/verifyState'.
79 * @param context A context object for this turn.
80 * @param query Signin state (part of signin action auth flow) verification invoke query.
81 * @returns A promise that represents the work queued.
82 */
83 protected handleTeamsSigninVerifyState(context: TurnContext, query: SigninStateVerificationQuery): Promise<void>;
84 /**
85 * Receives invoke activities with Activity name of 'signin/tokenExchange'
86 * @param context A context object for this turn.
87 * @param query Signin state (part of signin action auth flow) verification invoke query
88 * @returns A promise that represents the work queued.
89 */
90 protected handleTeamsSigninTokenExchange(context: TurnContext, query: SigninStateVerificationQuery): Promise<void>;
91 /**
92 * Receives invoke activities with Activity name of 'composeExtension/onCardButtonClicked'
93 * @param context A context object for this turn.
94 * @param cardData Object representing the card data.
95 * @returns A promise that represents the work queued.
96 */
97 protected handleTeamsMessagingExtensionCardButtonClicked(context: TurnContext, cardData: any): Promise<void>;
98 /**
99 * Receives invoke activities with Activity name of 'task/fetch'
100 * @param context A context object for this turn.
101 * @param taskModuleRequest The task module invoke request value payload.
102 * @returns A Task Module Response for the request.
103 */
104 protected handleTeamsTaskModuleFetch(context: TurnContext, taskModuleRequest: TaskModuleRequest): Promise<TaskModuleResponse>;
105 /**
106 * Receives invoke activities with Activity name of 'task/submit'
107 * @param context A context object for this turn.
108 * @param taskModuleRequest The task module invoke request value payload.
109 * @returns A Task Module Response for the request.
110 */
111 protected handleTeamsTaskModuleSubmit(context: TurnContext, taskModuleRequest: TaskModuleRequest): Promise<TaskModuleResponse>;
112 /**
113 * Receives invoke activities with Activity name of 'tab/fetch'
114 * @param context A context object for this turn.
115 * @param tabRequest The tab invoke request value payload.
116 * @returns A Tab Response for the request.
117 */
118 protected handleTeamsTabFetch(context: TurnContext, tabRequest: TabRequest): Promise<TabResponse>;
119 /**
120 * Receives invoke activities with Activity name of 'tab/submit'
121 * @param context A context object for this turn.
122 * @param tabSubmit The tab submit invoke request value payload.
123 * @returns A Tab Response for the request.
124 */
125 protected handleTeamsTabSubmit(context: TurnContext, tabSubmit: TabSubmit): Promise<TabResponse>;
126 /**
127 * Receives invoke activities with Activity name of 'composeExtension/queryLink'
128 * @remarks
129 * Used in creating a Search-based Message Extension.
130 * @param context A context object for this turn.
131 * @param query he invoke request body type for app-based link query.
132 * @returns The Messaging Extension Response for the query.
133 */
134 protected handleTeamsAppBasedLinkQuery(context: TurnContext, query: AppBasedLinkQuery): Promise<MessagingExtensionResponse>;
135 /**
136 * Receives invoke activities with the name 'composeExtension/query'.
137 * @remarks
138 * Used in creating a Search-based Message Extension.
139 * @param context A context object for this turn.
140 * @param query The query for the search command.
141 * @returns The Messaging Extension Response for the query.
142 */
143 protected handleTeamsMessagingExtensionQuery(context: TurnContext, query: MessagingExtensionQuery): Promise<MessagingExtensionResponse>;
144 /**
145 * Receives invoke activities with the name 'composeExtension/selectItem'.
146 * @remarks
147 * Used in creating a Search-based Message Extension.
148 * @param context A context object for this turn.
149 * @param query he object representing the query.
150 * @returns The Messaging Extension Response for the query.
151 */
152 protected handleTeamsMessagingExtensionSelectItem(context: TurnContext, query: any): Promise<MessagingExtensionResponse>;
153 /**
154 * Receives invoke activities with the name 'composeExtension/submitAction' and dispatches to botMessagePreview-flows as applicable.
155 * @remarks
156 * A handler registered through this method does not dispatch to the next handler (either `handleTeamsMessagingExtensionSubmitAction`, `handleTeamsMessagingExtensionBotMessagePreviewEdit`, or `handleTeamsMessagingExtensionBotMessagePreviewSend`).
157 * This method exists for developers to optionally add more logic before the TeamsActivityHandler routes the activity to one of the
158 * previously mentioned handlers.
159 * @param context A context object for this turn.
160 * @param action The messaging extension action.
161 * @returns The Messaging Extension Action Response for the action.
162 */
163 protected handleTeamsMessagingExtensionSubmitActionDispatch(context: TurnContext, action: MessagingExtensionAction): Promise<MessagingExtensionActionResponse>;
164 /**
165 * Receives invoke activities with the name 'composeExtension/submitAction'.
166 * @param context A context object for this turn.
167 * @param action The messaging extension action.
168 * @returns The Messaging Extension Action Response for the action.
169 */
170 protected handleTeamsMessagingExtensionSubmitAction(context: TurnContext, action: MessagingExtensionAction): Promise<MessagingExtensionActionResponse>;
171 /**
172 * Receives invoke activities with the name 'composeExtension/submitAction' with the 'botMessagePreview' property present on activity.value.
173 * The value for 'botMessagePreview' is 'edit'.
174 * @param context A context object for this turn.
175 * @param action The messaging extension action.
176 * @returns The Messaging Extension Action Response for the action.
177 */
178 protected handleTeamsMessagingExtensionBotMessagePreviewEdit(context: TurnContext, action: MessagingExtensionAction): Promise<MessagingExtensionActionResponse>;
179 /**
180 * Receives invoke activities with the name 'composeExtension/submitAction' with the 'botMessagePreview' property present on activity.value.
181 * The value for 'botMessagePreview' is 'send'.
182 * @param context A context object for this turn.
183 * @param action The messaging extension action.
184 * @returns The Messaging Extension Action Response for the action.
185 */
186 protected handleTeamsMessagingExtensionBotMessagePreviewSend(context: TurnContext, action: MessagingExtensionAction): Promise<MessagingExtensionActionResponse>;
187 /**
188 * Receives invoke activities with the name 'composeExtension/fetchTask'
189 * @param context A context object for this turn.
190 * @param action The messaging extension action.
191 * @returns The Messaging Extension Action Response for the action.
192 */
193 protected handleTeamsMessagingExtensionFetchTask(context: TurnContext, action: MessagingExtensionAction): Promise<MessagingExtensionActionResponse>;
194 /**
195 * Receives invoke activities with the name 'composeExtension/querySettingUrl'
196 * @param context A context object for this turn.
197 * @param query The Messaging extension query.
198 * @returns The Messaging Extension Action Response for the query.
199 */
200 protected handleTeamsMessagingExtensionConfigurationQuerySettingUrl(context: TurnContext, query: MessagingExtensionQuery): Promise<MessagingExtensionResponse>;
201 /**
202 * Receives invoke activities with the name 'adaptiveCard/action'
203 * @param context A context object for this turn.
204 * @returns The Messaging Extension Action Response for the query.
205 */
206 protected handleAdaptiveCardAction(context: TurnContext): Promise<AdaptiveCardInvokeResponse>;
207 /**
208 * Receives invoke activities with the name 'composeExtension/setting'
209 * @param context A context object for this turn.
210 * @param settings Object representing the configuration settings.
211 * @returns A promise that represents the work queued.
212 */
213 protected handleTeamsMessagingExtensionConfigurationSetting(context: TurnContext, settings: any): Promise<void>;
214 /**
215 * Override this method to change the dispatching of ConversationUpdate activities.
216 * @param context A context object for this turn.
217 * @returns A promise that represents the work queued.
218 */
219 protected dispatchConversationUpdateActivity(context: TurnContext): Promise<void>;
220 /**
221 * Called in `dispatchConversationUpdateActivity()` to trigger the `'TeamsMembersAdded'` handlers.
222 * Override this in a derived class to provide logic for when members other than the bot
223 * join the channel, such as your bot's welcome logic.
224 * @remarks
225 * If no handlers are registered for the `'TeamsMembersAdded'` event, the `'MembersAdded'` handlers will run instead.
226 * @param context A context object for this turn.
227 * @returns A promise that represents the work queued.
228 */
229 protected onTeamsMembersAdded(context: TurnContext): Promise<void>;
230 /**
231 * Called in `dispatchConversationUpdateActivity()` to trigger the `'TeamsMembersRemoved'` handlers.
232 * Override this in a derived class to provide logic for when members other than the bot
233 * leave the channel, such as your bot's good-bye logic.
234 * @remarks
235 * If no handlers are registered for the `'TeamsMembersRemoved'` event, the `'MembersRemoved'` handlers will run instead.
236 * @param context A context object for this turn.
237 * @returns A promise that represents the work queued.
238 */
239 protected onTeamsMembersRemoved(context: TurnContext): Promise<void>;
240 /**
241 * Invoked when a Channel Created event activity is received from the connector.
242 * Channel Created corresponds to the user creating a new channel.
243 * Override this in a derived class to provide logic for when a channel is created.
244 * @param context A context object for this turn.
245 * @returns A promise that represents the work queued.
246 */
247 protected onTeamsChannelCreated(context: any): Promise<void>;
248 /**
249 * Invoked when a Channel Deleted event activity is received from the connector.
250 * Channel Deleted corresponds to the user deleting a channel.
251 * Override this in a derived class to provide logic for when a channel is deleted.
252 * @param context A context object for this turn.
253 * @returns A promise that represents the work queued.
254 */
255 protected onTeamsChannelDeleted(context: any): Promise<void>;
256 /**
257 * Invoked when a Channel Renamed event activity is received from the connector.
258 * Channel Renamed corresponds to the user renaming a new channel.
259 * Override this in a derived class to provide logic for when a channel is renamed.
260 * @param context A context object for this turn.
261 * @returns A promise that represents the work queued.
262 */
263 protected onTeamsChannelRenamed(context: any): Promise<void>;
264 /**
265 * Invoked when a Team Archived event activity is received from the connector.
266 * Team Archived corresponds to the user archiving a team.
267 * Override this in a derived class to provide logic for when a team is archived.
268 * @param context The context for this turn.
269 * @returns A promise that represents the work queued.
270 */
271 protected onTeamsTeamArchived(context: any): Promise<void>;
272 /**
273 * Invoked when a Team Deleted event activity is received from the connector.
274 * Team Deleted corresponds to the user deleting a team.
275 * Override this in a derived class to provide logic for when a team is deleted.
276 * @param context The context for this turn.
277 * @returns A promise that represents the work queued.
278 */
279 protected onTeamsTeamDeleted(context: any): Promise<void>;
280 /**
281 * Invoked when a Team Hard Deleted event activity is received from the connector.
282 * Team Hard Deleted corresponds to the user hard-deleting a team.
283 * Override this in a derived class to provide logic for when a team is hard-deleted.
284 * @param context The context for this turn.
285 * @returns A promise that represents the work queued.
286 */
287 protected onTeamsTeamHardDeleted(context: any): Promise<void>;
288 /**
289 *
290 * @param context
291 * Invoked when a Channel Restored event activity is received from the connector.
292 * Channel Restored corresponds to the user restoring a previously deleted channel.
293 * Override this in a derived class to provide logic for when a channel is restored.
294 * @param context The context for this turn.
295 * @returns A promise that represents the work queued.
296 */
297 protected onTeamsChannelRestored(context: any): Promise<void>;
298 /**
299 * Invoked when a Team Renamed event activity is received from the connector.
300 * Team Renamed corresponds to the user renaming a team.
301 * Override this in a derived class to provide logic for when a team is renamed.
302 * @param context The context for this turn.
303 * @returns A promise that represents the work queued.
304 */
305 protected onTeamsTeamRenamed(context: any): Promise<void>;
306 /**
307 * Invoked when a Team Restored event activity is received from the connector.
308 * Team Restored corresponds to the user restoring a team.
309 * Override this in a derived class to provide logic for when a team is restored.
310 * @param context The context for this turn.
311 * @returns A promise that represents the work queued.
312 */
313 protected onTeamsTeamRestored(context: any): Promise<void>;
314 /**
315 * Invoked when a Team Unarchived event activity is received from the connector.
316 * Team Unarchived corresponds to the user unarchiving a team.
317 * Override this in a derived class to provide logic for when a team is unarchived.
318 * @param context The context for this turn.
319 * @returns A promise that represents the work queued.
320 */
321 protected onTeamsTeamUnarchived(context: any): Promise<void>;
322 /**
323 * Registers a handler for TeamsMembersAdded events, such as for when members other than the bot
324 * join the channel, such as your bot's welcome logic.
325 * @param handler
326 * @returns A promise that represents the work queued.
327 */
328 onTeamsMembersAddedEvent(handler: (membersAdded: TeamsChannelAccount[], teamInfo: TeamInfo, context: TurnContext, next: () => Promise<void>) => Promise<void>): this;
329 /**
330 * Registers a handler for TeamsMembersRemoved events, such as for when members other than the bot
331 * leave the channel, such as your bot's good-bye logic.
332 * @param handler
333 * @returns A promise that represents the work queued.
334 */
335 onTeamsMembersRemovedEvent(handler: (membersRemoved: TeamsChannelAccount[], teamInfo: TeamInfo, context: TurnContext, next: () => Promise<void>) => Promise<void>): this;
336 /**
337 * Registers a handler for TeamsChannelCreated events, such as for when a channel is created.
338 * @param handler
339 * @returns A promise that represents the work queued.
340 */
341 onTeamsChannelCreatedEvent(handler: (channelInfo: ChannelInfo, teamInfo: TeamInfo, context: TurnContext, next: () => Promise<void>) => Promise<void>): this;
342 /**
343 * Registers a handler for TeamsChannelDeleted events, such as for when a channel is deleted.
344 * @param handler
345 * @returns A promise that represents the work queued.
346 */
347 onTeamsChannelDeletedEvent(handler: (channelInfo: ChannelInfo, teamInfo: TeamInfo, context: TurnContext, next: () => Promise<void>) => Promise<void>): this;
348 /**
349 * Registers a handler for TeamsChannelRenamed events, such as for when a channel is renamed.
350 * @param handler
351 * @returns A promise that represents the work queued.
352 */
353 onTeamsChannelRenamedEvent(handler: (channelInfo: ChannelInfo, teamInfo: TeamInfo, context: TurnContext, next: () => Promise<void>) => Promise<void>): this;
354 /**
355 * Registers a handler for TeamsTeamArchived events, such as for when a team is archived.
356 * @param handler
357 * @returns A promise that represents the work queued.
358 */
359 onTeamsTeamArchivedEvent(handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise<void>) => Promise<void>): this;
360 /**
361 * Registers a handler for TeamsTeamDeleted events, such as for when a team is deleted.
362 * @param handler
363 * @returns A promise that represents the work queued.
364 */
365 onTeamsTeamDeletedEvent(handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise<void>) => Promise<void>): this;
366 /**
367 * Registers a handler for TeamsTeamHardDeleted events, such as for when a team is hard-deleted.
368 * @param handler
369 * @returns A promise that represents the work queued.
370 */
371 onTeamsTeamHardDeletedEvent(handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise<void>) => Promise<void>): this;
372 /**
373 * Registers a handler for TeamsChannelRestored events, such as for when a channel is restored.
374 * @param handler
375 * @returns A promise that represents the work queued.
376 */
377 onTeamsChannelRestoredEvent(handler: (channelInfo: ChannelInfo, teamInfo: TeamInfo, context: TurnContext, next: () => Promise<void>) => Promise<void>): this;
378 /**
379 * Registers a handler for TeamsTeamRenamed events, such as for when a team is renamed.
380 * @param handler
381 * @returns A promise that represents the work queued.
382 */
383 onTeamsTeamRenamedEvent(handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise<void>) => Promise<void>): this;
384 /**
385 * Registers a handler for TeamsTeamRestored events, such as for when a team is restored.
386 * @param handler
387 * @returns A promise that represents the work queued.
388 */
389 onTeamsTeamRestoredEvent(handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise<void>) => Promise<void>): this;
390 /**
391 * Registers a handler for TeamsTeamUnarchived events, such as for when a team is unarchived.
392 * @param handler
393 * @returns A promise that represents the work queued.
394 */
395 onTeamsTeamUnarchivedEvent(handler: (teamInfo: TeamInfo, context: TurnContext, next: () => Promise<void>) => Promise<void>): this;
396 /**
397 * Runs the _event_ sub-type handlers, as appropriate, and then continues the event emission process.
398 *
399 * @param context The context object for the current turn.
400 * @returns A promise that represents the work queued.
401 *
402 * @remarks
403 * Override this method to support channel-specific behavior across multiple channels or to add
404 * custom event sub-type events.
405 */
406 protected dispatchEventActivity(context: TurnContext): Promise<void>;
407 /**
408 * Invoked when a Meeting Started event activity is received from the connector.
409 * Override this in a derived class to provide logic for when a meeting is started.
410 *
411 * @param context The context for this turn.
412 * @returns A promise that represents the work queued.
413 */
414 protected onTeamsMeetingStart(context: TurnContext): Promise<void>;
415 /**
416 * Invoked when a Meeting End event activity is received from the connector.
417 * Override this in a derived class to provide logic for when a meeting is ended.
418 *
419 * @param context The context for this turn.
420 * @returns A promise that represents the work queued.
421 */
422 protected onTeamsMeetingEnd(context: TurnContext): Promise<void>;
423 /**
424 * Registers a handler for when a Teams meeting starts.
425 *
426 * @param handler A callback that handles Meeting Start events.
427 * @returns A promise that represents the work queued.
428 */
429 onTeamsMeetingStartEvent(handler: (meeting: MeetingStartEventDetails, context: TurnContext, next: () => Promise<void>) => Promise<void>): this;
430 /**
431 * Registers a handler for when a Teams meeting ends.
432 *
433 * @param handler A callback that handles Meeting End events.
434 * @returns A promise that represents the work queued.
435 */
436 onTeamsMeetingEndEvent(handler: (meeting: MeetingEndEventDetails, context: TurnContext, next: () => Promise<void>) => Promise<void>): this;
437}
438//# sourceMappingURL=teamsActivityHandler.d.ts.map
\No newline at end of file