public ConversationManager( IQnAMachineLearningFacade qnaFacade, IIntentRecognizerFacade intentFacade, IWeatherIntentHandler weatherHandler, IServiceProvider serviceProvider) { _qnaFacade = qnaFacade; _intentFacade = intentFacade; _serviceProvider = serviceProvider; _weatherHandler = weatherHandler; }
// This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddControllers().AddNewtonsoftJson(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton <IBotFrameworkHttpAdapter, AdapterWithErrorHandler>(); // Create the bot as a transient. In this case the ASP Controller is expecting an IBot. services.AddTransient <IBot, BotActivityHandler>(); services.AddTransient <IConversationManager, ConversationManager>(); IIntentRecognizerFacade mlRecognizerFacade = (new IntentRecognizerFacade(new MLContext())); services.AddSingleton(mlRecognizerFacade); IQnAMachineLearningFacade mlQnaFacade = (new QnAMachineLearningFacade(new MLContext())); var qnAFileName = Configuration["QnAFile"]; mlQnaFacade.Train(qnAFileName); services.AddSingleton(mlQnaFacade); IIntentRecognizerFacade mlIntentFacade = (new IntentRecognizerFacade(new MLContext())); var intentFileName = Configuration["IntentFile"]; mlIntentFacade.Train(intentFileName); services.AddSingleton(mlIntentFacade); var storage = new MemoryStorage(); // Create the Conversation state passing in the storage layer. var conversationState = new ConversationState(storage); services.AddSingleton(conversationState); //Open Weather Api Facade var httpClient = new HttpClient(); var openWeatherApiKey = Configuration["OpenWeatherApiKey"]; IOpenWeatherApiFacade openWeatherApiFacade = new OpenWeatherApiFacade(openWeatherApiKey, httpClient); services.AddSingleton(openWeatherApiFacade); services.AddSingleton <IWeatherIntentHandler, WeatherIntentHandler>(); }