Issues with Botfront Rasa App while deploying with docker - Rasa Open Source - Rasa Community Forum

Issues with Botfront Rasa App while deploying with docker

post by Jainil-Gosalia on Jul 7, 2021

I am having issues with running a rasa chatbot flask app in docker. I have used botfront script in index.html to make a flask app that will give a GUI for my rasa chatbot. The chatbot I am trying to implement right now is just the basic rasa init chatbot. I am facing some issues when running the docker-compose up command.

Goal

To run rasa flask app via docker.

Current Issue

The app server is shown as running, but it is not visible on the mentioned address.

Error

Starting rasa-chat-app … done
Starting rasa-chatbot-server … done
Attaching to rasa-chat-app, rasa-chatbot-server
rasa-chat-app | * Serving Flask app ‘app’ (lazy loading)
rasa-chat-app | * Environment: production
rasa-chat-app | WARNING: This is a development server. Do not use it in a production deployment.
rasa-chat-app | Use a production WSGI server instead.
rasa-chat-app | * Debug mode: on
rasa-chat-app | * Running on all addresses.
rasa-chat-app | * Running on http://172.18.0.3:8000/ (Press CTRL+C to quit)

Files

Docker-compose file

version: '2'  
services:   
  rasa-flask:  
    image: rasa-chatbot:latest  
    build:  
      context: .  
      dockerfile: Dockerfile  
    container_name: rasa-chat-app  
    volumes:  
      - .:/rasa_app  
    ports:  
      - 5000:5000  
    command: python3 app.py   
  rasa-server:  
    image: rasa/rasa:2.1.2-full  
    container_name: rasa-chatbot-server  
    volumes:  
      - .:/app  
    ports:  
      - 5005:5005  
    command: run -m models --enable-api --cors "*"

DockerFile

FROM tensorflow/tensorflow:2.2.0  
RUN mkdir -p /rasa_app  
WORKDIR /rasa_app  
COPY . /rasa_app  
RUN python -m pip install -U pip  
RUN pip3 install -r requirements.txt  
RUN python -m spacy download en  
RUN pip3 install --user rasa==2.1.2  
RUN pip3 install --user sanic==19.9.0

Flask App file

from flask import Flask  
from flask import render_template

# creates a Flask application, named app  
app = Flask(__name__, static_url_path='/static')

# a route to display our html page gotten from [react-chat-widget](https://github.com/mrbot-ai/rasa-webchat)  
@app.route("/")  
def index():  
    return render_template('index.html')

# run the application  
if __name__ == "__main__":  
    app.run(host="0.0.0.0", port="8000", debug=True)

HTML file

<!doctype html>
<html>
<head>
</head>
<body>
    <script>!(function () {
  let e = document.createElement("script"),
    t = document.head || document.getElementsByTagName("head")[0];
  (e.src =
    "https://cdn.jsdelivr.net/npm/rasa-webchat@1.0.0/lib/index.js"),
    // Replace 1.x.x with the version that you want
    (e.async = !0),
    (e.onload = () => {
      window.WebChat.default(
        {
          customData: { language: "en" },
          socketUrl: "http://localhost:5005",
          // add other props here
        },
        null
      );
    }),
    t.insertBefore(e, t.firstChild);
})();
</script>
</body>
</html>

post by Jainil-Gosalia on Sep 6, 2021

Hello all, I have since resolved this issue. It was a rasa webchat version issue. I changed

"https://cdn.jsdelivr.net/npm/rasa-webchat@1.0.0/lib/index.js"

in html file to

"https://cdn.jsdelivr.net/npm/rasa-webchat@0.11.2/lib/index.js"

and it works fine. Thank you for all the help!