예제 #1
0
        // GET: Conversation
        public ActionResult Index()
        {
            //Initial call to the service for getting a conversationID and a conversation context
            WCInitialMessage  msg            = new WCInitialMessage("");
            WCMessageResponse watsonResponse = new WCMessageResponse();

            watsonResponse = WatsonConversationClient.ConverseWatsonInitial(msg);

            foreach (var text in watsonResponse.output.text)
            {
                ViewBag.wc_ResponseWelcome += text + "";
            }

            //Subsequent Watson Conversation calls
            string userInput = "Quiero reservar un vuelo"; //Read user input from UI

            //Assign userinput to the message object, and then pass it to watson client
            watsonResponse.input.text = userInput;
            watsonResponse            = WatsonConversationClient.ConverseWatson(watsonResponse);

            //Starting from the watson Response, do the necessary application logic from here to show the conversation on the UI
            foreach (var text in watsonResponse.output.text)
            {
                ViewBag.wc_Response += text + " ";
            }

            return(View());
        }
예제 #2
0
        public string Initialize()
        {
            var res = "";

            WCInitialMessage  msg            = new WCInitialMessage("");
            WCMessageResponse watsonResponse = new WCMessageResponse();

            watsonResponse            = WatsonConversationClient.ConverseWatsonInitial(msg);
            Session["watsonResponse"] = watsonResponse;

            foreach (var text in watsonResponse.output.text)
            {
                res += "<section class=\"post\"><header class=\"post-header-watson\">" +
                       "<img width = \"48\" height=\"48\" alt=\"img\" class=\"post-avatar-w\"" +
                       "src=\"/Content/img/avatar-watson.png\"><h2 class=\"post-title-watson\">@IBM Watson</h2>" +
                       "</header><div class=\"post-description-watson\">" + text +
                       "</div></section>";
            }

            return(res);
        }