I am trying to connect my bot with a chat interface on a website using REST API. Before doing so I started testing the available web server routes. All the GET requests work prefectly fine, but I am getting errors when I try executing POST requests.
Additional Info - I have the bot running on a remote docker container. I used the image rasa/rasa:latest-spacy-en
$curl http://<server-ip>:<port>/webhooks/rest
{"status":"ok"}
$curl http://<server-ip>:<port>/
Hello from Rasa: 1.1.4
$curl http://<server-ip>:<port>/webhooks/rest/webhook -d '{"sender":"default","message":"Hello"}'
Error: Failed when parsing body as json
$curl http://<server-ip>:<port>/model/parse -d '{"text":"Hello"}'
{"version":"1.1.4","status":"failure","message":"An unexpected error occurred. Error: Failed when parsing body as json","reason":"ParsingError","details":{},"help":null,"code":500}
And I found this in the container logs
## Server side error message
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "/usr/local/lib/python3.6/site-packages/sanic/app.py", line 917, in handle_request
response = await response
File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 110, in __next__
return self.gen.send(None)
File "/usr/local/lib/python3.6/site-packages/rasa/core/channels/channel.py", line 433, in receive
sender_id = await self._extract_sender(request)
File "/usr/local/lib/python3.6/asyncio/coroutines.py", line 110, in __next__
return self.gen.send(None)
File "/usr/local/lib/python3.6/site-packages/rasa/core/channels/channel.py", line 393, in _extract_sender
return req.json.get("sender", None)
File "/usr/local/lib/python3.6/site-packages/sanic/request.py", line 143, in json
self.load_json()
File "/usr/local/lib/python3.6/site-packages/sanic/request.py", line 153, in load_json
raise InvalidUsage("Failed when parsing body as json")
sanic.exceptions.InvalidUsage: Failed when parsing body as json
Any suggestion on what I would be wrong? or am I missing any configurations?
Yes I did. I was using ārasa run -vv --enable-apiā. I changed this to ārasa run -m models --enable-api --cors ā*ā --debugā and it started working.
But I am unable to fetch the intents and entities while running the CURL .
Error: {āversionā:ā1.1.5ā,āstatusā:āfailureā,āmessageā:āAn unexpected error occurred. Error: Failed when parsing body as jsonā,āreasonā:āParsingErrorā,ādetailsā:{},āhelpā:null,ācodeā:500}
I think so we have discussed this in some other post, I havenāt worked yet on slack human agent-handoff yet but will soon do it.
Actually this UI was designed to handle bot response from Rasa but if you want to do something else you need to modify the UI script to handle those responses.