// Copyright (c) Microsoft Corporation. All rights reserved. // Licensed under the MIT License. using Microsoft.AspNetCore.Builder; using Microsoft.AspNetCore.Hosting; using Microsoft.Bot.Builder; using Microsoft.Bot.Builder.Integration.AspNet.Core; using Microsoft.Bot.Builder.Teams; using Microsoft.Bot.Connector.Authentication; using Microsoft.Extensions.DependencyInjection; using Microsoft.Extensions.Hosting; namespace Microsoft.BotBuilderSamples { public class Startup { // This method gets called by the runtime. Use this method to add services to the container. public void ConfigureServices(IServiceCollection services) { services.AddHttpClient().AddControllers().AddNewtonsoftJson(options => { options.SerializerSettings.MaxDepth = HttpHelper.BotMessageSerializerSettings.MaxDepth; }); // Create the Bot Framework Authentication to be used with the Bot Adapter. services.AddSingleton(); // Create the Bot Adapter with error handling enabled. services.AddSingleton(); // Create the storage we'll be using for User and Conversation state, as well as Single Sign On. // (Memory is great for testing purposes.) services.AddSingleton(); // For SSO, use CosmosDbPartitionedStorage /* COSMOSDB STORAGE - Uncomment the code in this section to use CosmosDB storage */ // var cosmosDbStorageOptions = new CosmosDbPartitionedStorageOptions() // { // CosmosDbEndpoint = "", // AuthKey = "", // DatabaseId = "", // ContainerId = "" // }; // var storage = new CosmosDbPartitionedStorage(cosmosDbStorageOptions); /* END COSMOSDB STORAGE */ // Create the User state. (Used in this bot's Dialog implementation.) services.AddSingleton(); // Create the Conversation state. (Used by the Dialog system itself.) services.AddSingleton(); // The Dialog that will be run by the bot. services.AddSingleton(); // Create the bot as a transient. In this case the ASP Controller is expecting an IBot. services.AddTransient>(); } // This method gets called by the runtime. Use this method to configure the HTTP request pipeline. public void Configure(IApplicationBuilder app, IWebHostEnvironment env) { if (env.IsDevelopment()) { app.UseDeveloperExceptionPage(); } app.UseDefaultFiles() .UseStaticFiles() .UseRouting() .UseAuthorization() .UseEndpoints(endpoints => { endpoints.MapControllers(); }); // app.UseHttpsRedirection(); } } }