Example #1
0
        public EmptyBot(CapitaAccessor capitaAccessor)
        {
            var dialogState = capitaAccessor.DialogStateAccessor;

            dialogs = new DialogSet(dialogState);
            dialogs.Add(MainDialog.Instance);
            dialogs.Add(ServiceRequestDialog.Instance);
            dialogs.Add(IncidenceDialog.Instance);
            dialogs.Add(TroubleshootDialogue.Instance);
            dialogs.Add(new ChoicePrompt("choicePrompt"));

            CapitaAccessor = capitaAccessor;
        }
Example #2
0
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_1);

            // Create the credential provider to be used with the Bot Framework Adapter.
            services.AddSingleton <ICredentialProvider, ConfigurationCredentialProvider>();

            // Create the Bot Framework Adapter.
            services.AddSingleton <IBotFrameworkHttpAdapter, BotFrameworkHttpAdapter>();



            services.AddBot <EmptyBot>(options =>
            {
                var conversationState = new ConversationState(new MemoryStorage());
                options.State.Add(conversationState);

                options.CredentialProvider = new ConfigurationCredentialProvider(Configuration);
            });
            services.AddSingleton(serviceProvider =>
            {
                var options           = serviceProvider.GetRequiredService <IOptions <BotFrameworkOptions> >().Value;
                var conversationState = options.State.OfType <ConversationState>().FirstOrDefault();

                var accessors = new CapitaAccessor(conversationState)
                {
                    DialogStateAccessor      = conversationState.CreateProperty <DialogState>(CapitaAccessor.DialogStateAccessorName),
                    CapitaStateStateAccessor = conversationState.CreateProperty <State>(CapitaAccessor.CapitaStateAccessorName)
                };

                return(accessors);
            });
            //
            // Create the bot as a transient. In this case the ASP Controller is expecting an IBot.
            services.AddTransient <IBot, EmptyBot>();
        }