// GET: api/Bot/5 public string Get(string appId) { //var synBot = new SynBot(); //var botUser = synBot.CreateUser(); //var outPutDirectory = Path.GetDirectoryName(Assembly.GetExecutingAssembly().CodeBase); //var packageString = File.ReadAllText(Path.Combine(outPutDirectory, "DocBotPackage.simlpk")); //synBot.PackageManager.LoadFromString(packageString); //var chatRequest = new ChatRequest("how are you", botUser); //var chatResult = synBot.Chat(chatRequest); //var botMessage = chatResult.BotMessage; //if (chatResult.Success) // { // //Do Something // } try { if (string.IsNullOrEmpty(appId)) { return("Sorry Bot cannot identify user."); } string response = MessageResponse.Response("", "").Trim(); MessageTracker.WriteLastMessaage(appId, response); return(response); } catch (Exception ex) { return(ex.Message); } //return "Something went wrong while communicating with Bot!"; } }
// GET: api/Bot/5/userInput public string Get(string appId, string userInput) { try { if (string.IsNullOrEmpty(appId)) { return("Sorry Bot cannot identify user."); } if (string.IsNullOrEmpty(userInput)) { return("Please input some text for Bot to read."); } string LastMsg = MessageTracker.GetLastMessage(appId); string response = MessageResponse.Response(LastMsg, userInput).Trim(); MessageTracker.WriteLastMessaage(appId, response); return(response); } catch (Exception ex) { return(ex.Message); } //return "Something went wrong while communicating with Bot!"; } }