public TestBot(TestBotAccessors accessors)
        {
            // create the DialogSet from accessor
            rootDialog = CognitiveLoader.Load <IDialog>(File.ReadAllText(accessors.RootDialogFile));

            _dialogs = new DialogSet(accessors.ConversationDialogState);
            _dialogs.Add(rootDialog);
        }
        // This method gets called by the runtime. Use this method to add services to the container.
        public void ConfigureServices(IServiceCollection services)
        {
            IStorage dataStore         = new MemoryStorage();
            var      conversationState = new ConversationState(dataStore);
            var      userState         = new UserState(dataStore);
            var      userStateMap      = userState.CreateProperty <StateMap>("user");

            // Get Bot file
            string rootDialog = string.Empty;
            var    botFile    = Configuration.GetSection("bot").Get <BotFile>();
            var    botProject = BotProject.Load(botFile);

            rootDialog = botProject.entry;

            var accessors = new TestBotAccessors
            {
                ConversationDialogState = conversationState.CreateProperty <DialogState>("DialogState"),
                ConversationState       = conversationState,
                RootDialogFile          = botProject.path + rootDialog
            };

            services.AddBot <IBot>(
                (IServiceProvider sp) =>
            {
                return(new TestBot(accessors));
            },
                (BotFrameworkOptions options) =>
            {
                options.OnTurnError = async(turnContext, exception) =>
                {
                    await conversationState.ClearStateAsync(turnContext);
                    await conversationState.SaveChangesAsync(turnContext);
                };
                options.Middleware.Add(new AutoSaveStateMiddleware(conversationState));
            });
        }
 public TestBotLG(TestBotAccessors accessors)
 {
     lgFile = LGParser.ParseFile(GetLGResourceFile("8.LG"));
 }
Exemple #4
0
 public TestBotLG(TestBotAccessors accessors)
 {
     // load LG file into engine
     engine = new TemplateEngine().AddFile(GetLGResourceFile("8.LG"));
 }
 public TestBotLG(TestBotAccessors accessors)
 {
     lgFile = Templates.ParseFile(GetLGResourceFile("8.LG"));
 }