/// <summary> /// Converse with the dialog system. /// </summary> /// <param name="dialogId">The dialog ID of the dialog to use.</param> /// <param name="input">The text input.</param> /// <param name="callback">The callback for receiving the responses.</param> /// <param name="conversation_id">The conversation ID to use, if 0 then a new conversation will be started.</param> /// <param name="client_id">The client ID of the user.</param> /// <returns>Returns true if the request was submitted to the back-end.</returns> public bool Converse(string dialogId, string input, OnConverse callback, int conversation_id = 0, int client_id = 0) { if (string.IsNullOrEmpty(dialogId)) { throw new ArgumentNullException("dialogId"); } if (string.IsNullOrEmpty(input)) { throw new ArgumentNullException("input"); } if (callback == null) { throw new ArgumentNullException("callback"); } RESTConnector connector = new RESTConnector(); connector.URL = "http://aiaas.pandorabots.com/talk/1409612821373/rosie?user_key=ce95ff63dbe2ece138f3ffec7695db2b"; if (connector == null) { return(false); } ConverseReq req = new ConverseReq(); req.Callback = callback; req.OnResponse = ConverseResp; req.Forms = new Dictionary <string, RESTConnector.Form>(); req.Forms["input"] = new RESTConnector.Form(input); return(connector.Send(req)); }
/// <summary> /// Converse with the dialog system. /// </summary> /// <param name="dialogId">The dialog ID of the dialog to use.</param> /// <param name="input">The text input.</param> /// <param name="callback">The callback for receiving the responses.</param> /// <param name="conversation_id">The conversation ID to use, if 0 then a new conversation will be started.</param> /// <param name="client_id">The client ID of the user.</param> /// <returns>Returns true if the request was submitted to the back-end.</returns> public bool Converse(string dialogId, string input, OnConverse callback, int conversation_id = 0, int client_id = 0) { if (string.IsNullOrEmpty(dialogId)) { throw new ArgumentNullException("dialogId"); } if (string.IsNullOrEmpty(input)) { throw new ArgumentNullException("input"); } if (callback == null) { throw new ArgumentNullException("callback"); } RESTConnector connector = RESTConnector.GetConnector(SERVICE_ID, "/v1/dialogs"); if (connector == null) { return(false); } ConverseReq req = new ConverseReq(); req.Function = "/" + dialogId + "/conversation"; req.Callback = callback; req.OnResponse = ConverseResp; req.Forms = new Dictionary <string, RESTConnector.Form>(); req.Forms["input"] = new RESTConnector.Form(input); if (conversation_id != 0) { req.Forms["conversation_id"] = new RESTConnector.Form(conversation_id); } if (client_id != 0) { req.Forms["client_id"] = new RESTConnector.Form(client_id); } return(connector.Send(req)); }