@@ -24,8 +24,17 @@ import {
24
24
Channels ,
25
25
MeetingNotification ,
26
26
MeetingNotificationResponse ,
27
+ TeamsMember ,
28
+ BatchOperationResponse ,
29
+ BatchOperationStateResponse ,
30
+ BatchFailedEntriesResponse ,
27
31
} from 'botbuilder-core' ;
28
- import { ConnectorClient , TeamsConnectorClient , TeamsConnectorModels } from 'botframework-connector' ;
32
+ import {
33
+ CancelOperationResponse ,
34
+ ConnectorClient ,
35
+ TeamsConnectorClient ,
36
+ TeamsConnectorModels ,
37
+ } from 'botframework-connector' ;
29
38
30
39
import { BotFrameworkAdapter } from './botFrameworkAdapter' ;
31
40
import { CloudAdapter } from './cloudAdapter' ;
@@ -364,6 +373,166 @@ export class TeamsInfo {
364
373
return await this . getTeamsConnectorClient ( context ) . teams . sendMeetingNotification ( meetingId , notification ) ;
365
374
}
366
375
376
+ /**
377
+ * Sends a message to the provided users in the list of Teams members.
378
+ *
379
+ * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn.
380
+ * @param activity The activity to send.
381
+ * @param tenantId The tenant ID.
382
+ * @param members The list of users recipients for the message.
383
+ * @returns Promise with operationId.
384
+ */
385
+ static async sendMessageToListOfUsers (
386
+ context : TurnContext ,
387
+ activity : Activity ,
388
+ tenantId : string ,
389
+ members : TeamsMember [ ]
390
+ ) : Promise < BatchOperationResponse > {
391
+ if ( ! activity ) {
392
+ throw new Error ( 'activity is required.' ) ;
393
+ }
394
+ if ( ! tenantId ) {
395
+ throw new Error ( 'tenantId is required.' ) ;
396
+ }
397
+ if ( ! members || members . length == 0 ) {
398
+ throw new Error ( 'members list is required.' ) ;
399
+ }
400
+
401
+ return await this . getTeamsConnectorClient ( context ) . teams . sendMessageToListOfUsers ( activity , tenantId , members ) ;
402
+ }
403
+
404
+ /**
405
+ * Sends a message to all the users in a tenant.
406
+ *
407
+ * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn.
408
+ * @param activity The activity to send.
409
+ * @param tenantId The tenant ID.
410
+ * @returns Promise with operationId.
411
+ */
412
+ static async sendMessageToAllUsersInTenant (
413
+ context : TurnContext ,
414
+ activity : Activity ,
415
+ tenantId : string
416
+ ) : Promise < BatchOperationResponse > {
417
+ if ( ! activity ) {
418
+ throw new Error ( 'activity is required.' ) ;
419
+ }
420
+ if ( ! tenantId ) {
421
+ throw new Error ( 'tenantId is required.' ) ;
422
+ }
423
+
424
+ return await this . getTeamsConnectorClient ( context ) . teams . sendMessageToAllUsersInTenant ( activity , tenantId ) ;
425
+ }
426
+
427
+ /**
428
+ * Sends a message to all the users in a team.
429
+ *
430
+ * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn.
431
+ * @param activity The activity to send.
432
+ * @param tenantId The tenant ID.
433
+ * @param teamId The team ID.
434
+ * @returns Promise with operationId.
435
+ */
436
+ static async sendMessageToAllUsersInTeam (
437
+ context : TurnContext ,
438
+ activity : Activity ,
439
+ tenantId : string ,
440
+ teamId : string
441
+ ) : Promise < BatchOperationResponse > {
442
+ if ( ! activity ) {
443
+ throw new Error ( 'activity is required.' ) ;
444
+ }
445
+ if ( ! tenantId ) {
446
+ throw new Error ( 'tenantId is required.' ) ;
447
+ }
448
+ if ( ! teamId ) {
449
+ throw new Error ( 'teamId is required.' ) ;
450
+ }
451
+
452
+ return await this . getTeamsConnectorClient ( context ) . teams . sendMessageToAllUsersInTeam (
453
+ activity ,
454
+ tenantId ,
455
+ teamId
456
+ ) ;
457
+ }
458
+
459
+ /**
460
+ * Sends a message to the provided list of Teams channels.
461
+ *
462
+ * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn.
463
+ * @param activity The activity to send.
464
+ * @param tenantId The tenant ID.
465
+ * @param members The list of channels recipients for the message.
466
+ * @returns Promise with operationId.
467
+ */
468
+ static async sendMessageToListOfChannels (
469
+ context : TurnContext ,
470
+ activity : Activity ,
471
+ tenantId : string ,
472
+ members : TeamsMember [ ]
473
+ ) : Promise < BatchOperationResponse > {
474
+ if ( ! activity ) {
475
+ throw new Error ( 'activity is required.' ) ;
476
+ }
477
+ if ( ! tenantId ) {
478
+ throw new Error ( 'tenantId is required.' ) ;
479
+ }
480
+ if ( ! members || members . length == 0 ) {
481
+ throw new Error ( 'members list is required.' ) ;
482
+ }
483
+
484
+ return await this . getTeamsConnectorClient ( context ) . teams . sendMessageToListOfChannels (
485
+ activity ,
486
+ tenantId ,
487
+ members
488
+ ) ;
489
+ }
490
+
491
+ /**
492
+ * Gets the operation state.
493
+ *
494
+ * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn.
495
+ * @param operationId The operationId to get the state of.
496
+ * @returns Promise with The state and responses of the operation.
497
+ */
498
+ static async getOperationState ( context : TurnContext , operationId : string ) : Promise < BatchOperationStateResponse > {
499
+ if ( ! operationId ) {
500
+ throw new Error ( 'operationId is required.' ) ;
501
+ }
502
+
503
+ return await this . getTeamsConnectorClient ( context ) . teams . getOperationState ( operationId ) ;
504
+ }
505
+
506
+ /**
507
+ * Gets the failed entries of an executed operation.
508
+ *
509
+ * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn.
510
+ * @param operationId The operationId to get the failed entries of.
511
+ * @returns Promise with the list of failed entries of the operation.
512
+ */
513
+ static async getFailedEntries ( context : TurnContext , operationId : string ) : Promise < BatchFailedEntriesResponse > {
514
+ if ( ! operationId ) {
515
+ throw new Error ( 'operationId is required.' ) ;
516
+ }
517
+
518
+ return await this . getTeamsConnectorClient ( context ) . teams . getOperationFailedEntries ( operationId ) ;
519
+ }
520
+
521
+ /**
522
+ * Cancels a pending operation.
523
+ *
524
+ * @param context The [TurnContext](xref:botbuilder-core.TurnContext) for this turn.
525
+ * @param operationId The id of the operation to cancel.
526
+ * @returns Promise representing the asynchronous operation.
527
+ */
528
+ static async cancelOperation ( context : TurnContext , operationId : string ) : Promise < CancelOperationResponse > {
529
+ if ( ! operationId ) {
530
+ throw new Error ( 'operationId is required.' ) ;
531
+ }
532
+
533
+ return await this . getTeamsConnectorClient ( context ) . teams . cancelOperation ( operationId ) ;
534
+ }
535
+
367
536
/**
368
537
* @private
369
538
*/
0 commit comments