How to send post request to rasa core server?

My versions are:

0.14.6—rasa_nlu 0.13.5 – rasa core 0.12.2 – rasa-core-sdk

I have built a weather chat bot and then trained it. I need to integrate it with a simple web app .i thought of using api’s and used “python -m rasa_core.run --enable_api -d models/dialogue -u models/nlu/default/weathernlu -o out.log --endpoints endpoints.yml”.

endpoints.yml file is: action_endpoint: url: “http://localhost:5055/webhook

Rasa Core server is up and running on http://localhost:5005

I want to test it with curl. by giving a '{“query”:‘hello"}’.How to do it? and more importantly what is the url of this core server that i need to give to the frontend guys so that they can do post and get requests??

Please let me know for any more info.

1 Like

Check this: https://www.rasa.com/docs/core/server/#operation/respond curl localhost:5005/conversations/default/respond ‘{“query”:“hello”}’

In your web app you could use axios: https://github.com/axios/axios axios.post(‘localhost:5005/conversations/default/respond’, JSON.stringify({ ‘query’: ‘hello’ })) .then(response => console.log(“fromRasa”, response)) .catch(error => console.error(‘err’, error));

1 Like

Thanks for the reply robert.

Apologies if I am doing a blinder here.Iam pretty new to this.

Please find below.

One more thing is I need to do POST request and am not seeing any available web server routes. How to add some??

Also, where should I mention the Rest Input ? I am not getting it.

Please let me know for any.

Try this: curl localhost:5005/conversations/default/respond ‘{“message”:“hello”}’

Maybe query changed to message. Iam using version 12.3 because updating don’t work ^^

No use.Same result.How to do it in rasa core 13.5??

My rasa.core server is:

I dont see any server wouters??How to add one??

I have changed to version 12.4 of RASA.Still Iam getting the following error.

My rasa_core.server shows like this:

Normal get calls of version and status are working fine.

image

I dont know where Iam doing wrong.

Please help me out.

Solved the issue. Gone through the documentation and found how to give RestInput.

Now iam able to get and give data though api’s.

Pls provide use the sample

@suryavamsi62 Can you provide a sample of your file ?

Hi, Sorry for late reply. Simply in the credentials file mention ‘rest’. With the latest version of rasa by default the rest api’s are activated.There is already a ‘rest’ written in the credentials file.

You can speak to the chat-bot through “http://localhost:5005/webhooks/rest/webhook”.

1 Like

I’ve the same problem. Could you help me with the solution you found already?

Pre-tests have been done, including run “rasa train/shell” successfully.

Then follow the doc you mentioned, I did run “rasa run”

After: curl -d ‘{“sender”: “Rasa”,“message”: “some query”}’ -X POST localhost:5005/webhooks/rest/webhook

I get an empty reply: []

The reply is not empty in “rasa shell”. What’s wrong here?

Thanks,

Hi, Currently I am using Rasa 1.3.X from git hub. In the credentials.yml simply mention “rest:”.

This will enable the rest channel.

When you first create the “rasa init” project, it will also create a credentials file with rest in it.

Check the rasa command prompt from where you have given Rasa run and actions rum. If there is an error, it will get displayed there.

Sometimes due to lack of stories, the bot may give back “action_listen”, which in turn is an empty response with sender id key. Check this scenario as well.

Thanks. After run

rasa run --enable-api -m models/***

It seems working. However, I’m confused here about 5005 port and 5055 port in endpoints.yml . 5005 alone seems working for both nlu (localhost:5005/model/parse) and action(localhost:5005/webhooks/rest/webhook). Then what the 5055 port for, when to use it?

Thanks,

You hit the 5005 port with the user message.Then depending on the intent, to perform the action, rasa nlu will hit the core server which will run in 5055(depending on what you specify in the endpoints file.).

Thanks for the explanation.

hi @suryavamsi62. Can you please give an example code snippet on how to do the following? Thanks in advance.

Hello,

i encouter the same issue. please how did you solve it. I run : rasa run --enable-api and I want to test if the API is working or no: I typed:

curl -XPOST localhost:5005/webhooks/rest/webhook ‘{“message”:“bonjour”}’

ERROR

Hit In postman -
http://localhost:5005/webhooks/rest/webhook with a POST request.
In the body -> raw -> select JSON , then write -
{
“sender”: “rasa”,
“message”: “hello how r u”
}

with python code -

data = { “sender”: "rasa, “message”: “Hello How r u”, }
data = json.dumps(data)
rasa_api_endpint = “http://localhost:5005/webhooks/rest/webhook
res = requests.post(url = rasa_api_endpint, data = data)\

2 Likes

@vi.kumar thanks for the exact answer which helps beginners to undertand. @All: Pzl enable api end point using command ‘rasa run --enable-api’ at your project directory before trying curl or postman commands.