Esempio n. 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;
 }
Esempio n. 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";
        }