public EchoBot(EchoBotAccessors accessors, LuisRecognizer luisRecognizer, IConfiguration configuration) { _accessors = accessors ?? throw new System.ArgumentNullException(nameof(accessors)); _dialogs = new DialogSet(_accessors.ConversationDialogState); _luis = luisRecognizer; Configuration = configuration; dh = new DialogHelper(); dal = new DataAccessLayer(Configuration); _ttsService = new TextToSpeechService(); var waterfallSteps = new WaterfallStep[] { ZeroStepAsync, FirstStepAsync, SecondStepAsync, ThirdStepAsync, FourthStepAsync, FifthStepAsync, }; //_dialogs.Add(new ReservationDialog(_accessors.UserDataState, Configuration)); _dialogs.Add(new WaterfallDialog("start", waterfallSteps)); _dialogs.Add(new TextPrompt("login")); _dialogs.Add(new TextPrompt("HR1")); _dialogs.Add(new TextPrompt("HR2")); _dialogs.Add(new TextPrompt("T1")); _dialogs.Add(new TextPrompt("T2")); }
public EchoBot(EchoBotAccessors accessors, LuisRecognizer luisRecognizer, IConfiguration configuration, IBotTelemetryClient telemetry) { _accessors = accessors ?? throw new System.ArgumentNullException(nameof(accessors)); _dialogs = new DialogSet(_accessors.ConversationDialogState); _luis = luisRecognizer; Configuration = configuration; _telemetry = telemetry; dh = new DialogHelper(); _ttsService = new TextToSpeechService(); var waterfallSteps = new WaterfallStep[] { ZeroStepAsync, FirstStepAsync, SecondStepAsync, ThirdStepAsync, FourthStepAsync, }; var waterfallSteps2 = new WaterfallStep[] { Assessment_ZeroStep, Assessment_FirstStep, }; var waterfallSteps3 = new WaterfallStep[] { Count_ZeroStep, Count_FirstStep, }; _dialogs.Add(new WaterfallDialog("booking", waterfallSteps)); _dialogs.Add(new WaterfallDialog("navigation", waterfallSteps2)); _dialogs.Add(new WaterfallDialog("YesNo", waterfallSteps3)); _dialogs.Add(new TextPrompt("B1")); _dialogs.Add(new TextPrompt("B2")); _dialogs.Add(new TextPrompt("B3")); _dialogs.Add(new TextPrompt("B4")); _dialogs.Add(new TextPrompt("YN1")); _dialogs.Add(new TextPrompt("N1")); }
/// <summary> /// This method gets called by the runtime. Use this method to add services to the container. /// </summary> /// <param name="services">The <see cref="IServiceCollection"/> specifies the contract for a collection of service descriptors.</param> /// <seealso cref="IStatePropertyAccessor{T}"/> /// <seealso cref="https://docs.microsoft.com/en-us/aspnet/web-api/overview/advanced/dependency-injection"/> /// <seealso cref="https://docs.microsoft.com/en-us/azure/bot-service/bot-service-manage-channels?view=azure-bot-service-4.0"/> public void ConfigureServices(IServiceCollection services) { services.AddMvc(); // create luis recognizer var luisApplication = new LuisApplication( Configuration["LuisAppId"], Configuration["LuisAPIKey"], Configuration["LuisAPIHostName"]); services.AddSingleton(new LuisRecognizer(luisApplication)); // Create the credential provider to be used with the Bot Framework Adapter. services.AddSingleton <ICredentialProvider, ConfigurationCredentialProvider>(); // Create the Bot Framework Adapter with error handling enabled. services.AddSingleton <IBotFrameworkHttpAdapter, AdapterWithErrorHandler>(); // Add Application Insights services into service collection services.AddApplicationInsightsTelemetry(); // Create the telemetry client. services.AddSingleton <IBotTelemetryClient, BotTelemetryClient>(); // Add telemetry initializer that will set the correlation context for all telemetry items. services.AddSingleton <ITelemetryInitializer, OperationCorrelationTelemetryInitializer>(); // Add telemetry initializer that sets the user ID and session ID (in addition to other bot-specific properties such as activity ID) services.AddSingleton <ITelemetryInitializer, TelemetryBotIdInitializer>(); // Create the telemetry middleware to initialize telemetry gathering //services.AddSingleton<TelemetryInitializerMiddleware>(); // Create the telemetry middleware (used by the telemetry initializer) to track conversation events services.AddSingleton <TelemetryLoggerMiddleware>(); // Create the storage we'll be using for User and Conversation state. (Memory is great for testing purposes.) services.AddSingleton <IStorage, MemoryStorage>(); //services.AddSingleton<IStorage, AzureBlobStorage>(); // Create the User state. (Used in this bot's Dialog implementation.) services.AddSingleton <UserState>(); // Create the Conversation state. (Used by the Dialog system itself.) services.AddSingleton <ConversationState>(); // The Dialog that will be run by the bot. //services.AddSingleton<ReservationDialog>(); // Memory Storage is for local bot debugging only. When the bot // is restarted, everything stored in memory will be gone. IStorage dataStore = new MemoryStorage(); //IStorage dataStore = new AzureBlobStorage(Configuration["BlobStorageConnection"], Configuration["BlobContainerName"]); var conversationState = new ConversationState(dataStore); services.AddSingleton(conversationState); var userState = new UserState(dataStore); services.AddSingleton(userState); //var personalityChatOptions = new PersonalityChatMiddlewareOptions( // respondOnlyIfChat: true, // scoreThreshold: 0.5F, // botPersona: PersonalityChatPersona.Humorous); //services.AddSingleton(new PersonalityChatMiddleware(personalityChatOptions)); services.AddTransient <IBot, EchoBot>(); // Create and register state accessors. // Accessors created here are passed into the IBot-derived class on every turn. services.AddSingleton(sp => { // We need to grab the conversationState we added on the options in the previous step var options = sp.GetRequiredService <IOptions <BotFrameworkOptions> >().Value; if (options == null) { throw new InvalidOperationException("BotFrameworkOptions must be configured prior to setting up the State Accessors"); } // Create the custom state accessor. // State accessors enable other components to read and write individual properties of state. var accessors = new EchoBotAccessors(conversationState, userState) { ConversationDialogState = conversationState.CreateProperty <DialogState>("DialogState"), UserDataState = conversationState.CreateProperty <UserData>("UserState"), }; return(accessors); }); // Add QnA Maker here }