private static void Main() { var bot = new OscovaBot(); bot.Dialogs.Add(new TestDialog()); bot.Trainer.StartTraining(); var botServer = new WebApiChannel <OscovaBot>(bot, "http://localhost:8086/bot"); //In case the server generates a log, write it to console. botServer.Logger.LogReceived += (sender, eventArgs) => { Console.WriteLine(eventArgs.Log); }; botServer.Start(); //Once the server is started you can call API url using the below format. //http://localhost:8086/bot?userid={USER-ID}&query={USER-MESSAGE} //Example: http://localhost:8086/bot?userid=12345&query=test Console.WriteLine($"Bot Server is online at '{botServer.Url}'. Press any key to stop server."); Console.ReadLine(); botServer.Stop(); }
private static void Main() { try { OscovaBot.Logger.LogLevelThreshold = LogLevel.Info; var telegramChannel = new TelegramChannel <OscovaBot>("TELEGRAM_BOT_TOKEN", OscovaBot.Instance); WebApiChannel = new WebApiChannel <OscovaBot>(OscovaBot.Instance, "HOST_ADDRESS"); Action <LogReceivedEventArgs> logAction = receivedEventArgs => { File.AppendAllText(LogFilePath, receivedEventArgs.Log.ToString() + Environment.NewLine); Console.WriteLine(receivedEventArgs.Log); }; Logger.LogReceived += (sender, receivedEventArgs) => { logAction.Invoke(receivedEventArgs); }; telegramChannel.Logger.LogReceived += (sender, args) => { logAction.Invoke(args); }; WebApiChannel.Logger.LogReceived += (sender, args) => { logAction.Invoke(args); }; LogEvent("Start Saga Bot"); Logger.Info("Initializing Saga Bot..."); Bot.Configuration.RequiredRecognizersOnly = true; Bot.Configuration.RemoveContextOnFallback = false; Bot.Configuration.ContextLifespan = 1; Bot.Configuration.Scoring.MinimumScore = 0.4; Bot.Users.UserAdded += (sender, userAddedEventArgs) => { LogEvent($"USER {userAddedEventArgs.User.ID}"); }; EntitiesCreator.Initialize(); DialogCreator.Initialize(); //Load Word Vectors //Logger.Info("Loading word vectors..."); //Saga.Language.WordVectors.Load(@"D:\Word Vectors\FastText\wiki-en.vec", VectorDataFormat.Text); //Saga.Language.WordVectors.Load(@"D:\pizzabot-wordvectors.vec", VectorDataFormat.Text); Bot.Language.WordVectors.Logger.LogReceived += (sender, logReceivedEventArgs) => { Logger.Log(logReceivedEventArgs.Log); }; Bot.Trainer.StartTraining(); //Save optimized Word Vectors //var optimizedWordVector = Bot.Language.WordVectors.Optimize(Saga); //optimizedWordVector.Save(@"/*D:\pizzabot-wordvectors.vec*/", VectorDataFormat.Text); //Logger.Info("Saved optimized Word Vectors."); telegramChannel.Start(); WebApiChannel.Start(); Console.WriteLine("Press any key to stop Saga bot server."); Console.ReadLine(); telegramChannel.Stop(); Logger.Info("Telegram channel stopped."); WebApiChannel.Stop(); Logger.Info("Web API channel stopped."); } catch (Exception e) { Console.WriteLine(e); Console.ReadLine(); } }