-1

I have successfully deployed a Rasa server on an AWS Ubuntu server, and it works great in the terminal, but I can't access from a POST via fetch().

I run this command:

rasa run --enable-api --cors *.*

and it responds:

Starting Rasa server on http://localhost:5005
Rasa Sever is up and running.

It responds in the browser (i.e. xxx.xxx.xxx:5005) with "Hello from Rasa: 2.8.3", so it's connected, but when I try to POST to if via fetch() it gives me a CORS error:

const url = 'http://xxx.xxx.xxx.xxx:5005/model/parse';
fetch(url, { method: 'POST',
     body: "{text:'Hello'}"})
    .then(res => { console.log(res); res.json()})
    .then(res => console.log(res))
Bill Ferster
  • 347
  • 1
  • 5
  • 17

2 Answers2

0

The url you added in your code is incorrect if you want a response.

const url = "HTTP://ip:5005/webhooks/rest/webhook";
fetch(url, { method: "POST",
body: "{sender: 'me', message: 'Hi'}"
})

If you still have any doubts feel free to ask.

  • Thanks, but I'm looking to get the intents/entities of a message, not the response. I think I need to point at model/parse but for some reason it give me a CORS error. – Bill Ferster Aug 28 '21 at 19:18
  • try just running nlu server then. it will just run and provide you just that. https://rasa.com/docs/rasa/2.6.x/nlu-only-server – Dishant Gandhi Sep 01 '21 at 17:13
-1

I was able to solve it with this:

let xhttp = new XMLHttpRequest();
xhttp.onreadystatechange = function() {
        if (this.readyState == 4 && this.status == 200) {
            console.log(this.response);
            } 
        }
xhttp.open(POST, http://xxx.xxx.xxx:5005/model/parse);
http.setRequestHeader(Content-Type, application/json);
xhttp.send(JSON.stringify({text:msg}));
Bill Ferster
  • 347
  • 1
  • 5
  • 17