// In this example we will be using a static constructor on the Controller as these objects // should be singletons. Most likely a production application will be using one of the // Dependency Injection systems from NuGet such as Autofac, Unity, Ninject etc. static BotController() { _loggerFactory = new LoggerFactory(); // create the User and ConversationState objects (in this case, for testing, both based on the same memory store) var storage = new MemoryStorage(); _conversationState = new ConversationState(storage); _userState = new UserState(storage); // create the BotAdapter we will be using var credentialProvider = new ConfigurationCredentialProvider(); _adapter = new AdapterWithErrorHandler(credentialProvider, _loggerFactory.CreateLogger <BotFrameworkHttpAdapter>(), _conversationState); // read the old style Web.Config settings and construct a new style dot net core IConfiguration object var appsettings = ConfigurationManager.AppSettings.AllKeys.SelectMany( ConfigurationManager.AppSettings.GetValues, (k, v) => new KeyValuePair <string, string>(k, v)); var configuration = new ConfigurationBuilder() .AddInMemoryCollection(appsettings) .Build(); // LUIS recognizer and BookingDialog are used by the MainDialog var bookingRecognizer = new FlightBookingRecognizer(configuration); var bookingDialog = new BookingDialog(); // create the Dialog this bot will run - we need configuration because this Dialog will call LUIS _dialog = new MainDialog(bookingRecognizer, bookingDialog, _loggerFactory.CreateLogger <MainDialog>()); }
public MainDialog(ILogger <MainDialog> logger, IRecognizer luisRecognizer, BookingDialog bookingDialog) : base(nameof(MainDialog)) { _logger = logger; _luisRecognizer = luisRecognizer; AddDialog(new TextPrompt(nameof(TextPrompt))); // Add bookingDialog intents AddDialog(bookingDialog); // Create and add waterfall for main conversation loop // NOTE: we use a different task step if LUIS is not configured. WaterfallStep[] steps; if (luisRecognizer == null) { steps = new WaterfallStep[] { PromptForTaskStepAsync, InvokeTaskStepAsyncNoLuis, ResumeMainLoopStepAsync, }; } else { // LUIS is configured steps = new WaterfallStep[] { PromptForTaskStepAsync, InvokeTaskStepAsync, ResumeMainLoopStepAsync, }; } AddDialog(new WaterfallDialog(nameof(WaterfallDialog), steps)); // The initial child Dialog to run. InitialDialogId = nameof(WaterfallDialog); }
public DispatchBot(IBotServices botServices, BookingDialog bookingDialog, ILogger <DispatchBot> logger) { _logger = logger; _botServices = botServices; }
public MainDialog(ILogger <MainDialog> logger, BookingDialog bookingDialog) : this(logger, null, bookingDialog) { }