@microsoft/teamsfx 2.1.1-alpha.f8e51b9d8.0 → 2.2.0-alpha.d2fbcaf19.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/README.md +70 -28
- package/dist/index.esm2017.js +548 -12
- package/dist/index.esm2017.js.map +1 -1
- package/dist/index.esm2017.mjs +871 -34
- package/dist/index.esm2017.mjs.map +1 -1
- package/dist/index.esm5.js +570 -12
- package/dist/index.esm5.js.map +1 -1
- package/dist/index.node.cjs.js +907 -35
- package/dist/index.node.cjs.js.map +1 -1
- package/package.json +4 -4
- package/types/teamsfx.d.ts +623 -10
package/types/teamsfx.d.ts
CHANGED
|
@@ -11,6 +11,7 @@ import { CardAction } from 'botbuilder';
|
|
|
11
11
|
import { CardImage } from 'botbuilder';
|
|
12
12
|
import { ChannelInfo } from 'botbuilder';
|
|
13
13
|
import { Client } from '@microsoft/microsoft-graph-client';
|
|
14
|
+
import { CloudAdapter } from 'botbuilder';
|
|
14
15
|
import { ComponentDialog } from 'botbuilder-dialogs';
|
|
15
16
|
import { ConnectionConfig } from 'tedious';
|
|
16
17
|
import { ConversationReference } from 'botbuilder';
|
|
@@ -24,6 +25,8 @@ import { InvokeResponse } from 'botbuilder';
|
|
|
24
25
|
import { MessagingExtensionResponse } from 'botbuilder';
|
|
25
26
|
import { O365ConnectorCard } from 'botbuilder';
|
|
26
27
|
import { ReceiptCard } from 'botbuilder';
|
|
28
|
+
import { Request as Request_2 } from 'botbuilder';
|
|
29
|
+
import { Response as Response_2 } from 'botbuilder';
|
|
27
30
|
import { SecureContextOptions } from 'tls';
|
|
28
31
|
import { SigninStateVerificationQuery } from 'botbuilder';
|
|
29
32
|
import { StatePropertyAccessor } from 'botbuilder';
|
|
@@ -292,6 +295,25 @@ export declare class BearerTokenAuthProvider implements AuthProvider {
|
|
|
292
295
|
AddAuthenticationInfo(config: AxiosRequestConfig): Promise<AxiosRequestConfig>;
|
|
293
296
|
}
|
|
294
297
|
|
|
298
|
+
declare namespace BotBuilderCloudAdapter {
|
|
299
|
+
export {
|
|
300
|
+
ConversationOptions_2 as ConversationOptions,
|
|
301
|
+
NotificationOptions_3 as NotificationOptions,
|
|
302
|
+
ConversationBot_2 as ConversationBot,
|
|
303
|
+
BotSsoExecutionDialog,
|
|
304
|
+
Channel_2 as Channel,
|
|
305
|
+
Member_2 as Member,
|
|
306
|
+
NotificationBot_2 as NotificationBot,
|
|
307
|
+
sendAdaptiveCard_2 as sendAdaptiveCard,
|
|
308
|
+
sendMessage_2 as sendMessage,
|
|
309
|
+
TeamsBotInstallation_2 as TeamsBotInstallation,
|
|
310
|
+
SearchScope_2 as SearchScope,
|
|
311
|
+
CommandBot_2 as CommandBot,
|
|
312
|
+
CardActionBot_2 as CardActionBot
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
export { BotBuilderCloudAdapter }
|
|
316
|
+
|
|
295
317
|
/**
|
|
296
318
|
* Interface for SSO configuration for Bot SSO
|
|
297
319
|
*/
|
|
@@ -477,6 +499,9 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
477
499
|
/**
|
|
478
500
|
* A card action bot to respond to adaptive card universal actions.
|
|
479
501
|
*/
|
|
502
|
+
/**
|
|
503
|
+
* @deprecated Use `BotBuilderCloudAdapter.CardActionBot` instead.
|
|
504
|
+
*/
|
|
480
505
|
export declare class CardActionBot {
|
|
481
506
|
private readonly adapter;
|
|
482
507
|
private middleware;
|
|
@@ -499,6 +524,33 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
499
524
|
registerHandlers(actionHandlers: TeamsFxAdaptiveCardActionHandler[]): void;
|
|
500
525
|
}
|
|
501
526
|
|
|
527
|
+
/**
|
|
528
|
+
* A card action bot to respond to adaptive card universal actions.
|
|
529
|
+
*/
|
|
530
|
+
declare class CardActionBot_2 {
|
|
531
|
+
private readonly adapter;
|
|
532
|
+
private middleware;
|
|
533
|
+
/**
|
|
534
|
+
* Create a new instance of the `CardActionBot`.
|
|
535
|
+
*
|
|
536
|
+
* @param adapter - The bound `CloudAdapter`.
|
|
537
|
+
* @param options - The initialize options.
|
|
538
|
+
*/
|
|
539
|
+
constructor(adapter: CloudAdapter, options?: CardActionOptions);
|
|
540
|
+
/**
|
|
541
|
+
* Register a card action handler to the bot.
|
|
542
|
+
*
|
|
543
|
+
* @param actionHandler - A card action handler to be registered.
|
|
544
|
+
*/
|
|
545
|
+
registerHandler(actionHandler: TeamsFxAdaptiveCardActionHandler): void;
|
|
546
|
+
/**
|
|
547
|
+
* Register card action handlers to the bot.
|
|
548
|
+
*
|
|
549
|
+
* @param actionHandlers - A set of card action handlers to be registered.
|
|
550
|
+
*/
|
|
551
|
+
registerHandlers(actionHandlers: TeamsFxAdaptiveCardActionHandler[]): void;
|
|
552
|
+
}
|
|
553
|
+
|
|
502
554
|
/**
|
|
503
555
|
* Options to initialize {@link CardActionBot}.
|
|
504
556
|
*/
|
|
@@ -587,12 +639,70 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
587
639
|
private newConversation;
|
|
588
640
|
}
|
|
589
641
|
|
|
642
|
+
/**
|
|
643
|
+
* A {@link NotificationTarget} that represents a team channel.
|
|
644
|
+
*
|
|
645
|
+
* @remarks
|
|
646
|
+
* It's recommended to get channels from {@link TeamsBotInstallation.channels()}.
|
|
647
|
+
*/
|
|
648
|
+
declare class Channel_2 implements NotificationTarget {
|
|
649
|
+
/**
|
|
650
|
+
* The parent {@link TeamsBotInstallation} where this channel is created from.
|
|
651
|
+
*/
|
|
652
|
+
readonly parent: TeamsBotInstallation_2;
|
|
653
|
+
/**
|
|
654
|
+
* Detailed channel information.
|
|
655
|
+
*/
|
|
656
|
+
readonly info: ChannelInfo;
|
|
657
|
+
/**
|
|
658
|
+
* Notification target type. For channel it's always "Channel".
|
|
659
|
+
*/
|
|
660
|
+
readonly type: NotificationTargetType;
|
|
661
|
+
/**
|
|
662
|
+
* Constructor.
|
|
663
|
+
*
|
|
664
|
+
* @remarks
|
|
665
|
+
* It's recommended to get channels from {@link TeamsBotInstallation.channels()}, instead of using this constructor.
|
|
666
|
+
*
|
|
667
|
+
* @param parent - The parent {@link TeamsBotInstallation} where this channel is created from.
|
|
668
|
+
* @param info - Detailed channel information.
|
|
669
|
+
*/
|
|
670
|
+
constructor(parent: TeamsBotInstallation_2, info: ChannelInfo);
|
|
671
|
+
/**
|
|
672
|
+
* Send a plain text message.
|
|
673
|
+
*
|
|
674
|
+
* @param text - The plain text message.
|
|
675
|
+
* @param onError - An optional error handler that can catch exceptions during message sending.
|
|
676
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
677
|
+
*
|
|
678
|
+
* @returns The response of sending message.
|
|
679
|
+
*/
|
|
680
|
+
sendMessage(text: string, onError?: (context: TurnContext, error: Error) => Promise<void>): Promise<MessageResponse>;
|
|
681
|
+
/**
|
|
682
|
+
* Send an adaptive card message.
|
|
683
|
+
*
|
|
684
|
+
* @param card - The adaptive card raw JSON.
|
|
685
|
+
* @param onError - An optional error handler that can catch exceptions during adaptive card sending.
|
|
686
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
687
|
+
*
|
|
688
|
+
* @returns The response of sending adaptive card message.
|
|
689
|
+
*/
|
|
690
|
+
sendAdaptiveCard(card: unknown, onError?: (context: TurnContext, error: Error) => Promise<void>): Promise<MessageResponse>;
|
|
691
|
+
/**
|
|
692
|
+
* @internal
|
|
693
|
+
*/
|
|
694
|
+
private newConversation;
|
|
695
|
+
}
|
|
696
|
+
|
|
590
697
|
/**
|
|
591
698
|
* A command bot for receiving commands and sending responses in Teams.
|
|
592
699
|
*
|
|
593
700
|
* @remarks
|
|
594
701
|
* 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.
|
|
595
702
|
*/
|
|
703
|
+
/**
|
|
704
|
+
* @deprecated Use `BotBuilderCloudAdapter.CommandBot` instead.
|
|
705
|
+
*/
|
|
596
706
|
export declare class CommandBot {
|
|
597
707
|
private readonly adapter;
|
|
598
708
|
private readonly middleware;
|
|
@@ -631,6 +741,52 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
631
741
|
private validateSsoActivityHandler;
|
|
632
742
|
}
|
|
633
743
|
|
|
744
|
+
/**
|
|
745
|
+
* A command bot for receiving commands and sending responses in Teams.
|
|
746
|
+
*
|
|
747
|
+
* @remarks
|
|
748
|
+
* 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.
|
|
749
|
+
*/
|
|
750
|
+
declare class CommandBot_2 {
|
|
751
|
+
private readonly adapter;
|
|
752
|
+
private readonly middleware;
|
|
753
|
+
private readonly ssoConfig;
|
|
754
|
+
/**
|
|
755
|
+
* Create a new instance of the `CommandBot`.
|
|
756
|
+
*
|
|
757
|
+
* @param adapter - The bound `CloudAdapter`.
|
|
758
|
+
* @param options - The initialize options
|
|
759
|
+
* @param ssoCommandActivityHandler - SSO execution activity handler.
|
|
760
|
+
* @param ssoConfig - SSO configuration for Bot SSO.
|
|
761
|
+
*/
|
|
762
|
+
constructor(adapter: CloudAdapter, options?: CommandOptions, ssoCommandActivityHandler?: BotSsoExecutionActivityHandler, ssoConfig?: BotSsoConfig);
|
|
763
|
+
/**
|
|
764
|
+
* Register a command into the command bot.
|
|
765
|
+
*
|
|
766
|
+
* @param command - The command to be registered.
|
|
767
|
+
*/
|
|
768
|
+
registerCommand(command: TeamsFxBotCommandHandler): void;
|
|
769
|
+
/**
|
|
770
|
+
* Register commands into the command bot.
|
|
771
|
+
*
|
|
772
|
+
* @param commands - The commands to be registered.
|
|
773
|
+
*/
|
|
774
|
+
registerCommands(commands: TeamsFxBotCommandHandler[]): void;
|
|
775
|
+
/**
|
|
776
|
+
* Register a sso command into the command bot.
|
|
777
|
+
*
|
|
778
|
+
* @param ssoCommand - The sso command to be registered.
|
|
779
|
+
*/
|
|
780
|
+
registerSsoCommand(ssoCommand: TeamsFxBotSsoCommandHandler): void;
|
|
781
|
+
/**
|
|
782
|
+
* Register sso commands into the command bot.
|
|
783
|
+
*
|
|
784
|
+
* @param ssoCommands - The sso commands to be registered.
|
|
785
|
+
*/
|
|
786
|
+
registerSsoCommands(ssoCommands: TeamsFxBotSsoCommandHandler[]): void;
|
|
787
|
+
private validateSsoActivityHandler;
|
|
788
|
+
}
|
|
789
|
+
|
|
634
790
|
/**
|
|
635
791
|
* Interface for a command message that can handled in a command handler.
|
|
636
792
|
*/
|
|
@@ -710,6 +866,9 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
710
866
|
*
|
|
711
867
|
* For notification, set `notification.storage` in {@link ConversationOptions} to use your own storage implementation.
|
|
712
868
|
*/
|
|
869
|
+
/**
|
|
870
|
+
* @deprecated Use `BotBuilderCloudAdapter.ConversationBot` instead.
|
|
871
|
+
*/
|
|
713
872
|
export declare class ConversationBot {
|
|
714
873
|
/**
|
|
715
874
|
* The bot adapter.
|
|
@@ -761,8 +920,119 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
761
920
|
requestHandler(req: WebRequest, res: WebResponse, logic?: (context: TurnContext) => Promise<any>): Promise<void>;
|
|
762
921
|
}
|
|
763
922
|
|
|
923
|
+
/**
|
|
924
|
+
* Provide utilities for bot conversation, including:
|
|
925
|
+
* - handle command and response.
|
|
926
|
+
* - send notification to varies targets (e.g., member, group, channel).
|
|
927
|
+
*
|
|
928
|
+
* @example
|
|
929
|
+
* For command and response, you can register your commands through the constructor, or use the `registerCommand` and `registerCommands` API to add commands later.
|
|
930
|
+
*
|
|
931
|
+
* ```typescript
|
|
932
|
+
* import { BotBuilderCloudAdapter } from "@microsoft/teamsfx";
|
|
933
|
+
* import ConversationBot = BotBuilderCloudAdapter.ConversationBot;
|
|
934
|
+
*
|
|
935
|
+
* // register through constructor
|
|
936
|
+
* const conversationBot = new ConversationBot({
|
|
937
|
+
* command: {
|
|
938
|
+
* enabled: true,
|
|
939
|
+
* commands: [ new HelloWorldCommandHandler() ],
|
|
940
|
+
* },
|
|
941
|
+
* });
|
|
942
|
+
*
|
|
943
|
+
* // register through `register*` API
|
|
944
|
+
* conversationBot.command.registerCommand(new HelpCommandHandler());
|
|
945
|
+
* ```
|
|
946
|
+
*
|
|
947
|
+
* For notification, you can enable notification at initialization, then send notifications at any time.
|
|
948
|
+
*
|
|
949
|
+
* ```typescript
|
|
950
|
+
* import { BotBuilderCloudAdapter } from "@microsoft/teamsfx";
|
|
951
|
+
* import ConversationBot = BotBuilderCloudAdapter.ConversationBot;
|
|
952
|
+
*
|
|
953
|
+
* // enable through constructor
|
|
954
|
+
* const conversationBot = new ConversationBot({
|
|
955
|
+
* notification: {
|
|
956
|
+
* enabled: true,
|
|
957
|
+
* },
|
|
958
|
+
* });
|
|
959
|
+
*
|
|
960
|
+
* // get all bot installations and send message
|
|
961
|
+
* for (const target of await conversationBot.notification.installations()) {
|
|
962
|
+
* await target.sendMessage("Hello Notification");
|
|
963
|
+
* }
|
|
964
|
+
*
|
|
965
|
+
* // alternative - send message to all members
|
|
966
|
+
* for (const target of await conversationBot.notification.installations()) {
|
|
967
|
+
* for (const member of await target.members()) {
|
|
968
|
+
* await member.sendMessage("Hello Notification");
|
|
969
|
+
* }
|
|
970
|
+
* }
|
|
971
|
+
* ```
|
|
972
|
+
*
|
|
973
|
+
* @remarks
|
|
974
|
+
* Set `adapter` in {@link ConversationOptions} to use your own bot adapter.
|
|
975
|
+
*
|
|
976
|
+
* 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.
|
|
977
|
+
*
|
|
978
|
+
* For notification, set `notification.storage` in {@link ConversationOptions} to use your own storage implementation.
|
|
979
|
+
*/
|
|
980
|
+
declare class ConversationBot_2 {
|
|
981
|
+
/**
|
|
982
|
+
* The bot adapter.
|
|
983
|
+
*/
|
|
984
|
+
readonly adapter: CloudAdapter;
|
|
985
|
+
/**
|
|
986
|
+
* The entrypoint of command and response.
|
|
987
|
+
*/
|
|
988
|
+
readonly command?: CommandBot_2;
|
|
989
|
+
/**
|
|
990
|
+
* The entrypoint of notification.
|
|
991
|
+
*/
|
|
992
|
+
readonly notification?: NotificationBot_2;
|
|
993
|
+
/**
|
|
994
|
+
* The action handler used for adaptive card universal actions.
|
|
995
|
+
*/
|
|
996
|
+
readonly cardAction?: CardActionBot_2;
|
|
997
|
+
/**
|
|
998
|
+
* Create new instance of the `ConversationBot`.
|
|
999
|
+
*
|
|
1000
|
+
* @remarks
|
|
1001
|
+
* It's recommended to create your own adapter and storage for production environment instead of the default one.
|
|
1002
|
+
*
|
|
1003
|
+
* @param options - The initialize options.
|
|
1004
|
+
*/
|
|
1005
|
+
constructor(options: ConversationOptions_2);
|
|
1006
|
+
private createDefaultAdapter;
|
|
1007
|
+
/**
|
|
1008
|
+
* The request handler to integrate with web request.
|
|
1009
|
+
*
|
|
1010
|
+
* @param req - An incoming HTTP [Request](xref:botbuilder.Request).
|
|
1011
|
+
* @param res - The corresponding HTTP [Response](xref:botbuilder.Response).
|
|
1012
|
+
* @param logic - The additional function to handle bot context.
|
|
1013
|
+
*
|
|
1014
|
+
* @example
|
|
1015
|
+
* For example, to use with Restify:
|
|
1016
|
+
* ``` typescript
|
|
1017
|
+
* // The default/empty behavior
|
|
1018
|
+
* server.use(restify.plugins.bodyParser());
|
|
1019
|
+
* server.post("api/messages", conversationBot.requestHandler);
|
|
1020
|
+
*
|
|
1021
|
+
* // Or, add your own logic
|
|
1022
|
+
* server.use(restify.plugins.bodyParser());
|
|
1023
|
+
* server.post("api/messages", async (req, res) => {
|
|
1024
|
+
* await conversationBot.requestHandler(req, res, async (context) => {
|
|
1025
|
+
* // your-own-context-logic
|
|
1026
|
+
* });
|
|
1027
|
+
* });
|
|
1028
|
+
* ```
|
|
1029
|
+
*/
|
|
1030
|
+
requestHandler(req: Request_2, res: Response_2, logic?: (context: TurnContext) => Promise<any>): Promise<void>;
|
|
1031
|
+
}
|
|
1032
|
+
|
|
764
1033
|
/**
|
|
765
1034
|
* Options to initialize {@link ConversationBot}
|
|
1035
|
+
* @deprecated Please use BotBuilderCloudAdapter.ConversationOptions instead.
|
|
766
1036
|
*/
|
|
767
1037
|
export declare interface ConversationOptions {
|
|
768
1038
|
/**
|
|
@@ -816,6 +1086,61 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
816
1086
|
};
|
|
817
1087
|
}
|
|
818
1088
|
|
|
1089
|
+
/**
|
|
1090
|
+
* Options to initialize {@link ConversationBot}
|
|
1091
|
+
*/
|
|
1092
|
+
declare interface ConversationOptions_2 {
|
|
1093
|
+
/**
|
|
1094
|
+
* The bot adapter. If not provided, a default adapter will be created:
|
|
1095
|
+
* - with `adapterConfig` as constructor parameter.
|
|
1096
|
+
* - with a default error handler that logs error to console, sends trace activity, and sends error message to user.
|
|
1097
|
+
*
|
|
1098
|
+
* @remarks
|
|
1099
|
+
* If neither `adapter` nor `adapterConfig` is provided, will use BOT_ID and BOT_PASSWORD from environment variables.
|
|
1100
|
+
*/
|
|
1101
|
+
adapter?: CloudAdapter;
|
|
1102
|
+
/**
|
|
1103
|
+
* If `adapter` is not provided, this `adapterConfig` will be passed to the new `CloudAdapter` when created internally.
|
|
1104
|
+
*
|
|
1105
|
+
* @remarks
|
|
1106
|
+
* If neither `adapter` nor `adapterConfig` is provided, will use BOT_ID and BOT_PASSWORD from environment variables.
|
|
1107
|
+
*/
|
|
1108
|
+
adapterConfig?: {
|
|
1109
|
+
[key: string]: unknown;
|
|
1110
|
+
};
|
|
1111
|
+
/**
|
|
1112
|
+
* Configurations for sso command bot
|
|
1113
|
+
*/
|
|
1114
|
+
ssoConfig?: BotSsoConfig;
|
|
1115
|
+
/**
|
|
1116
|
+
* The command part.
|
|
1117
|
+
*/
|
|
1118
|
+
command?: CommandOptions & {
|
|
1119
|
+
/**
|
|
1120
|
+
* Whether to enable command or not.
|
|
1121
|
+
*/
|
|
1122
|
+
enabled?: boolean;
|
|
1123
|
+
};
|
|
1124
|
+
/**
|
|
1125
|
+
* The notification part.
|
|
1126
|
+
*/
|
|
1127
|
+
notification?: NotificationOptions_3 & {
|
|
1128
|
+
/**
|
|
1129
|
+
* Whether to enable notification or not.
|
|
1130
|
+
*/
|
|
1131
|
+
enabled?: boolean;
|
|
1132
|
+
};
|
|
1133
|
+
/**
|
|
1134
|
+
* The adaptive card action handler part.
|
|
1135
|
+
*/
|
|
1136
|
+
cardAction?: CardActionOptions & {
|
|
1137
|
+
/**
|
|
1138
|
+
* Whether to enable adaptive card actions or not.
|
|
1139
|
+
*/
|
|
1140
|
+
enabled?: boolean;
|
|
1141
|
+
};
|
|
1142
|
+
}
|
|
1143
|
+
|
|
819
1144
|
/**
|
|
820
1145
|
* Initializes new Axios instance with specific auth provider
|
|
821
1146
|
*
|
|
@@ -1200,9 +1525,9 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
1200
1525
|
* The type of the invoke response is `application/vnd.microsoft.activity.message`
|
|
1201
1526
|
* indicates the request was successfully processed.
|
|
1202
1527
|
*
|
|
1203
|
-
* @param message A text message included in a invoke response.
|
|
1528
|
+
* @param message - A text message included in a invoke response.
|
|
1204
1529
|
*
|
|
1205
|
-
* @returns
|
|
1530
|
+
* @returns An `InvokeResponse` object.
|
|
1206
1531
|
*/
|
|
1207
1532
|
static textMessage(message: string): InvokeResponse;
|
|
1208
1533
|
/**
|
|
@@ -1212,9 +1537,9 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
1212
1537
|
* the request was successfully processed, and the response includes an adaptive card
|
|
1213
1538
|
* that the client should display in place of the current one.
|
|
1214
1539
|
*
|
|
1215
|
-
* @param card The adaptive card JSON payload.
|
|
1540
|
+
* @param card - The adaptive card JSON payload.
|
|
1216
1541
|
*
|
|
1217
|
-
* @returns
|
|
1542
|
+
* @returns An `InvokeResponse` object.
|
|
1218
1543
|
*/
|
|
1219
1544
|
static adaptiveCard(card: unknown): InvokeResponse;
|
|
1220
1545
|
/**
|
|
@@ -1223,20 +1548,20 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
1223
1548
|
* The type of the invoke response is `application/vnd.microsoft.error` indicates
|
|
1224
1549
|
* the request was failed to processed.
|
|
1225
1550
|
*
|
|
1226
|
-
* @param errorCode The status code indicates error, available values:
|
|
1551
|
+
* @param errorCode - The status code indicates error, available values:
|
|
1227
1552
|
* - 400 (BadRequest): indicate the incoming request was invalid.
|
|
1228
1553
|
* - 500 (InternalServerError): indicate an unexpected error occurred.
|
|
1229
|
-
* @param errorMessage The error message.
|
|
1554
|
+
* @param errorMessage - The error message.
|
|
1230
1555
|
*
|
|
1231
|
-
* @returns
|
|
1556
|
+
* @returns An `InvokeResponse` object.
|
|
1232
1557
|
*/
|
|
1233
1558
|
static errorResponse(errorCode: InvokeResponseErrorCode, errorMessage: string): InvokeResponse;
|
|
1234
1559
|
/**
|
|
1235
1560
|
* Create an invoke response with status code and response value.
|
|
1236
|
-
* @param statusCode The status code.
|
|
1237
|
-
* @param body The value of the response body.
|
|
1561
|
+
* @param statusCode - The status code.
|
|
1562
|
+
* @param body - The value of the response body.
|
|
1238
1563
|
*
|
|
1239
|
-
* @returns
|
|
1564
|
+
* @returns An `InvokeResponse` object.
|
|
1240
1565
|
*/
|
|
1241
1566
|
static createInvokeResponse(statusCode: StatusCodes, body?: unknown): InvokeResponse;
|
|
1242
1567
|
}
|
|
@@ -1343,6 +1668,61 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
1343
1668
|
private newConversation;
|
|
1344
1669
|
}
|
|
1345
1670
|
|
|
1671
|
+
/**
|
|
1672
|
+
* A {@link NotificationTarget} that represents a team member.
|
|
1673
|
+
*
|
|
1674
|
+
* @remarks
|
|
1675
|
+
* It's recommended to get members from {@link TeamsBotInstallation.members()}.
|
|
1676
|
+
*/
|
|
1677
|
+
declare class Member_2 implements NotificationTarget {
|
|
1678
|
+
/**
|
|
1679
|
+
* The parent {@link TeamsBotInstallation} where this member is created from.
|
|
1680
|
+
*/
|
|
1681
|
+
readonly parent: TeamsBotInstallation_2;
|
|
1682
|
+
/**
|
|
1683
|
+
* Detailed member account information.
|
|
1684
|
+
*/
|
|
1685
|
+
readonly account: TeamsChannelAccount;
|
|
1686
|
+
/**
|
|
1687
|
+
* Notification target type. For member it's always "Person".
|
|
1688
|
+
*/
|
|
1689
|
+
readonly type: NotificationTargetType;
|
|
1690
|
+
/**
|
|
1691
|
+
* Constructor.
|
|
1692
|
+
*
|
|
1693
|
+
* @remarks
|
|
1694
|
+
* It's recommended to get members from {@link TeamsBotInstallation.members()}, instead of using this constructor.
|
|
1695
|
+
*
|
|
1696
|
+
* @param parent - The parent {@link TeamsBotInstallation} where this member is created from.
|
|
1697
|
+
* @param account - Detailed member account information.
|
|
1698
|
+
*/
|
|
1699
|
+
constructor(parent: TeamsBotInstallation_2, account: TeamsChannelAccount);
|
|
1700
|
+
/**
|
|
1701
|
+
* Send a plain text message.
|
|
1702
|
+
*
|
|
1703
|
+
* @param text - The plain text message.
|
|
1704
|
+
* @param onError - An optional error handler that can catch exceptions during message sending.
|
|
1705
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
1706
|
+
*
|
|
1707
|
+
* @returns The response of sending message.
|
|
1708
|
+
*/
|
|
1709
|
+
sendMessage(text: string, onError?: (context: TurnContext, error: Error) => Promise<void>): Promise<MessageResponse>;
|
|
1710
|
+
/**
|
|
1711
|
+
* Send an adaptive card message.
|
|
1712
|
+
*
|
|
1713
|
+
* @param card - The adaptive card raw JSON.
|
|
1714
|
+
* @param onError - An optional error handler that can catch exceptions during adaptive card sending.
|
|
1715
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
1716
|
+
*
|
|
1717
|
+
* @returns The response of sending adaptive card message.
|
|
1718
|
+
*/
|
|
1719
|
+
sendAdaptiveCard(card: unknown, onError?: (context: TurnContext, error: Error) => Promise<void>): Promise<MessageResponse>;
|
|
1720
|
+
/**
|
|
1721
|
+
* @internal
|
|
1722
|
+
*/
|
|
1723
|
+
private newConversation;
|
|
1724
|
+
}
|
|
1725
|
+
|
|
1346
1726
|
/**
|
|
1347
1727
|
* Provides utility method to build bot message with cards that supported in Teams.
|
|
1348
1728
|
*/
|
|
@@ -1526,6 +1906,9 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
1526
1906
|
/**
|
|
1527
1907
|
* Provide utilities to send notification to varies targets (e.g., member, group, channel).
|
|
1528
1908
|
*/
|
|
1909
|
+
/**
|
|
1910
|
+
* @deprecated Use `BotBuilderCloudAdapter.NotificationBot` instead.
|
|
1911
|
+
*/
|
|
1529
1912
|
export declare class NotificationBot {
|
|
1530
1913
|
private readonly conversationReferenceStore;
|
|
1531
1914
|
private readonly adapter;
|
|
@@ -1589,8 +1972,80 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
1589
1972
|
private matchSearchScope;
|
|
1590
1973
|
}
|
|
1591
1974
|
|
|
1975
|
+
/**
|
|
1976
|
+
* Provide utilities to send notification to varies targets (e.g., member, group, channel).
|
|
1977
|
+
*/
|
|
1978
|
+
declare class NotificationBot_2 {
|
|
1979
|
+
private readonly conversationReferenceStore;
|
|
1980
|
+
private readonly adapter;
|
|
1981
|
+
private readonly botAppId;
|
|
1982
|
+
/**
|
|
1983
|
+
* Constructor of the notification bot.
|
|
1984
|
+
*
|
|
1985
|
+
* @remarks
|
|
1986
|
+
* To ensure accuracy, it's recommended to initialize before handling any message.
|
|
1987
|
+
*
|
|
1988
|
+
* @param adapter - The bound `CloudAdapter`
|
|
1989
|
+
* @param options - The initialize options
|
|
1990
|
+
*/
|
|
1991
|
+
constructor(adapter: CloudAdapter, options?: NotificationOptions_3);
|
|
1992
|
+
/**
|
|
1993
|
+
* Get all targets where the bot is installed.
|
|
1994
|
+
*
|
|
1995
|
+
* @remarks
|
|
1996
|
+
* The result is retrieving from the persisted storage.
|
|
1997
|
+
*
|
|
1998
|
+
* @returns An array of {@link TeamsBotInstallation}.
|
|
1999
|
+
*/
|
|
2000
|
+
installations(): Promise<TeamsBotInstallation_2[]>;
|
|
2001
|
+
/**
|
|
2002
|
+
* Return the first {@link Member} where predicate is true, and undefined otherwise.
|
|
2003
|
+
*
|
|
2004
|
+
* @param predicate - Find calls predicate once for each member of the installation,
|
|
2005
|
+
* until it finds one where predicate returns true. If such a member is found, find
|
|
2006
|
+
* immediately returns that member. Otherwise, find returns undefined.
|
|
2007
|
+
* @param scope - The scope to find members from the installations
|
|
2008
|
+
* (personal chat, group chat, Teams channel).
|
|
2009
|
+
*
|
|
2010
|
+
* @returns The first {@link Member} where predicate is true, and `undefined` otherwise.
|
|
2011
|
+
*/
|
|
2012
|
+
findMember(predicate: (member: Member_2) => Promise<boolean>, scope?: SearchScope_2): Promise<Member_2 | undefined>;
|
|
2013
|
+
/**
|
|
2014
|
+
* Return the first {@link Channel} where predicate is true, and undefined otherwise.
|
|
2015
|
+
* (Ensure the bot app is installed into the `General` channel, otherwise undefined will be returned.)
|
|
2016
|
+
*
|
|
2017
|
+
* @param predicate - Find calls predicate once for each channel of the installation,
|
|
2018
|
+
* until it finds one where predicate returns true. If such a channel is found, find
|
|
2019
|
+
* immediately returns that channel. Otherwise, find returns `undefined`.
|
|
2020
|
+
*
|
|
2021
|
+
* @returns The first {@link Channel} where predicate is true, and `undefined` otherwise.
|
|
2022
|
+
*/
|
|
2023
|
+
findChannel(predicate: (channel: Channel_2, teamDetails: TeamDetails | undefined) => Promise<boolean>): Promise<Channel_2 | undefined>;
|
|
2024
|
+
/**
|
|
2025
|
+
* Return all {@link Member} where predicate is true, and empty array otherwise.
|
|
2026
|
+
*
|
|
2027
|
+
* @param predicate - Find calls predicate for each member of the installation.
|
|
2028
|
+
* @param scope - The scope to find members from the installations
|
|
2029
|
+
* (personal chat, group chat, Teams channel).
|
|
2030
|
+
*
|
|
2031
|
+
* @returns An array of {@link Member} where predicate is true, and empty array otherwise.
|
|
2032
|
+
*/
|
|
2033
|
+
findAllMembers(predicate: (member: Member_2) => Promise<boolean>, scope?: SearchScope_2): Promise<Member_2[]>;
|
|
2034
|
+
/**
|
|
2035
|
+
* Return all {@link Channel} where predicate is true, and empty array otherwise.
|
|
2036
|
+
* (Ensure the bot app is installed into the `General` channel, otherwise empty array will be returned.)
|
|
2037
|
+
*
|
|
2038
|
+
* @param predicate - Find calls predicate for each channel of the installation.
|
|
2039
|
+
*
|
|
2040
|
+
* @returns An array of {@link Channel} where predicate is true, and empty array otherwise.
|
|
2041
|
+
*/
|
|
2042
|
+
findAllChannels(predicate: (channel: Channel_2, teamDetails: TeamDetails | undefined) => Promise<boolean>): Promise<Channel_2[]>;
|
|
2043
|
+
private matchSearchScope;
|
|
2044
|
+
}
|
|
2045
|
+
|
|
1592
2046
|
/**
|
|
1593
2047
|
* Options to initialize {@link NotificationBot}.
|
|
2048
|
+
* @deprecated Please use BotBuilderCloudAdapter.NotificationOptions instead.
|
|
1594
2049
|
*/
|
|
1595
2050
|
declare interface NotificationOptions_2 {
|
|
1596
2051
|
/**
|
|
@@ -1608,6 +2063,31 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
1608
2063
|
}
|
|
1609
2064
|
export { NotificationOptions_2 as NotificationOptions }
|
|
1610
2065
|
|
|
2066
|
+
/**
|
|
2067
|
+
* Options to initialize {@link NotificationBot}.
|
|
2068
|
+
*/
|
|
2069
|
+
declare interface NotificationOptions_3 {
|
|
2070
|
+
/**
|
|
2071
|
+
* An optional input of bot app Id.
|
|
2072
|
+
*
|
|
2073
|
+
* @remarks
|
|
2074
|
+
* If `botAppId` is not provided, `process.env.BOT_ID` will be used by default.
|
|
2075
|
+
*/
|
|
2076
|
+
botAppId?: string;
|
|
2077
|
+
/**
|
|
2078
|
+
* An optional storage to persist bot notification connections.
|
|
2079
|
+
*
|
|
2080
|
+
* @remarks
|
|
2081
|
+
* If `storage` is not provided, a default local file storage will be used,
|
|
2082
|
+
* which stores notification connections into:
|
|
2083
|
+
* - `.notification.localstore.json` if running locally
|
|
2084
|
+
* - `${process.env.TEMP}/.notification.localstore.json` if `process.env.RUNNING_ON_AZURE` is set to "1"
|
|
2085
|
+
*
|
|
2086
|
+
* It's recommended to use your own shared storage for production environment.
|
|
2087
|
+
*/
|
|
2088
|
+
storage?: NotificationTargetStorage;
|
|
2089
|
+
}
|
|
2090
|
+
|
|
1611
2091
|
/**
|
|
1612
2092
|
* Represent a notification target.
|
|
1613
2093
|
*/
|
|
@@ -1852,6 +2332,30 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
1852
2332
|
All = 7
|
|
1853
2333
|
}
|
|
1854
2334
|
|
|
2335
|
+
/**
|
|
2336
|
+
* The search scope when calling {@link NotificationBot.findMember} and {@link NotificationBot.findAllMembers}.
|
|
2337
|
+
* The search scope is a flagged enum and it can be combined with `|`.
|
|
2338
|
+
* For example, to search from personal chat and group chat, use `SearchScope.Person | SearchScope.Group`.
|
|
2339
|
+
*/
|
|
2340
|
+
declare enum SearchScope_2 {
|
|
2341
|
+
/**
|
|
2342
|
+
* Search members from the installations in personal chat only.
|
|
2343
|
+
*/
|
|
2344
|
+
Person = 1,
|
|
2345
|
+
/**
|
|
2346
|
+
* Search members from the installations in group chat only.
|
|
2347
|
+
*/
|
|
2348
|
+
Group = 2,
|
|
2349
|
+
/**
|
|
2350
|
+
* Search members from the installations in Teams channel only.
|
|
2351
|
+
*/
|
|
2352
|
+
Channel = 4,
|
|
2353
|
+
/**
|
|
2354
|
+
* Search members from all installations including personal chat, group chat and Teams channel.
|
|
2355
|
+
*/
|
|
2356
|
+
All = 7
|
|
2357
|
+
}
|
|
2358
|
+
|
|
1855
2359
|
/**
|
|
1856
2360
|
* Send an adaptive card message to a notification target.
|
|
1857
2361
|
*
|
|
@@ -1863,6 +2367,18 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
1863
2367
|
*/
|
|
1864
2368
|
export declare function sendAdaptiveCard(target: NotificationTarget, card: unknown, onError?: (context: TurnContext, error: Error) => Promise<void>): Promise<MessageResponse>;
|
|
1865
2369
|
|
|
2370
|
+
/**
|
|
2371
|
+
* Send an adaptive card message to a notification target.
|
|
2372
|
+
*
|
|
2373
|
+
* @param target - The notification target.
|
|
2374
|
+
* @param card - The adaptive card raw JSON.
|
|
2375
|
+
* @param onError - An optional error handler that can catch exceptions during adaptive card sending.
|
|
2376
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2377
|
+
*
|
|
2378
|
+
* @returns The response of sending adaptive card message.
|
|
2379
|
+
*/
|
|
2380
|
+
declare function sendAdaptiveCard_2(target: NotificationTarget, card: unknown, onError?: (context: TurnContext, error: Error) => Promise<void>): Promise<MessageResponse>;
|
|
2381
|
+
|
|
1866
2382
|
/**
|
|
1867
2383
|
* Send a plain text message to a notification target.
|
|
1868
2384
|
*
|
|
@@ -1874,6 +2390,18 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
1874
2390
|
*/
|
|
1875
2391
|
export declare function sendMessage(target: NotificationTarget, text: string, onError?: (context: TurnContext, error: Error) => Promise<void>): Promise<MessageResponse>;
|
|
1876
2392
|
|
|
2393
|
+
/**
|
|
2394
|
+
* Send a plain text message to a notification target.
|
|
2395
|
+
*
|
|
2396
|
+
* @param target - The notification target.
|
|
2397
|
+
* @param text - The plain text message.
|
|
2398
|
+
* @param onError - An optional error handler that can catch exceptions during message sending.
|
|
2399
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2400
|
+
*
|
|
2401
|
+
* @returns The response of sending message.
|
|
2402
|
+
*/
|
|
2403
|
+
declare function sendMessage_2(target: NotificationTarget, text: string, onError?: (context: TurnContext, error: Error) => Promise<void>): Promise<MessageResponse>;
|
|
2404
|
+
|
|
1877
2405
|
/**
|
|
1878
2406
|
* Set custom log function. Use the function if it's set. Priority is lower than setLogger.
|
|
1879
2407
|
*
|
|
@@ -1923,6 +2451,9 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
1923
2451
|
* @remarks
|
|
1924
2452
|
* It's recommended to get bot installations from {@link ConversationBot.installations()}.
|
|
1925
2453
|
*/
|
|
2454
|
+
/**
|
|
2455
|
+
* @deprecated Use `BotBuilderCloudAdapter.TeamsBotInstallation` instead.
|
|
2456
|
+
*/
|
|
1926
2457
|
export declare class TeamsBotInstallation implements NotificationTarget {
|
|
1927
2458
|
/**
|
|
1928
2459
|
* The bound `BotFrameworkAdapter`.
|
|
@@ -1989,6 +2520,88 @@ export declare class BotSsoExecutionDialog extends ComponentDialog {
|
|
|
1989
2520
|
getTeamDetails(): Promise<TeamDetails | undefined>;
|
|
1990
2521
|
}
|
|
1991
2522
|
|
|
2523
|
+
/**
|
|
2524
|
+
* A {@link NotificationTarget} that represents a bot installation. Teams Bot could be installed into
|
|
2525
|
+
* - Personal chat
|
|
2526
|
+
* - Group chat
|
|
2527
|
+
* - Team (by default the `General` channel)
|
|
2528
|
+
*
|
|
2529
|
+
* @remarks
|
|
2530
|
+
* It's recommended to get bot installations from {@link ConversationBot.installations()}.
|
|
2531
|
+
*/
|
|
2532
|
+
declare class TeamsBotInstallation_2 implements NotificationTarget {
|
|
2533
|
+
/**
|
|
2534
|
+
* The bound `CloudAdapter`.
|
|
2535
|
+
*/
|
|
2536
|
+
readonly adapter: CloudAdapter;
|
|
2537
|
+
/**
|
|
2538
|
+
* The bound `ConversationReference`.
|
|
2539
|
+
*/
|
|
2540
|
+
readonly conversationReference: Partial<ConversationReference>;
|
|
2541
|
+
/**
|
|
2542
|
+
* The bot app id.
|
|
2543
|
+
*/
|
|
2544
|
+
readonly botAppId: string;
|
|
2545
|
+
/**
|
|
2546
|
+
* Notification target type.
|
|
2547
|
+
*
|
|
2548
|
+
* @remarks
|
|
2549
|
+
* - "Channel" means bot is installed into a team and notification will be sent to its "General" channel.
|
|
2550
|
+
* - "Group" means bot is installed into a group chat.
|
|
2551
|
+
* - "Person" means bot is installed into a personal scope and notification will be sent to personal chat.
|
|
2552
|
+
*/
|
|
2553
|
+
readonly type?: NotificationTargetType;
|
|
2554
|
+
/**
|
|
2555
|
+
* Constructor
|
|
2556
|
+
*
|
|
2557
|
+
* @remarks
|
|
2558
|
+
* It's recommended to get bot installations from {@link ConversationBot.installations()}, instead of using this constructor.
|
|
2559
|
+
*
|
|
2560
|
+
* @param adapter - The bound `CloudAdapter`.
|
|
2561
|
+
* @param conversationReference - The bound `ConversationReference`.
|
|
2562
|
+
* @param botAppId - The bot app id.
|
|
2563
|
+
*/
|
|
2564
|
+
constructor(adapter: CloudAdapter, conversationReference: Partial<ConversationReference>, botAppId: string);
|
|
2565
|
+
/**
|
|
2566
|
+
* Send a plain text message.
|
|
2567
|
+
*
|
|
2568
|
+
* @param text - The plain text message.
|
|
2569
|
+
* @param onError - An optional error handler that can catch exceptions during message sending.
|
|
2570
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2571
|
+
*
|
|
2572
|
+
* @returns The response of sending message.
|
|
2573
|
+
*/
|
|
2574
|
+
sendMessage(text: string, onError?: (context: TurnContext, error: Error) => Promise<void>): Promise<MessageResponse>;
|
|
2575
|
+
/**
|
|
2576
|
+
* Send an adaptive card message.
|
|
2577
|
+
*
|
|
2578
|
+
* @param card - The adaptive card raw JSON.
|
|
2579
|
+
* @param onError - An optional error handler that can catch exceptions during adaptive card sending.
|
|
2580
|
+
* If not defined, error will be handled by `BotAdapter.onTurnError`.
|
|
2581
|
+
*
|
|
2582
|
+
* @returns The response of sending adaptive card message.
|
|
2583
|
+
*/
|
|
2584
|
+
sendAdaptiveCard(card: unknown, onError?: (context: TurnContext, error: Error) => Promise<void>): Promise<MessageResponse>;
|
|
2585
|
+
/**
|
|
2586
|
+
* Get channels from this bot installation.
|
|
2587
|
+
*
|
|
2588
|
+
* @returns An array of channels if bot is installed into a team, otherwise returns an empty array.
|
|
2589
|
+
*/
|
|
2590
|
+
channels(): Promise<Channel_2[]>;
|
|
2591
|
+
/**
|
|
2592
|
+
* Get members from this bot installation.
|
|
2593
|
+
*
|
|
2594
|
+
* @returns An array of members from where the bot is installed.
|
|
2595
|
+
*/
|
|
2596
|
+
members(): Promise<Member_2[]>;
|
|
2597
|
+
/**
|
|
2598
|
+
* Get team details from this bot installation
|
|
2599
|
+
*
|
|
2600
|
+
* @returns The team details if bot is installed into a team, otherwise returns `undefined`.
|
|
2601
|
+
*/
|
|
2602
|
+
getTeamDetails(): Promise<TeamDetails | undefined>;
|
|
2603
|
+
}
|
|
2604
|
+
|
|
1992
2605
|
/**
|
|
1993
2606
|
* Creates a new prompt that leverage Teams Single Sign On (SSO) support for bot to automatically sign in user and
|
|
1994
2607
|
* help receive oauth token, asks the user to consent if needed.
|