@microsoft/teamsfx 0.6.2 → 0.6.3-alpha.8d048e1f1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.esm2017.js +448 -1
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +997 -2
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +461 -1
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +1060 -0
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +5 -3
- package/types/teamsfx.d.ts +807 -0
package/types/teamsfx.d.ts
CHANGED
|
@@ -1,13 +1,29 @@
|
|
|
1
1
|
import { AccessToken } from '@azure/identity';
|
|
2
|
+
import { Activity } from 'botbuilder-core';
|
|
3
|
+
import { Activity as Activity_2 } from 'botbuilder';
|
|
4
|
+
import { Attachment } from 'botbuilder';
|
|
2
5
|
import { AuthenticationProvider } from '@microsoft/microsoft-graph-client';
|
|
6
|
+
import { AxiosInstance } from 'axios';
|
|
7
|
+
import { AxiosRequestConfig } from 'axios';
|
|
8
|
+
import { BotFrameworkAdapter } from 'botbuilder';
|
|
9
|
+
import { CardAction } from 'botbuilder';
|
|
10
|
+
import { CardImage } from 'botbuilder';
|
|
11
|
+
import { ChannelInfo } from 'botbuilder';
|
|
3
12
|
import { Client } from '@microsoft/microsoft-graph-client';
|
|
4
13
|
import { ConnectionConfig } from 'tedious';
|
|
14
|
+
import { ConversationReference } from 'botbuilder';
|
|
5
15
|
import { Dialog } from 'botbuilder-dialogs';
|
|
6
16
|
import { DialogContext } from 'botbuilder-dialogs';
|
|
7
17
|
import { DialogTurnResult } from 'botbuilder-dialogs';
|
|
8
18
|
import { GetTokenOptions } from '@azure/identity';
|
|
19
|
+
import { HeroCard } from 'botbuilder';
|
|
20
|
+
import { O365ConnectorCard } from 'botbuilder';
|
|
21
|
+
import { ReceiptCard } from 'botbuilder';
|
|
22
|
+
import { TeamsChannelAccount } from 'botbuilder';
|
|
23
|
+
import { ThumbnailCard } from 'botbuilder';
|
|
9
24
|
import { TokenCredential } from '@azure/identity';
|
|
10
25
|
import { TokenResponse } from 'botframework-schema';
|
|
26
|
+
import { TurnContext } from 'botbuilder-core';
|
|
11
27
|
|
|
12
28
|
/**
|
|
13
29
|
* Represent Microsoft 365 tenant identity, and it is usually used when user is not involved like time-triggered automation job.
|
|
@@ -123,6 +139,328 @@ export declare interface AuthenticationConfiguration {
|
|
|
123
139
|
readonly applicationIdUri?: string;
|
|
124
140
|
}
|
|
125
141
|
|
|
142
|
+
/**
|
|
143
|
+
* Defines method that injects authentication info to http requests
|
|
144
|
+
*
|
|
145
|
+
* @beta
|
|
146
|
+
*/
|
|
147
|
+
export declare interface AuthProvider {
|
|
148
|
+
/**
|
|
149
|
+
* Adds authentication info to http requests
|
|
150
|
+
*
|
|
151
|
+
* @param config - Contains all the request information and can be updated to include extra authentication info.
|
|
152
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
153
|
+
*
|
|
154
|
+
* @beta
|
|
155
|
+
*/
|
|
156
|
+
AddAuthenticationInfo: (config: AxiosRequestConfig) => Promise<AxiosRequestConfig>;
|
|
157
|
+
}
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Provider that handles Bearer Token authentication
|
|
161
|
+
*
|
|
162
|
+
* @beta
|
|
163
|
+
*/
|
|
164
|
+
export declare class BearerTokenAuthProvider implements AuthProvider {
|
|
165
|
+
private getToken;
|
|
166
|
+
/**
|
|
167
|
+
* @param getToken Function that returns the content of bearer token used in http request
|
|
168
|
+
*
|
|
169
|
+
* @beta
|
|
170
|
+
*/
|
|
171
|
+
constructor(getToken: () => Promise<string>);
|
|
172
|
+
/**
|
|
173
|
+
* Adds authentication info to http requests
|
|
174
|
+
*
|
|
175
|
+
* @param config - Contains all the request information and can be updated to include extra authentication info.
|
|
176
|
+
* Refer https://axios-http.com/docs/req_config for detailed document.
|
|
177
|
+
*
|
|
178
|
+
* @beta
|
|
179
|
+
*/
|
|
180
|
+
AddAuthenticationInfo(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* A {@link NotificationTarget} that represents a team channel.
|
|
185
|
+
*
|
|
186
|
+
* @remarks
|
|
187
|
+
* It's recommended to get channels from {@link TeamsBotInstallation.channels()}.
|
|
188
|
+
*
|
|
189
|
+
* @beta
|
|
190
|
+
*/
|
|
191
|
+
export declare class Channel implements NotificationTarget {
|
|
192
|
+
/**
|
|
193
|
+
* The parent {@link TeamsBotInstallation} where this channel is created from.
|
|
194
|
+
*
|
|
195
|
+
* @beta
|
|
196
|
+
*/
|
|
197
|
+
readonly parent: TeamsBotInstallation;
|
|
198
|
+
/**
|
|
199
|
+
* Detailed channel information.
|
|
200
|
+
*
|
|
201
|
+
* @beta
|
|
202
|
+
*/
|
|
203
|
+
readonly info: ChannelInfo;
|
|
204
|
+
/**
|
|
205
|
+
* Notification target type. For channel it's always "Channel".
|
|
206
|
+
*
|
|
207
|
+
* @beta
|
|
208
|
+
*/
|
|
209
|
+
readonly type: NotificationTargetType;
|
|
210
|
+
/**
|
|
211
|
+
* Constuctor.
|
|
212
|
+
*
|
|
213
|
+
* @remarks
|
|
214
|
+
* It's recommended to get channels from {@link TeamsBotInstallation.channels()}, instead of using this constructor.
|
|
215
|
+
*
|
|
216
|
+
* @param parent - The parent {@link TeamsBotInstallation} where this channel is created from.
|
|
217
|
+
* @param info - Detailed channel information.
|
|
218
|
+
*
|
|
219
|
+
* @beta
|
|
220
|
+
*/
|
|
221
|
+
constructor(parent: TeamsBotInstallation, info: ChannelInfo);
|
|
222
|
+
/**
|
|
223
|
+
* Send a plain text message.
|
|
224
|
+
*
|
|
225
|
+
* @param text - the plain text message.
|
|
226
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
227
|
+
*
|
|
228
|
+
* @beta
|
|
229
|
+
*/
|
|
230
|
+
sendMessage(text: string): Promise<void>;
|
|
231
|
+
/**
|
|
232
|
+
* Send an adaptive card message.
|
|
233
|
+
*
|
|
234
|
+
* @param card - the adaptive card raw JSON.
|
|
235
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
236
|
+
*
|
|
237
|
+
* @beta
|
|
238
|
+
*/
|
|
239
|
+
sendAdaptiveCard(card: unknown): Promise<void>;
|
|
240
|
+
/**
|
|
241
|
+
* @internal
|
|
242
|
+
*/
|
|
243
|
+
private newConversation;
|
|
244
|
+
}
|
|
245
|
+
|
|
246
|
+
/**
|
|
247
|
+
* A command bot for receiving commands and sending responses in Teams.
|
|
248
|
+
*
|
|
249
|
+
* @remarks
|
|
250
|
+
* Ensure each command should ONLY be registered with the command once, otherwise it'll cause unexpected behavior if you register the same command more than once.
|
|
251
|
+
*
|
|
252
|
+
* @beta
|
|
253
|
+
*/
|
|
254
|
+
export declare class CommandBot {
|
|
255
|
+
private readonly adapter;
|
|
256
|
+
private readonly middleware;
|
|
257
|
+
/**
|
|
258
|
+
* Creates a new instance of the `CommandBot`.
|
|
259
|
+
*
|
|
260
|
+
* @param adapter The bound `BotFrameworkAdapter`.
|
|
261
|
+
* @param options - initialize options
|
|
262
|
+
*
|
|
263
|
+
* @beta
|
|
264
|
+
*/
|
|
265
|
+
constructor(adapter: BotFrameworkAdapter, options?: CommandOptions);
|
|
266
|
+
/**
|
|
267
|
+
* Registers a command into the command bot.
|
|
268
|
+
*
|
|
269
|
+
* @param command The command to registered.
|
|
270
|
+
*
|
|
271
|
+
* @beta
|
|
272
|
+
*/
|
|
273
|
+
registerCommand(command: TeamsFxBotCommandHandler): void;
|
|
274
|
+
/**
|
|
275
|
+
* Registers commands into the command bot.
|
|
276
|
+
*
|
|
277
|
+
* @param commands The command to registered.
|
|
278
|
+
*
|
|
279
|
+
* @beta
|
|
280
|
+
*/
|
|
281
|
+
registerCommands(commands: TeamsFxBotCommandHandler[]): void;
|
|
282
|
+
}
|
|
283
|
+
|
|
284
|
+
/**
|
|
285
|
+
* Interface for a command messagge that can handled in a command handler.
|
|
286
|
+
*/
|
|
287
|
+
export declare interface CommandMessage {
|
|
288
|
+
/**
|
|
289
|
+
* Text of the message sent by the user.
|
|
290
|
+
*/
|
|
291
|
+
text: string;
|
|
292
|
+
/**
|
|
293
|
+
* The capture groups that matched to the {@link triggerPatterns} in a {@link TeamsFxBotCommandHandler} instance.
|
|
294
|
+
*/
|
|
295
|
+
matches?: RegExpMatchArray;
|
|
296
|
+
}
|
|
297
|
+
|
|
298
|
+
/**
|
|
299
|
+
* Options to initialize {@link CommandBot}.
|
|
300
|
+
*
|
|
301
|
+
* @beta
|
|
302
|
+
*/
|
|
303
|
+
export declare interface CommandOptions {
|
|
304
|
+
/**
|
|
305
|
+
* The commands to registered with the command bot. Each command should implement the interface {@link TeamsFxBotCommandHandler} so that it can be correctly handled by this command bot.
|
|
306
|
+
*
|
|
307
|
+
* @beta
|
|
308
|
+
*/
|
|
309
|
+
commands?: TeamsFxBotCommandHandler[];
|
|
310
|
+
}
|
|
311
|
+
|
|
312
|
+
/**
|
|
313
|
+
* Provide utilities for bot conversation, including:
|
|
314
|
+
* - handle command and response.
|
|
315
|
+
* - send notification to varies targets (e.g., member, channel, incoming wehbook).
|
|
316
|
+
*
|
|
317
|
+
* @example
|
|
318
|
+
* For command and response, you can register your commands through the constructor, or use the `registerCommand` and `registerCommands` API to add commands later.
|
|
319
|
+
*
|
|
320
|
+
* ```typescript
|
|
321
|
+
* // register through constructor
|
|
322
|
+
* const conversationBot = new ConversationBot({
|
|
323
|
+
* command: {
|
|
324
|
+
* enabled: true,
|
|
325
|
+
* options: {
|
|
326
|
+
* commands: [ new HelloWorldCommandHandler() ],
|
|
327
|
+
* },
|
|
328
|
+
* },
|
|
329
|
+
* });
|
|
330
|
+
*
|
|
331
|
+
* // register through `register*` API
|
|
332
|
+
* conversationBot.command.registerCommand(new HelpCommandHandler());
|
|
333
|
+
* ```
|
|
334
|
+
*
|
|
335
|
+
* For notification, you can enable notification at initialization, then send notificaations at any time.
|
|
336
|
+
*
|
|
337
|
+
* ```typescript
|
|
338
|
+
* // enable through constructor
|
|
339
|
+
* const conversationBot = new ConversationBot({
|
|
340
|
+
* notification: {
|
|
341
|
+
* enabled: true,
|
|
342
|
+
* },
|
|
343
|
+
* });
|
|
344
|
+
*
|
|
345
|
+
* // get all bot installations and send message
|
|
346
|
+
* for (const target of await conversationBot.notification.installations()) {
|
|
347
|
+
* await target.sendMessage("Hello Notification");
|
|
348
|
+
* }
|
|
349
|
+
*
|
|
350
|
+
* // alternative - send message to all members
|
|
351
|
+
* for (const target of await conversationBot.notification.installations()) {
|
|
352
|
+
* for (const member of await target.members()) {
|
|
353
|
+
* await member.sendMessage("Hello Notification");
|
|
354
|
+
* }
|
|
355
|
+
* }
|
|
356
|
+
* ```
|
|
357
|
+
*
|
|
358
|
+
* @remarks
|
|
359
|
+
* Set `adapter` in {@link ConversationOptions} to use your own bot adapter.
|
|
360
|
+
*
|
|
361
|
+
* For command and response, ensure each command should ONLY be registered with the command once, otherwise it'll cause unexpected behavior if you register the same command more than once.
|
|
362
|
+
*
|
|
363
|
+
* For notification, set `notification.options.storage` in {@link ConversationOptions} to use your own storage implementation.
|
|
364
|
+
*
|
|
365
|
+
* @beta
|
|
366
|
+
*/
|
|
367
|
+
export declare class ConversationBot {
|
|
368
|
+
/**
|
|
369
|
+
* The bot adapter.
|
|
370
|
+
*
|
|
371
|
+
* @beta
|
|
372
|
+
*/
|
|
373
|
+
readonly adapter: BotFrameworkAdapter;
|
|
374
|
+
/**
|
|
375
|
+
* The entrypoint of command and response.
|
|
376
|
+
*
|
|
377
|
+
* @beta
|
|
378
|
+
*/
|
|
379
|
+
readonly command?: CommandBot;
|
|
380
|
+
/**
|
|
381
|
+
* The entrypoint of notification.
|
|
382
|
+
*
|
|
383
|
+
* @beta
|
|
384
|
+
*/
|
|
385
|
+
readonly notification?: NotificationBot;
|
|
386
|
+
/**
|
|
387
|
+
* Creates new instance of the `ConversationBot`.
|
|
388
|
+
*
|
|
389
|
+
* @param options - initialize options
|
|
390
|
+
*
|
|
391
|
+
* @beta
|
|
392
|
+
*/
|
|
393
|
+
constructor(options: ConversationOptions);
|
|
394
|
+
}
|
|
395
|
+
|
|
396
|
+
/**
|
|
397
|
+
* Options to initialize {@link ConversationBot}
|
|
398
|
+
*
|
|
399
|
+
* @beta
|
|
400
|
+
*/
|
|
401
|
+
export declare interface ConversationOptions {
|
|
402
|
+
/**
|
|
403
|
+
* The bot adapter. If not provided, a default adapter will be created with BOT_ID and BOT_PASSWORD from environment variables.
|
|
404
|
+
*
|
|
405
|
+
* @beta
|
|
406
|
+
*/
|
|
407
|
+
adapter?: BotFrameworkAdapter;
|
|
408
|
+
/**
|
|
409
|
+
* The command part.
|
|
410
|
+
*
|
|
411
|
+
* @beta
|
|
412
|
+
*/
|
|
413
|
+
command: {
|
|
414
|
+
/**
|
|
415
|
+
* Whether to enable command or not.
|
|
416
|
+
*
|
|
417
|
+
* @beta
|
|
418
|
+
*/
|
|
419
|
+
enabled: boolean;
|
|
420
|
+
/**
|
|
421
|
+
* The command options if command is enabled.
|
|
422
|
+
*
|
|
423
|
+
* @beta
|
|
424
|
+
*/
|
|
425
|
+
options: CommandOptions;
|
|
426
|
+
};
|
|
427
|
+
/**
|
|
428
|
+
* The notification part.
|
|
429
|
+
*
|
|
430
|
+
* @beta
|
|
431
|
+
*/
|
|
432
|
+
notification: {
|
|
433
|
+
/**
|
|
434
|
+
* Whether to enable notification or not.
|
|
435
|
+
*
|
|
436
|
+
* @beta
|
|
437
|
+
*/
|
|
438
|
+
enabled: boolean;
|
|
439
|
+
/**
|
|
440
|
+
* The notification options if notification is enabled.
|
|
441
|
+
*
|
|
442
|
+
* @beta
|
|
443
|
+
*/
|
|
444
|
+
options: NotificationOptions_2;
|
|
445
|
+
};
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Initializes new Axios instance with specific auth provider
|
|
450
|
+
*
|
|
451
|
+
* @param apiEndpoint - Base url of the API
|
|
452
|
+
* @param authProvider - Auth provider that injects authentication info to each request
|
|
453
|
+
* @returns axios instance configured with specfic auth provider
|
|
454
|
+
*
|
|
455
|
+
* @example
|
|
456
|
+
* ```typescript
|
|
457
|
+
* const client = createApiClient("https://my-api-endpoint-base-url", new BasicAuthProvider("xxx","xxx"));
|
|
458
|
+
* ```
|
|
459
|
+
*
|
|
460
|
+
* @beta
|
|
461
|
+
*/
|
|
462
|
+
export declare function createApiClient(apiEndpoint: string, authProvider: AuthProvider): AxiosInstance;
|
|
463
|
+
|
|
126
464
|
/**
|
|
127
465
|
* Get Microsoft graph client.
|
|
128
466
|
*
|
|
@@ -353,6 +691,198 @@ export declare enum LogLevel {
|
|
|
353
691
|
Error = 3
|
|
354
692
|
}
|
|
355
693
|
|
|
694
|
+
/**
|
|
695
|
+
* A {@link NotificationTarget} that represents a team member.
|
|
696
|
+
*
|
|
697
|
+
* @remarks
|
|
698
|
+
* It's recommended to get members from {@link TeamsBotInstallation.members()}.
|
|
699
|
+
*
|
|
700
|
+
* @beta
|
|
701
|
+
*/
|
|
702
|
+
export declare class Member implements NotificationTarget {
|
|
703
|
+
/**
|
|
704
|
+
* The parent {@link TeamsBotInstallation} where this member is created from.
|
|
705
|
+
*
|
|
706
|
+
* @beta
|
|
707
|
+
*/
|
|
708
|
+
readonly parent: TeamsBotInstallation;
|
|
709
|
+
/**
|
|
710
|
+
* Detailed member account information.
|
|
711
|
+
*
|
|
712
|
+
* @beta
|
|
713
|
+
*/
|
|
714
|
+
readonly account: TeamsChannelAccount;
|
|
715
|
+
/**
|
|
716
|
+
* Notification target type. For member it's always "Person".
|
|
717
|
+
*
|
|
718
|
+
* @beta
|
|
719
|
+
*/
|
|
720
|
+
readonly type: NotificationTargetType;
|
|
721
|
+
/**
|
|
722
|
+
* Constuctor.
|
|
723
|
+
*
|
|
724
|
+
* @remarks
|
|
725
|
+
* It's recommended to get members from {@link TeamsBotInstallation.members()}, instead of using this constructor.
|
|
726
|
+
*
|
|
727
|
+
* @param parent - The parent {@link TeamsBotInstallation} where this member is created from.
|
|
728
|
+
* @param account - Detailed member account information.
|
|
729
|
+
*
|
|
730
|
+
* @beta
|
|
731
|
+
*/
|
|
732
|
+
constructor(parent: TeamsBotInstallation, account: TeamsChannelAccount);
|
|
733
|
+
/**
|
|
734
|
+
* Send a plain text message.
|
|
735
|
+
*
|
|
736
|
+
* @param text - the plain text message.
|
|
737
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
738
|
+
*
|
|
739
|
+
* @beta
|
|
740
|
+
*/
|
|
741
|
+
sendMessage(text: string): Promise<void>;
|
|
742
|
+
/**
|
|
743
|
+
* Send an adaptive card message.
|
|
744
|
+
*
|
|
745
|
+
* @param card - the adaptive card raw JSON.
|
|
746
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
747
|
+
*
|
|
748
|
+
* @beta
|
|
749
|
+
*/
|
|
750
|
+
sendAdaptiveCard(card: unknown): Promise<void>;
|
|
751
|
+
/**
|
|
752
|
+
* @internal
|
|
753
|
+
*/
|
|
754
|
+
private newConversation;
|
|
755
|
+
}
|
|
756
|
+
|
|
757
|
+
/**
|
|
758
|
+
* Provides utility method to build bot message with cards that supported in Teams.
|
|
759
|
+
*/
|
|
760
|
+
export declare class MessageBuilder {
|
|
761
|
+
/**
|
|
762
|
+
* Build a bot message activity attached with adaptive card.
|
|
763
|
+
*
|
|
764
|
+
* @param getCardData Function to prepare your card data.
|
|
765
|
+
* @param cardTemplate The adaptive card template.
|
|
766
|
+
* @returns A bot message activity attached with an adaptive card.
|
|
767
|
+
*
|
|
768
|
+
* @example
|
|
769
|
+
* ```javascript
|
|
770
|
+
* const cardTemplate = {
|
|
771
|
+
* type: "AdaptiveCard",
|
|
772
|
+
* body: [
|
|
773
|
+
* {
|
|
774
|
+
* "type": "TextBlock",
|
|
775
|
+
* "text": "${title}",
|
|
776
|
+
* "size": "Large"
|
|
777
|
+
* },
|
|
778
|
+
* {
|
|
779
|
+
* "type": "TextBlock",
|
|
780
|
+
* "text": "${description}"
|
|
781
|
+
* }],
|
|
782
|
+
* $schema: "http://adaptivecards.io/schemas/adaptive-card.json",
|
|
783
|
+
* version: "1.4"
|
|
784
|
+
* };
|
|
785
|
+
*
|
|
786
|
+
* type CardData = {
|
|
787
|
+
* title: string,
|
|
788
|
+
* description: string
|
|
789
|
+
* };
|
|
790
|
+
* const card = MessageBuilder.attachAdaptiveCard<CardData>(() => {
|
|
791
|
+
* return {
|
|
792
|
+
* title: "sample card title",
|
|
793
|
+
* description: "sample card description"
|
|
794
|
+
* }}, cardTemplate);
|
|
795
|
+
* ```
|
|
796
|
+
*
|
|
797
|
+
* @beta
|
|
798
|
+
*/
|
|
799
|
+
static attachAdaptiveCard<TData>(getCardData: () => TData, cardTemplate: any): Partial<Activity_2>;
|
|
800
|
+
/**
|
|
801
|
+
* Build a bot message activity attached with an adaptive card.
|
|
802
|
+
*
|
|
803
|
+
* @param card The adaptive card content.
|
|
804
|
+
* @returns A bot message activity attached with an adaptive card.
|
|
805
|
+
*
|
|
806
|
+
* @beta
|
|
807
|
+
*/
|
|
808
|
+
static attachAdaptiveCardWithoutData(card: any): Partial<Activity_2>;
|
|
809
|
+
/**
|
|
810
|
+
* Build a bot message activity attached with an hero card.
|
|
811
|
+
*
|
|
812
|
+
* @param title The card title.
|
|
813
|
+
* @param images Optional. The array of images to include on the card.
|
|
814
|
+
* @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
|
|
815
|
+
* is converted to an `imBack` button with a title and value set to the value of the string.
|
|
816
|
+
* @param other Optional. Any additional properties to include on the card.
|
|
817
|
+
*
|
|
818
|
+
* @returns A bot message activity attached with a hero card.
|
|
819
|
+
*
|
|
820
|
+
* @example
|
|
821
|
+
* ```javascript
|
|
822
|
+
* const message = MessageBuilder.attachHeroCard(
|
|
823
|
+
* 'sample title',
|
|
824
|
+
* ['https://example.com/sample.jpg'],
|
|
825
|
+
* ['action']
|
|
826
|
+
* );
|
|
827
|
+
* ```
|
|
828
|
+
*
|
|
829
|
+
* @beta
|
|
830
|
+
*/
|
|
831
|
+
static attachHeroCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<HeroCard>): Partial<Activity_2>;
|
|
832
|
+
/**
|
|
833
|
+
* Returns an attachment for a sign-in card.
|
|
834
|
+
*
|
|
835
|
+
* @param title The title for the card's sign-in button.
|
|
836
|
+
* @param url The URL of the sign-in page to use.
|
|
837
|
+
* @param text Optional. Additional text to include on the card.
|
|
838
|
+
*
|
|
839
|
+
* @returns A bot message activity attached with a sign-in card.
|
|
840
|
+
*
|
|
841
|
+
* @remarks
|
|
842
|
+
* For channels that don't natively support sign-in cards, an alternative message is rendered.
|
|
843
|
+
*
|
|
844
|
+
* @beta
|
|
845
|
+
*/
|
|
846
|
+
static attachSigninCard(title: string, url: string, text?: string): Partial<Activity_2>;
|
|
847
|
+
/**
|
|
848
|
+
* Build a bot message activity attached with an Office 365 connector card.
|
|
849
|
+
*
|
|
850
|
+
* @param card A description of the Office 365 connector card.
|
|
851
|
+
* @returns A bot message activity attached with an Office 365 connector card.
|
|
852
|
+
*
|
|
853
|
+
* @beta
|
|
854
|
+
*/
|
|
855
|
+
static attachO365ConnectorCard(card: O365ConnectorCard): Partial<Activity_2>;
|
|
856
|
+
/**
|
|
857
|
+
* Build a message activity attached with a receipt card.
|
|
858
|
+
* @param card A description of the receipt card.
|
|
859
|
+
* @returns A message activity attached with a receipt card.
|
|
860
|
+
*
|
|
861
|
+
* @beta
|
|
862
|
+
*/
|
|
863
|
+
static AttachReceiptCard(card: ReceiptCard): Partial<Activity_2>;
|
|
864
|
+
/**
|
|
865
|
+
*
|
|
866
|
+
* @param title The card title.
|
|
867
|
+
* @param images Optional. The array of images to include on the card.
|
|
868
|
+
* @param buttons Optional. The array of buttons to include on the card. Each `string` in the array
|
|
869
|
+
* is converted to an `imBack` button with a title and value set to the value of the string.
|
|
870
|
+
* @param other Optional. Any additional properties to include on the card.
|
|
871
|
+
* @returns A message activity attached with a thumbnail card
|
|
872
|
+
*
|
|
873
|
+
* @beta
|
|
874
|
+
*/
|
|
875
|
+
static attachThumbnailCard(title: string, images?: (CardImage | string)[], buttons?: (CardAction | string)[], other?: Partial<ThumbnailCard>): Partial<Activity_2>;
|
|
876
|
+
/**
|
|
877
|
+
* Add an attachement to a bot activity.
|
|
878
|
+
* @param attachement The attachment object to attach.
|
|
879
|
+
* @returns A message activity with an attachment.
|
|
880
|
+
*
|
|
881
|
+
* @beta
|
|
882
|
+
*/
|
|
883
|
+
static attachContent(attachement: Attachment): Partial<Activity_2>;
|
|
884
|
+
}
|
|
885
|
+
|
|
356
886
|
/**
|
|
357
887
|
* Microsoft Graph auth provider for Teams Framework
|
|
358
888
|
*
|
|
@@ -389,6 +919,153 @@ export declare class MsGraphAuthProvider implements AuthenticationProvider {
|
|
|
389
919
|
getAccessToken(): Promise<string>;
|
|
390
920
|
}
|
|
391
921
|
|
|
922
|
+
/**
|
|
923
|
+
* Provide utilities to send notification to varies targets (e.g., member, channel, incoming wehbook).
|
|
924
|
+
*
|
|
925
|
+
* @beta
|
|
926
|
+
*/
|
|
927
|
+
export declare class NotificationBot {
|
|
928
|
+
private readonly conversationReferenceStore;
|
|
929
|
+
private readonly adapter;
|
|
930
|
+
/**
|
|
931
|
+
* constructor of the notification bot.
|
|
932
|
+
*
|
|
933
|
+
* @remarks
|
|
934
|
+
* To ensure accuracy, it's recommended to initialize before handling any message.
|
|
935
|
+
*
|
|
936
|
+
* @param adapter - the bound `BotFrameworkAdapter`
|
|
937
|
+
* @param options - initialize options
|
|
938
|
+
*
|
|
939
|
+
* @beta
|
|
940
|
+
*/
|
|
941
|
+
constructor(adapter: BotFrameworkAdapter, options?: NotificationOptions_2);
|
|
942
|
+
/**
|
|
943
|
+
* Get all targets where the bot is installed.
|
|
944
|
+
*
|
|
945
|
+
* @remarks
|
|
946
|
+
* The result is retrieving from the persisted storage.
|
|
947
|
+
*
|
|
948
|
+
* @returns - an array of {@link TeamsBotInstallation}.
|
|
949
|
+
*
|
|
950
|
+
* @beta
|
|
951
|
+
*/
|
|
952
|
+
installations(): Promise<TeamsBotInstallation[]>;
|
|
953
|
+
}
|
|
954
|
+
|
|
955
|
+
/**
|
|
956
|
+
* Options to initialize {@link NotificationBot}.
|
|
957
|
+
*
|
|
958
|
+
* @beta
|
|
959
|
+
*/
|
|
960
|
+
declare interface NotificationOptions_2 {
|
|
961
|
+
/**
|
|
962
|
+
* An optional storage to persist bot notification connections.
|
|
963
|
+
*
|
|
964
|
+
* @remarks
|
|
965
|
+
* If `storage` is not provided, a default local file storage will be used,
|
|
966
|
+
* which stores notification connections into:
|
|
967
|
+
* - ".notification.localstore.json" if running locally
|
|
968
|
+
* - "${process.env.TEMP}/.notification.localstore.json" if `process.env.RUNNING_ON_AZURE` is set to "1"
|
|
969
|
+
*
|
|
970
|
+
* It's recommended to use your own shared storage for production environment.
|
|
971
|
+
*
|
|
972
|
+
* @beta
|
|
973
|
+
*/
|
|
974
|
+
storage?: NotificationTargetStorage;
|
|
975
|
+
}
|
|
976
|
+
export { NotificationOptions_2 as NotificationOptions }
|
|
977
|
+
|
|
978
|
+
/**
|
|
979
|
+
* Represent a notification target.
|
|
980
|
+
*
|
|
981
|
+
* @beta
|
|
982
|
+
*/
|
|
983
|
+
export declare interface NotificationTarget {
|
|
984
|
+
/**
|
|
985
|
+
* The type of target, could be "Channel" or "Group" or "Person".
|
|
986
|
+
*
|
|
987
|
+
* @beta
|
|
988
|
+
*/
|
|
989
|
+
readonly type?: NotificationTargetType;
|
|
990
|
+
/**
|
|
991
|
+
* Send a plain text message.
|
|
992
|
+
*
|
|
993
|
+
* @param text - the plain text message.
|
|
994
|
+
*
|
|
995
|
+
* @beta
|
|
996
|
+
*/
|
|
997
|
+
sendMessage(text: string): Promise<void>;
|
|
998
|
+
/**
|
|
999
|
+
* Send an adaptive card message.
|
|
1000
|
+
*
|
|
1001
|
+
* @param card - the adaptive card raw JSON.
|
|
1002
|
+
*
|
|
1003
|
+
* @beta
|
|
1004
|
+
*/
|
|
1005
|
+
sendAdaptiveCard(card: unknown): Promise<void>;
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
/**
|
|
1009
|
+
* Interface for a storage provider that stores and retrieves notification target references.
|
|
1010
|
+
*
|
|
1011
|
+
* @beta
|
|
1012
|
+
*/
|
|
1013
|
+
export declare interface NotificationTargetStorage {
|
|
1014
|
+
/**
|
|
1015
|
+
* Read one notification target by its key.
|
|
1016
|
+
*
|
|
1017
|
+
* @param key - the key of a notification target.
|
|
1018
|
+
*
|
|
1019
|
+
* @returns - the notification target. Or undefined if not found.
|
|
1020
|
+
*
|
|
1021
|
+
* @beta
|
|
1022
|
+
*/
|
|
1023
|
+
read(key: string): Promise<{
|
|
1024
|
+
[key: string]: unknown;
|
|
1025
|
+
} | undefined>;
|
|
1026
|
+
/**
|
|
1027
|
+
* List all stored notification targets.
|
|
1028
|
+
*
|
|
1029
|
+
* @returns - an array of notification target. Or an empty array if nothing is stored.
|
|
1030
|
+
*
|
|
1031
|
+
* @beta
|
|
1032
|
+
*/
|
|
1033
|
+
list(): Promise<{
|
|
1034
|
+
[key: string]: unknown;
|
|
1035
|
+
}[]>;
|
|
1036
|
+
/**
|
|
1037
|
+
* Write one notification target by its key.
|
|
1038
|
+
*
|
|
1039
|
+
* @param key - the key of a notification target.
|
|
1040
|
+
* @param object - the notification target.
|
|
1041
|
+
*
|
|
1042
|
+
* @beta
|
|
1043
|
+
*/
|
|
1044
|
+
write(key: string, object: {
|
|
1045
|
+
[key: string]: unknown;
|
|
1046
|
+
}): Promise<void>;
|
|
1047
|
+
/**
|
|
1048
|
+
* Delete one notificaton target by its key.
|
|
1049
|
+
*
|
|
1050
|
+
* @param key - the key of a notification target.
|
|
1051
|
+
*
|
|
1052
|
+
* @beta
|
|
1053
|
+
*/
|
|
1054
|
+
delete(key: string): Promise<void>;
|
|
1055
|
+
}
|
|
1056
|
+
|
|
1057
|
+
/**
|
|
1058
|
+
* The target type where the notification will be sent to.
|
|
1059
|
+
*
|
|
1060
|
+
* @remarks
|
|
1061
|
+
* - "Channel" means to a team channel. (By default, notification to a team will be sent to its "General" channel.)
|
|
1062
|
+
* - "Group" means to a group chat.
|
|
1063
|
+
* - "Person" means to a personal chat.
|
|
1064
|
+
*
|
|
1065
|
+
* @beta
|
|
1066
|
+
*/
|
|
1067
|
+
export declare type NotificationTargetType = "Channel" | "Group" | "Person";
|
|
1068
|
+
|
|
392
1069
|
/**
|
|
393
1070
|
* Represent on-behalf-of flow to get user identity, and it is designed to be used in server side.
|
|
394
1071
|
*
|
|
@@ -476,6 +1153,28 @@ export declare class OnBehalfOfUserCredential implements TokenCredential {
|
|
|
476
1153
|
private generateAuthServerError;
|
|
477
1154
|
}
|
|
478
1155
|
|
|
1156
|
+
/**
|
|
1157
|
+
* Send an adaptive card message to a notification target.
|
|
1158
|
+
*
|
|
1159
|
+
* @param target - the notification target.
|
|
1160
|
+
* @param card - the adaptive card raw JSON.
|
|
1161
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1162
|
+
*
|
|
1163
|
+
* @beta
|
|
1164
|
+
*/
|
|
1165
|
+
export declare function sendAdaptiveCard(target: NotificationTarget, card: unknown): Promise<void>;
|
|
1166
|
+
|
|
1167
|
+
/**
|
|
1168
|
+
* Send a plain text message to a notification target.
|
|
1169
|
+
*
|
|
1170
|
+
* @param target - the notification target.
|
|
1171
|
+
* @param text - the plain text message.
|
|
1172
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1173
|
+
*
|
|
1174
|
+
* @beta
|
|
1175
|
+
*/
|
|
1176
|
+
export declare function sendMessage(target: NotificationTarget, text: string): Promise<void>;
|
|
1177
|
+
|
|
479
1178
|
/**
|
|
480
1179
|
* Set custom log function. Use the function if it's set. Priority is lower than setLogger.
|
|
481
1180
|
*
|
|
@@ -522,6 +1221,89 @@ export declare function setLogger(logger?: Logger): void;
|
|
|
522
1221
|
*/
|
|
523
1222
|
export declare function setLogLevel(level: LogLevel): void;
|
|
524
1223
|
|
|
1224
|
+
/**
|
|
1225
|
+
* A {@link NotificationTarget} that represents a bot installation. Teams Bot could be installed into
|
|
1226
|
+
* - Personal chat
|
|
1227
|
+
* - Group chat
|
|
1228
|
+
* - Team (by default the `General` channel)
|
|
1229
|
+
*
|
|
1230
|
+
* @remarks
|
|
1231
|
+
* It's recommended to get bot installations from {@link ConversationBot.installations()}.
|
|
1232
|
+
*
|
|
1233
|
+
* @beta
|
|
1234
|
+
*/
|
|
1235
|
+
export declare class TeamsBotInstallation implements NotificationTarget {
|
|
1236
|
+
/**
|
|
1237
|
+
* The bound `BotFrameworkAdapter`.
|
|
1238
|
+
*
|
|
1239
|
+
* @beta
|
|
1240
|
+
*/
|
|
1241
|
+
readonly adapter: BotFrameworkAdapter;
|
|
1242
|
+
/**
|
|
1243
|
+
* The bound `ConversationReference`.
|
|
1244
|
+
*
|
|
1245
|
+
* @beta
|
|
1246
|
+
*/
|
|
1247
|
+
readonly conversationReference: Partial<ConversationReference>;
|
|
1248
|
+
/**
|
|
1249
|
+
* Notification target type.
|
|
1250
|
+
*
|
|
1251
|
+
* @remarks
|
|
1252
|
+
* - "Channel" means bot is installed into a team and notification will be sent to its "General" channel.
|
|
1253
|
+
* - "Group" means bot is installed into a group chat.
|
|
1254
|
+
* - "Person" means bot is installed into a personal scope and notification will be sent to personal chat.
|
|
1255
|
+
*
|
|
1256
|
+
* @beta
|
|
1257
|
+
*/
|
|
1258
|
+
readonly type?: NotificationTargetType;
|
|
1259
|
+
/**
|
|
1260
|
+
* Constructor
|
|
1261
|
+
*
|
|
1262
|
+
* @remarks
|
|
1263
|
+
* It's recommended to get bot installations from {@link ConversationBot.installations()}, instead of using this constructor.
|
|
1264
|
+
*
|
|
1265
|
+
* @param adapter - the bound `BotFrameworkAdapter`.
|
|
1266
|
+
* @param conversationReference - the bound `ConversationReference`.
|
|
1267
|
+
*
|
|
1268
|
+
* @beta
|
|
1269
|
+
*/
|
|
1270
|
+
constructor(adapter: BotFrameworkAdapter, conversationReference: Partial<ConversationReference>);
|
|
1271
|
+
/**
|
|
1272
|
+
* Send a plain text message.
|
|
1273
|
+
*
|
|
1274
|
+
* @param text - the plain text message.
|
|
1275
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1276
|
+
*
|
|
1277
|
+
* @beta
|
|
1278
|
+
*/
|
|
1279
|
+
sendMessage(text: string): Promise<void>;
|
|
1280
|
+
/**
|
|
1281
|
+
* Send an adaptive card message.
|
|
1282
|
+
*
|
|
1283
|
+
* @param card - the adaptive card raw JSON.
|
|
1284
|
+
* @returns A `Promise` representing the asynchronous operation.
|
|
1285
|
+
*
|
|
1286
|
+
* @beta
|
|
1287
|
+
*/
|
|
1288
|
+
sendAdaptiveCard(card: unknown): Promise<void>;
|
|
1289
|
+
/**
|
|
1290
|
+
* Get channels from this bot installation.
|
|
1291
|
+
*
|
|
1292
|
+
* @returns an array of channels if bot is installed into a team, otherwise returns an empty array.
|
|
1293
|
+
*
|
|
1294
|
+
* @beta
|
|
1295
|
+
*/
|
|
1296
|
+
channels(): Promise<Channel[]>;
|
|
1297
|
+
/**
|
|
1298
|
+
* Get members from this bot installation.
|
|
1299
|
+
*
|
|
1300
|
+
* @returns an array of members from where the bot is installed.
|
|
1301
|
+
*
|
|
1302
|
+
* @beta
|
|
1303
|
+
*/
|
|
1304
|
+
members(): Promise<Member[]>;
|
|
1305
|
+
}
|
|
1306
|
+
|
|
525
1307
|
/**
|
|
526
1308
|
* Creates a new prompt that leverage Teams Single Sign On (SSO) support for bot to automatically sign in user and
|
|
527
1309
|
* help receive oauth token, asks the user to consent if needed.
|
|
@@ -809,6 +1591,26 @@ export declare class TeamsFx implements TeamsFxConfiguration {
|
|
|
809
1591
|
private loadFromEnv;
|
|
810
1592
|
}
|
|
811
1593
|
|
|
1594
|
+
/**
|
|
1595
|
+
* Interface for a command handler that can process command to a TeamsFx bot and return a response.
|
|
1596
|
+
*
|
|
1597
|
+
* @beta
|
|
1598
|
+
*/
|
|
1599
|
+
export declare interface TeamsFxBotCommandHandler {
|
|
1600
|
+
/**
|
|
1601
|
+
* The string or regular expression patterns that can trigger this handler.
|
|
1602
|
+
*/
|
|
1603
|
+
triggerPatterns: TriggerPatterns;
|
|
1604
|
+
/**
|
|
1605
|
+
* Handles a bot command received activity.
|
|
1606
|
+
*
|
|
1607
|
+
* @param context The bot context.
|
|
1608
|
+
* @param message The command message the user types from Teams.
|
|
1609
|
+
* @returns A `Promise` representing an activity or text to send as the command response.
|
|
1610
|
+
*/
|
|
1611
|
+
handleCommandReceived(context: TurnContext, message: CommandMessage): Promise<string | Partial<Activity>>;
|
|
1612
|
+
}
|
|
1613
|
+
|
|
812
1614
|
/**
|
|
813
1615
|
* TeamsFx interface that provides credential and configuration.
|
|
814
1616
|
* @beta
|
|
@@ -929,6 +1731,11 @@ export declare class TeamsUserCredential implements TokenCredential {
|
|
|
929
1731
|
getUserInfo(): Promise<UserInfo>;
|
|
930
1732
|
}
|
|
931
1733
|
|
|
1734
|
+
/**
|
|
1735
|
+
* The trigger pattern used to trigger a {@link TeamsFxBotCommandHandler} instance.
|
|
1736
|
+
*/
|
|
1737
|
+
export declare type TriggerPatterns = string | RegExp | (string | RegExp)[];
|
|
1738
|
+
|
|
932
1739
|
/**
|
|
933
1740
|
* UserInfo with user displayName, objectId and preferredUserName.
|
|
934
1741
|
*
|