Search code examples
pythonsocket.iorasa-corerasa

Rasa Webchat Integration issue


Hey I'm new to Rasa so when I try to run my chatbot using the command

rasa run --credentials credentials.yml --cors null

the chatbot runs only when I open the HTML file using its path.

file:///C:/Users/ansel/PycharmProjects/rasabot/index.html

Hence I wanted to know if there is any way to run the HTML file on my localhost? When I enter http://localhost:5005 in my browser it gives me : Hello from Rasa: 1.8.1 and not the actual webpage

Also on the same note when I re-run the rasa chatbot is doesn't seem to clear my old conversation.....is there any way to change this??

My chatbot also doesn't seem to load any images.

This is the issue I face currently.

Here is the HTML code:

<!DOCTYPE html>
<html>
<head>
    <title>Rasa Chatbot</title>
</head>
<body>

<div id="webchat"/>
<script src="https://storage.googleapis.com/mrbot-cdn/webchat-latest.js"></script>
// Or you can replace latest with a specific version
<script>
  WebChat.default.init({
    selector: "#webchat",
    initPayload: "/hello",
    customData: {"language": "en"}, // arbitrary custom data. Stay minimal as this will be added to the socket
    socketUrl: "http://localhost:5005",
    socketPath: "/socket.io/",
    title: "Chatbot",
</script>

</body>
</html>

Any help would be greatly appreciated and I thank you in advance.


Solution

  • To access your Chatwidget through your localhost you need to create a local webserver. You can do so with e.g. npm lite-server.

    Localhost port 5005 is already in use by your rasa server. That's where the chatbot is running.

    "Hello from Rasa: 1.8.1" shows that the rasa server is working properly.


    I assume you've used botfronts rasa-webchat as your interface ?

    To delete your chathistory you have to implement something like this into the chatwidget:

    if(Websocket.CLOSED){
    localStorage.clear();
    //or 
    sessionStorage.clear();
    }
    

    You can find more information in the rasa-webchat ReadMe API Part.