frontend/static/js/script.js
//============== send the user message to rasa server =============================================
send the user message to rasa server
send the user message to rasa server
function send(message) {
	var url = "https://inf.u-szeged.hu/algmi/chatbot/";
	$.ajax({
		url: url + "/rasa/webhooks/rest/webhook",
		type: "POST",
		contentType: "application/json",
		data: JSON.stringify({ message: message, sender: user_id }),
		success: function (botResponse, status) {
			console.log("Response from Rasa: ", botResponse, "\nStatus: ", status);
			if (message.toLowerCase() == '/restart') {
				$("#userInput").prop('disabled', false);
				action_trigger();
				return;
			}
			setBotResponse(botResponse);
		},
		error: function (xhr, textStatus, errorThrown) {
			if (message.toLowerCase() == '/restart') {
			}
			setBotResponse("");
			console.log("Error from bot end: ", textStatus);
		}
	});
}
function send ( message ) { var url = "https://inf.u-szeged.hu/algmi/chatbot/" ; $ . ajax ( { url : url + "/rasa/webhooks/rest/webhook" , type : "POST" , contentType : "application/json" , data : JSON . stringify ( { message : message , sender : user_id } ) , success : function ( botResponse , status ) { console . log ( "Response from Rasa: " , botResponse , "\nStatus: " , status ) ; if ( message . toLowerCase ( ) == '/restart' ) { $ ( "#userInput" ) . prop ( 'disabled' , false ) ; action_trigger ( ) ; return ; } setBotResponse ( botResponse ) ; } , error : function ( xhr , textStatus , errorThrown ) { if ( message . toLowerCase ( ) == '/restart' ) { } setBotResponse ( "" ) ; console . log ( "Error from bot end: " , textStatus ) ; } } ) ; }
send the user message to rasa server
send the user message to rasa server
//var url = //document.location.protocol + "//" + document.location.hostname + ":" + PORT; // if user wants to restart the chat and clear the existing chat contents //if you want the bot to start the conversation after restart // $("#userInput").prop('disabled', false); //if you want the bot to start the conversation after the restart action. // action_trigger(); // return; //console.log("url =" + document.location.protocol + " asd " + document.location.hostname); // if there is no response from rasa server