Serving Multiple Bots from Django Backend - Rasa Open Source - Rasa Community Forum

Serving Multiple Bots from Django Backend

post by raymond on Aug 21, 2018

Hey guys,

I’m currently trying to serve multiple bots (running different models) and to allow users to interact with it on a website. I’ve had a look at the following:

but I’m still having trouble figuring out how it can be done.

Some of the solutions I’ve considered are either:

  1. Serve the bot on an HTTP server and have my website interact with the Rasa HTTP server.
  2. Create the website on Django Framework or REST API, and run Rasa Core and NLU on the backend.

Which of these would you recommend? Are there better alternatives? And, could anyone please briefly explain how this can be done (with multiple bot models and instances running)?

Any help would be greatly appreciated!


post by raymond on Aug 22, 2018

After a bit more digging around, I’ve decided to go with the Django backend. Looks like it should be able to handle running the bots as well as connecting them to a web page.


post by adrianhumphrey111 on Aug 22, 2018

Hello Raymond,

I have implemented this using Flask. What I did was create my own server and not using the Rasa HTTP server. My server has an initiateConversation endpoint where I create a unique ID. I have another endpoint that takes that id and a message. I then take that id and message and simply call:

agent = Agent.load()  # Whatever model you want to load
agent.send_message(text_message=message, sender_id=unique_id)

This will allow you to create one agent instance of a model, have multiple conversations.

Regarding having more than one model, simply instantiate more than one agent that loads different models:

agent1 = Agent.load(model1, interpreter1)
agent2 = Agent.load(model2, interpreter2)

Then have your endpoints figure out which agent should handle the message and which conversation it is on. Hope this helps.


post by raymond on Aug 23, 2018

Thanks for the reply! I’m starting to work on something similar using Django (chose Django instead of Flask mainly for the ORM database support). For anyone else searching, these answers here give an idea of how it can work:


post by raymond on Aug 25, 2018

Hey @adrianhumphrey111, just a question regarding Flask, is it able to handle multiple requests to multiple agents simultaneously? Just wondering as now I’m considering switching to Flask, Django is a bit bulky and doesn’t seem to be able to handle multiple clients simultaneously.


post by adrianhumphrey111 on Aug 26, 2018

What I did was create a simple server running that takes all requests through port 5000. This can run on your local host, in the cloud, or wherever you want to run the server. In the server file, I instantiated an agent instance:

agent = Agent.load()

Then I declared all of my app routes for Flask. So every time you run:

python app.py

And start your server, you will create an agent instance loaded from your NLU model and your dialogue model. I then have a route on my server that takes GET requests with the params:

{ message: "Hello my name is Adrian", sender_id: "alijf9424nn349348394394n" }

Where the sender_id is a unique string. I returned the message by:

return agent.handle_message(text_message=message, sender_id=sender_id)[0]

What this does is send that message to your agent, but by sending it a unique string for the sender_id, it will in essence create a new conversation for that sender Id, that you do not have to manage, just send that message for that sender id, and make sure whoever is sending the message has access to the sender_id to pass it in a param. Hope that helps.


post by raymond on Jan 1, 2019

Hmm I’m not familiar with Django-Rasa-Bot, but from that screenshot it looks like the client isn’t connecting to the server. Have you checked that the Django server and bot are both running properly? Does anything come up in your browser console when you press F12?


post by raymond on May 1, 2020

Hi @samwell,

Its working out quite well in a production environment so far, but still requires testing under load.

I ended up using Flask as opposed to Django which I initially posted about just because its simpler, so that’s what I would recommend. Works fine with multiple bots, as long as you’ve got the processing power/memory.

The trickiest part for my team was setting up the production environment, but that issue isn’t so much related to Flask/Rasa. Flask and Rasa seems to work together quite smoothly in my experience.