protected void Page_Load(object sender, EventArgs e) { Sys.Tool.dialogflow df = new Sys.Tool.dialogflow(); string data = df.Query("Does ISS NUS conduct post graduate programmes?"); //what is the weather in tokyo Response.Write(data); }
//public static string GetFormattedResponseText(string ResponseText) //{ // string Name = "Ada"; // return "<script>$('ul.chat-ul').prepend('<li class=\"clearfix\"><div class=\"message -data align-right\" ><span class=\"message -data-name\" >" + Name + "</span> <i class=\"fa fa-circle me\"></i></div><div class=\"message me-message float-right\">" + ResponseText + "</div></li>');</script; //} public static string ProcessQuery() { string RequestString = ""; if (Page.Request.InputStream != null) { using (StreamReader reader = new StreamReader(Page.Request.InputStream, Encoding.UTF8)) { RequestString = reader.ReadToEnd(); } //Skip if just page loading for this first time if (RequestString == "") { return(""); } //skip processing welcome command if (RequestString == constWelcome) { return(Data.GetWelcomeMessage()); } string ResponseText = GetStandardResponseAboutBot(RequestString); if (ResponseText != "") { return(ResponseText); } if (Data.IsTextWithProfanity(RequestString)) { User.Emotion = User.EnumEmotion.Angry; return(Data.GetProfanityResponse()); } //update user object based on inputs, eg user name, user feed back etc. UpdateUserData(RequestString); if (RequestString.Trim() != "") { string data = ""; //data = "chad:" + RequestString; Sys.Tool.dialogflow DialogFlow = new Sys.Tool.dialogflow(); data = DialogFlow.Query(RequestString); //Add user name if it is provided. if (User.Name.Trim() != "") { data = User.Name + ", " + data; } return(data); } } return(""); }
//public static string GetFormattedResponseText(string ResponseText) //{ // string Name = "Ada"; // return "<script>$('ul.chat-ul').prepend('<li class=\"clearfix\"><div class=\"message -data align-right\" ><span class=\"message -data-name\" >" + Name + "</span> <i class=\"fa fa-circle me\"></i></div><div class=\"message me-message float-right\">" + ResponseText + "</div></li>');</script; //} public static string ProcessQuery() { string RequestString = ""; if (Page.Request.InputStream != null) { using (StreamReader reader = new StreamReader(Page.Request.InputStream, Encoding.UTF8)) { RequestString = reader.ReadToEnd(); } //Skip if just page loading for this first time if (RequestString == "") { return(""); } //skip processing welcome command if (RequestString == constWelcome) { return(Data.GetWelcomeMessage()); } string ResponseText = GetStandardResponseAboutBot(RequestString); if (ResponseText != "") { return(ResponseText); } if (Data.IsTextWithProfanity(RequestString)) { User.Emotion = User.EnumEmotion.Angry; return(Data.GetProfanityResponse()); } //update user object based on inputs, eg user name, user feed back etc. UpdateUserData(RequestString); if (RequestString.Trim() != "") { string data = ""; //data = "chad:" + RequestString; Sys.Tool.dialogflow DialogFlow = new Sys.Tool.dialogflow(); data = DialogFlow.Query(RequestString); //Add user name if it is provided. if (User.Name.Trim() != "") { data = User.Name + ", " + data; } User.CurrentContext.LastQueryText = RequestString; User.CurrentContext.Action = DialogFlow.Response.Data.QueryResult.Parameters.Action; User.CurrentContext.InquiryType = DialogFlow.Response.Data.QueryResult.Parameters.Inquirytype; User.CurrentContext.Location = DialogFlow.Response.Data.QueryResult.Parameters.Location; User.CurrentContext.Subject = DialogFlow.Response.Data.QueryResult.Parameters.Subject; User.CurrentContext.IntentDisplayName = DialogFlow.Response.Data.QueryResult.Intent.DisplayName; User.Store(); //Save for later return(AddConversationalResponseTag(data, DialogFlow.Response.Data.QueryResult.QueryText)); } } return(""); }