Search code examples
dockerchatbotrasaweb-chat

I run rasa in docker containers but I can't get webchat working


I got my 5 rasa chatbots running in different docker containers but when I try use webchat it fails. I can run rasa with webchat in normal linux server.

I don't get error messages just no webchat chat window.

CORRECTION: This error I get
"Unable to correct
Firefox can't estabilish a connection to the server at localhost:5005"

Here is command I run

docker run --name=rasa1 --user 1000 -v $(pwd):/app rasa/rasa:1.10.11-full run -m models --enable-api --cors "*" --debug

Here is my environment:

Ubuntu 18.04
Docker 19.03.12

Solution

  • You did not expose any ports.

    Assuming rasa is listening on port 5005 inside the container, try:

    docker run --name=rasa1 --user 1000 -v $(pwd):/app -p "5005:5005" rasa/rasa:1.10.11-full run -m models --enable-api --cors "*" --debug
    

    Edit:

    I managed to make it run by trial and error. The steps are below:

    1. Init the project

          mkdir app
          docker run -it --rm --user 1000 -v $(pwd)/app:/app rasa/rasa:1.10.11-full init --no-prompt
      
    2. Edit $(pwd)/app/credentials.yml and add the following lines:

          socketio:
            user_message_evt: user_uttered
            bot_message_evt: bot_uttered
            session_persistence: true
      
    3. Start rasa:

          docker run --name=rasa1 --user 1000 -v $(pwd)/app/app:/app -p "5005:5005" rasa/rasa:1.10.11-full run -m models --enable-api --cors "*" --debug
      

    4.Create $(pwd)/index.html with the following contents:

        <html>
        <head>
            <title>Webchat</title>
        </head>
    
        <body>
            <div id="webchat"></div>
            <script src="https://cdn.jsdelivr.net/npm/rasa-webchat/lib/index.min.js"></script>
            // you can add a version tag if you need, e.g for version 0.11.5
            https://cdn.jsdelivr.net/npm/rasa-webchat@0.11.5/lib/index.min.js
            <script>
                WebChat.default.init({
                    selector: "#webchat",
                    initPayload: "/get_started",
                    customData: { "language": "en" }, // arbitrary custom data. Stay minimal as this will be added to the socket
                    socketUrl: "http://localhost:5005",
                    socketPath: "/socket.io/",
                    embedded: true,
                    title: "Welcome",
                    subtitle: "to my chatbot",
                    params: { "storage": "session" } // can be set to "local"  or "session". details in storage section.
                })
            </script>
        </body>
        </html>
    
    1. Open $(pwd)/index.html in your browser.
    2. Enjoy!