Пример #1
0
        /// <summary>
        /// Initializes a new instance of the <see cref="BasicBot"/> class.
        /// </summary>
        /// <param name="botServices">Bot services.</param>
        /// <param name="accessors">Bot State Accessors.</param>
        public BasicBot(
            BotServices services,

            UserState userState,
            ConversationState conversationState,
            BotStateAccessors stateBotAccessors,
            ITurnContextResolverService turnContextResolverService,
            IAuthService authService,
            ILoggerFactory loggerFactory
            )
        {
            this.services          = services ?? throw new ArgumentNullException(nameof(services));
            this.userState         = userState ?? throw new ArgumentNullException(nameof(userState));
            this.conversationState = conversationState ?? throw new ArgumentNullException(nameof(conversationState));

            this.authService = authService;

            this.turnContextResolverService = turnContextResolverService;
            dialogStateAccessor             = this.conversationState.CreateProperty <DialogState>(nameof(DialogState));
            this.stateBotAccessors          = stateBotAccessors ?? throw new System.ArgumentNullException(nameof(stateBotAccessors));

            // Verify LUIS configuration.
            if (!this.services.LuisServices.ContainsKey(LuisConfiguration))
            {
                throw new InvalidOperationException($"The bot configuration does not contain a service type of `luis` with the id `{LuisConfiguration}`.");
            }

            Dialogs = new DialogSet(dialogStateAccessor);
            Dialogs.Add(new LoginDialog(this.authService, this.stateBotAccessors));
            Dialogs.Add(new LogoutDialog(this.authService, this.stateBotAccessors));

            // Use this method to initilize the intents field in order to automize intent and entity parsing
            this.DeclareIntents();
        }
 public BaseService(
     ITurnContextResolverService turnContextResolver,
     BotStateAccessors botState,
     IOptions <AuthAppConfigs> authAppOptions
     )
 {
     this.turnContextResolver = turnContextResolver;
     this.botState            = botState;
     this.authAppConfigs      = authAppOptions;
 }
Пример #3
0
        public AuthService(
            ITurnContextResolverService turnContextResolverService,
            BotStateAccessors botState,
            IOptions <AuthAppConfigs> authAppConfigs
            ) : base(turnContextResolverService, botState, authAppConfigs)
        {
            this.authAppConfigs = authAppConfigs.Value;

            // Change if not using Azure AD v2.0
            this.AuthUri = $"https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id={this.authAppConfigs.AppId}&response_type=code&redirect_uri={this.authAppConfigs.RedirectUri}&response_mode=query&scope={this.authAppConfigs.GraphTokenScope}&state=12345";
        }
Пример #4
0
        public LogoutDialog(IAuthService authService, BotStateAccessors botStateAccessors)
            : base(nameof(LogoutDialog))
        {
            this.authService       = authService;
            this.botStateAccessors = botStateAccessors;

            var waterfallSteps = new WaterfallStep[]
            {
                LogoutStepAsync,
            };

            this.AddDialog(new WaterfallDialog(LogoutDialogName, waterfallSteps));
        }
        public LoginDialog(IAuthService authService, BotStateAccessors botStateAccessors)
            : base(nameof(LoginDialog))
        {
            this.authService       = authService;
            this.botStateAccessors = botStateAccessors;

            var waterfallSteps = new WaterfallStep[]
            {
                SendLoginLinkStepAsync,
                PromptForAuthCodeStepAsync,
                EndLoginStepAsync,
            };

            this.AddDialog(new WaterfallDialog(LoginDialogName, waterfallSteps));
            this.AddDialog(new TextPrompt(AuthCodePrompt, GetTokensAsync));
        }
Пример #6
0
 public AuthenticatedDialog(BotServices botServices, string dialogId, BotStateAccessors accessors) : base(botServices, dialogId)
 {
     _accessors   = accessors;
     _botServices = botServices;
     AddDialog(new AuthenticationDialog("", accessors));
 }