/// <summary> /// This method is called when user has entered their message and hits the send button. /// It calls the <see cref="NetworkManager.PostRequest(string, string)"> coroutine to send /// the user message to the bot and also updates the UI with user message. /// </summary> public void SendMessageToRasa() { // get user messasge from input field, create a json object // from user message and then clear input field string message = botUI.inputField.text; botUI.inputField.text = ""; // if user message is not empty, send message to bot if (message != "") { // create json from message PostMessage postMessage = new PostMessage { sender = "user", message = message }; string jsonBody = JsonUtility.ToJson(postMessage); // update UI object with user message botUI.UpdateDisplay("user", message, "text"); // Create a post request with the data to send to Rasa server StartCoroutine(PostRequest(rasa_webhook_url, jsonBody)); } }
/// <summary> /// This method is called when user has entered their message and hits the send button. /// It calls the <see cref="NetworkManager.PostRequest(string, string)"> coroutine to send /// the user message to the bot and also updates the UI with user message. /// </summary> public void SendMessageToRasa() { // get user messasge from input field, create a json object // from user message and then clear input field string message = botUI.input.text; if (message == "") { return; } EventSystem.current.SetSelectedGameObject(botUI.input.gameObject, null); botUI.input.OnPointerClick(new PointerEventData(EventSystem.current)); botUI.input.text = ""; PostMessage postMessage = new PostMessage { //sender = jugador.GetComponent<SyncPlayerInfo>().getID(), sender = "*****@*****.**", message = message }; string jsonBody = JsonUtility.ToJson(postMessage); // update UI object with user message botUI.UpdateDisplay("user", message, "text"); // Dependiendo del rol se cambiaría el webhook int rolJugador = jugador.GetComponent <SyncPlayerInfo>().rol; Debug.Log("rol asignado: " + rolJugador); switch (rolJugador) { case PlayerInfo.ProductOwner: // Create a post request with the data to send to Rasa server StartCoroutine(PostRequest(rasa_url, jsonBody)); break; case PlayerInfo.ScrumMaster: // Create a post request with the data to send to Rasa server StartCoroutine(PostRequest(rasa_url, jsonBody)); break; case PlayerInfo.ScrumMember: // Create a post request with the data to send to Rasa server StartCoroutine(PostRequest(rasa_url, jsonBody)); break; } }