Unable to connect Rasa chatbot to Flask environment because I keep getting a 404 error and the bot is stuck saying "waiting for server"

i’m basically trying to create a chat bot using Rasa and implement it using Flask or at least find any method to implement the chatbot to my site permanently. I need help desperately and am starting to give up on using Rasa at this point. I’ve spent too many hours trying to simply deploy the chatbot onto my site. Currently all i’m trying to do is implement Rasa onto localhost:5000. I’m using websockets to connect with Flask but have been able to basically make no progress. Here’s my html template

<!doctype html>
    <div id="webchat">
      <script src="https://storage.googleapis.com/mrbot-cdn/webchat-0.5.8.js"></script>
          selector: "#webchat",
          initPayload: "/get_started",
          interval: 1000, // 1000 ms between each message
          socketUrl: "http://localhost:5000",
          socketPath: "/socket.io/",
          title: "SIA",
          inputTextFieldHint: "Type a message...",
          connectingText: "Waiting for server...",
          hideWhenNotConnected: false,
          fullScreenMode: true,
          profileAvatar: "/static/bot.png",
          openLauncherImage: 'myCustomOpenImage.png',
          closeLauncherImage: 'myCustomCloseImage.png',
          params: {
            images: {
              dims: {
                width: 300,
                height: 200,
            storage: "session"

here’s my server.py file which connects to the websocket

    from rasa_core.channels import SocketIOInput
from rasa_core.agent import Agent
from rasa_core.interpreter import RegexInterpreter
from rasa_core.interpreter import RasaNLUInterpreter
from rasa_core.utils import EndpointConfig
from rasa_core.policies import KerasPolicy, MemoizationPolicy

# load your trained agent
interpreter = RasaNLUInterpreter('./models/nlu/profiler/nlu')
agent = Agent.load('./models/dialogue',
    #for action endpoint

input_channel = SocketIOInput(
    # event name for messages sent from the user
    # event name for messages sent from the bot
    # socket.io namespace to use for the messages

# set serve_forever=True if you want to keep the server running
s = agent.handle_channels([input_channel], 5000, serve_forever=False)

finally here’s my app.py files which uses Flask

    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)
def index():
    return render_template('index.html')

# run the application
if __name__ == "__main__":

This is the error I receive with inspect element on my web page is

"webchat-0.5.8.js:33 GET http://localhost:5000/socket.io/?EIO=3&transport=polling&t=M-bhVfa 404 (NOT FOUND)"

If anyone can help me that would be greatly appreciated. I may be missing details that can help answer this question so if anyone needs extra info I’ll provide immediately.

One extra detail I forgot to add was my version of Flask is 1.1.1, my version of Rasa is 1.6.0, my version of rasa-nlu is 0.15. and my version of rasa-core is 0.14.5

Hey @CanadianBeaver, have you tried configuring the WebSocket channel using the credentials.yml file, instead of creating your own server.py file? I believe that should do the trick, check this link: Your Own Website

Hello, sorry for the late response. I am trying to integrate a Rasa chatbot onto my own website without having to type into the command line "Rasa Run --enable-api --cors “*”. I’m starting to realize where I was going wrong last week. I’m not the most experienced with server configuration and this is where I think is where I’m running into issues. I want to be able to just type into the command line “Flask run” and have my site working with the rasa chatbot, is this not possible?

I’m open to any methods with trying to connect the chatbot to my site. I’ve had no issues with the frontend of the chatbot but the backend is where i’m struggling greatly.

Apologies for the third message. So awhile ago I got rid of the server.py file and just used the socket.io channel settings in the credential.yml file. This can obviously work but I need to type "rasa run --enable-api --cors “*” " into the terminal and then “Flask run” into another terminal. I can talk to the chatbot this method but me and my team have created our GUI using the flask framework so I need to learn how to configure this rasa server with our separate flask server. I will work on this and ask for any solutions if I run into issues.

No problem! Hope it works out.

Hi @CanadianBeaver , were you able to automate the process of running the command - rasa run --enable-api ?