Hello, our team is currently working on a chatbot web application and we previously got Rasa’s API to successfully receive user messages and respond back. However, the API communication was only successful as long the project was ran on localhost. Our team is now trying to implement the service on one of the subdomains of the organization in order to make it accessible to some people for testing purposes. I successfully set up the nginx web server on the Ubuntu VM and got the website (UI) running on the subdomain; however, the API communication is not properly set up and the response from rasa is an empty array. (Pay attention, that apparently it detects the connection as successful, however, the response is just empty. Take a look at the if-else condition down below for better understanding of the error-management of Rasa) There are 3 sections in the .js files in which API calls are taking place: 1:
function actionTrigger() {
$.ajax({
url: `http://XXXX.XX.XXXX.edu:5005/conversations/${sender_id}/execute`,
type: "POST",
contentType: "application/json",
data: JSON.stringify({
name: action_name,
policy: "MappingPolicy",
confidence: "0.98",
}),
success(botResponse, status) {
console.log("Response from Rasa: ", botResponse, "\nStatus: ", status);
if (Object.hasOwnProperty.call(botResponse, "messages")) {
setBotResponse(botResponse.messages);
}
$("#user-input").prop("disabled", false);
},
error(xhr, textStatus) {
// if there is no response from rasa server
setBotResponse("");
console.log("Error from bot end: ", textStatus);
$("#user-input").prop("disabled", false);
},
});
}
2:
function customActionTrigger() {
$.ajax({
url: "http://XXXX.XX.XXXX.edu:5005/webhooks/rest/webhook",
type: "POST",
contentType: "application/json",
data: JSON.stringify({
next_action: action_name,
tracker: {
sender_id,
},
}),
success(botResponse, status) {
console.log("Response from Rasa: ", botResponse, "\nStatus: ", status);
if (Object.hasOwnProperty.call(botResponse, "responses")) {
setBotResponse(botResponse.responses);
}
$("#user-input").prop("disabled", false);
},
error(xhr, textStatus) {
// if there is no response from rasa server
setBotResponse("");
console.log("Error from bot end: ", textStatus);
$("#user-input").prop("disabled", false);
},
});
}
The previous 2 sections are inside the file chats.js The following part is inside of constants.js 3:
const rasa_server_url = "http://XXXX.XX.XXXX.edu:5005/webhooks/rest/webhook";
And about the web server, here’s the configuration related to nginx located at /etc/nginx/sites-enabled/project-name
:
server {
listen 80;
listen [::]:80;
server_name XXXX.XX.XXXX.edu;
root /var/www/project-name;
index index.html;
location / {
try_files $uri $uri/ =404;
}
location /api {
proxy_pass http://localhost:5005;
add_header 'Access-Control-Allow-Origin' '*';
add_header 'Access-Control-Allow-Methods' 'GET, POST, OPTIONS';
add_header 'Access-Control-Allow-Headers' 'DNT,User-Agent,X-Requested-With,If-Modified-Since,Cache-Control,Content-Type,Range';
add_header 'Access-Control-Expose-Headers' 'Content-Length,Content-Range';
}
}
When I analyze the network connection in developer tools, this is what I get: rasaDevScreenshot.pdf (61.2 KB)
And I can confirm that this has nothing to do with the actions.py configs since the model is supposed to be running to a certain point before needing resources from actions.py to crash. Please let me know if there is something else I could provide you with to get a better understanding of the situation. Thank you in advance for your time.
Additional information:
1: I use rasa run -m models --enable-api --cors "*" --debug
to get the API running
2: I get the welcome message from rasa when visiting XXXX.XX.XXXX.edu:5005 in my browser.
3: There are no firewall configurations for now on the VM.
Let me know if you need any other information that I could provide you with.