Im trying to fill a website (chatbot widget) using FastAPI. I want the page to show me a first message automatically, then I type something, that text is sent via POST request to Rasa server. Then it should display the response back in frontend.
This is my index.html:
<html>
<div id="rasa-chat-widget" data-websocket-url="http://localhost:5005"></div>
<script src="https://unpkg.com/@rasahq/rasa-chat" type="application/javascript"></script>
</html>
This is some of my FastAPI code
@app.get("/", response_class=HTMLResponse)
def index():
path = "/path"
return HTMLResponse(content=pathlib.Path(path).read_text(), status_code=200)
@app.post("/parse")
def post_attempt(text: Text):
body = {"text": text.text,"message_id": str(uuid.uuid4())}
headers = {'content-type': 'application/json'}
url = "http://localhost:5005/webhooks/rest/webhook"
return requests.post(url, data=json.dumps(body), headers=headers)
However I get no reply from Rasa server on the frontend, I just see the chat widget when opening webpage and am able to type, but Rasa is not returning a response and showing on html page. What am I missing? thanks