RASA X HTTP API Implementation for BOT builder UI

Hello Everyone,

I m trying to build an react based UI, to fetch conversations, domain, stories, nlu training data using https://rasa.com/docs/rasa-x/api/rasa-x-http-api/. I have successfully completed to fetch the bearerAuth and fetch the messages deployed on GCP. i have successfully update the NLU data using POST and PUT method and also was able to fetch the chatTokens etc.

My issue is i m trying to update the stories, domain and actions data using POST or PUT using https://rasa.com/docs/rasa-x/api/rasa-x-http-api/#operation/uploadStories but all i get is an empty array and nothing is updated. When i try doing this using PUT, the entire stories is removed and an empty array is uploaded.

Below are the screenshot from POSTMAN :slight_smile:

Get the stories in JSON format, working perfect:

Get the strories in MD format, working perfect:

But when i try to POST a new story, it returns an empty array and nothing is updated:

Similar responses i get while updating domain and actions. With actions i don’t mean code of actions.py.

Please help @erohmensing @wabi @KarthiAru @akelad

Hi Athenasaurav,

Thanks for including those screenshots.

The problem is that the stories need to be passed as data instead of in the body of the message. In postman choose binary and select a markdown file instead of using raw.

I have some Typescript code you can also use as an example in this repo. My rasacli project has a bunch of other example api calls.

Greg

Even I’m working on something similar. Were you able to fix the issue?

Thank You @stephens for your response. Yes it solved the issue.

As mentioned by @stephens The stories need to be passed as text binary and .md format rather than in Json format. I also figured it out yesterday. rest are mostly passed in json format. All the HTTP API are also working perfectly for me.

Were you able to create reactu UI for managing rasa model? Would you be able to share the soultion/code if possible.

We are working on it. Till now we are getting all responses from curl request in postman and have implemented a voximplant single chatbot. Will share a video tutorial soon and share it as rasa contribution.

can someone help me in using RASA X HTTP API locally??? i am not able to use apis mentioned

https://rasa.com/docs/rasa-x/api/rasa-x-http-api/#tag/Conversations

hey can i test these RASA X API locally??? I tried hitting conversations endpoint but not able to use it.

If you are testing this locally you are on the wrong link.

First you need to two command prompt in your project directory.

  1. rasa run actions
  2. rasa run -m models --enable-api --cors “*” --debug

In the 2nd window you can see all the prediction, actions, intent and msg when you talk to rasa bot in rasa x or from postman.

Endpoint : http://localhost:port/webhooks/rest/webhook.

2nd window will also all GET, POST, PUT, DELETE commands available. You can also find them here HTTP API.

hi @athenasaurav ! how’s your project progressing? I am curious to know, what is missing from Rasa X that you would like to build into this project?

Hi @amn41. Project is going good. We have build an Bot builder UI and have been able to create parallel VM instance to deploy bot over cloud. We are passing nlu, stories and domain from UI server to individual bot server. Currently the issue we are facing are creating credentials files and custom actions as there is no way to create Then using RASA X HTTP API. Also i have been facing a lot of issue with integration also with platform like slack, telegram etc. I believe a better tutorial is expected from rasa for them and some documentation if creating custom action server using RASA X HTTP API. We are connected already on LinkedIn, i will send a greetings message there, so that we can be connected. Thanks for your follow ups.

Vishal,

First you the call to login to Rasa X. Here’s an example with curl (replace the URL and password with your values)

curl --location --request POST 'http://localhost/api/auth' --data-raw '{"username": "me", "password": "mypassword" }'

Here’s example post of an utterance:

curl --location --request POST 'http://localhost/api/chat?environment=production' --data-raw '{"sender":"postman", "message":"hi there"}'

However, for conversations, you can typically post to the Rasa server directly using the REST or WebSocket channel.

curl --location --request POST 'http://localhost:5005/webhooks/rest/webhook'  --data-raw '{
  "sender_id": "postman",
  "message": "hi there",
}'

Hey stephens, one quick question. I have Rasa-X on gcp deployed with docker-compose quick install. When trying to post to rasa-x with postman at [IP]:5005//webhooks/rest/webhook, I don’t get any response, while when I remove the port I get a URL not found.

Any idea if such a thing is possible, in order to ditch the authentication? I have a working version already with /api/auth and /api/chat but was wondering if this can happen too.

Thanks in advance.

If you do a docker-compose ps you should see the nginx container is running that it has port 80 mapped to 8080. The API calls are routed via nginx to the API endpoint in rasa-production so you should be using port 80.

Is the rest interface enabled in your credentials.yml:

rest:
1 Like

Thanks Greg!

On my local machine I have it in credentials.yml but on Rasa-x Server I have just this

rasa:

url: ${RASA_X_HOST}/api

Hey @ktoulgaridis you can find which api work on GCP here HTTP API

I m not sure /webhooks/rest/webhook is there.

I m also searching for same but couldnt find.

This will be easy for custom integration to messaging platforms.

Try what Greg suggests it worked for me. In your instance go to /etc/rasa & edit the credentials.yml. In there by default, you will find

rasa: 
  url: ${RASA_X_HOST}/api 

simply add at the bottom

rest: 

then you can access the rest by contacting port 80 on your VM like this

http://[IP]:80/webhooks/rest/webhook
2 Likes

thanks @ktoulgaridis @stephens, this worked for me too. Right away.

Hey @stephens @athenasaurav,I am running my rasa x on my local server and was looking to train my model using the http api.Can you help me out here as in the rasa x http api docs its mentioned some project_id that i have to pass which i am not able to find.