Multiple users use chat bot at a time

Chat bot is handling only 1 request at a time, How will multiple users use chat bot at a time? User can’t wait for the chat bot server to be free. Chat bot should use parallel execution concept.

How can i implement parallel execution concept in rasa action server for multiple users?

@erohmensing @akelad @JulianGerhard

Any help would be greatly appreciated.

1 Like

Parallel execution is defined in the Rasa server agent by default. You can test this out by running your Rasa instance in server mode (rasa run) and using a REST client such as Postman to send it messages as JSON objects, like so:

{
	"sender": "Sender",
	"message": "Hello"
}

Try changing “sender” to different values and holding multiple conversations with your bot.

@ActuallyAcey, Can you please explain it, how can we send sender id with conversation? and i’m talking about parallel execution with rasa action server?

And i’m using rasa bot(web component) which uses regular HTTP requests.

1 Like

How you send a sender ID depends entirely on your choice of frontend. End of the day, the RASA server wants a “sender” field in the JSON that you send to it. The sender can be any unique but persistent value that you can assign to someone.

For example, if your chatbot shows up after a login page, you can send the login ID as the sender. If not, you can send a randomly generated number.

@ActuallyAcey Thanks for your response, I tried with sender id, but its not working for parallel execution of rasa action server(rasa run actions -p 5055).

Same here. I wonder why this problem has not come up before.

Here is a different question from forum but goes under this same topic:

@k1m Thanks for your reply, any other alternative way to achieve parallel execution in action server?

Please look out this issue. @erohmensing @akelad @JulianGerhard

Hi @rsawriya,

basically the action server is only called “server” when used by sanic/flask. The code which actually executes a RemoteAction resides in /rasa/core/actions/action.py. You could do something like the following to achieve what you want:

executor = ActionExecutor()
executor.register_package('actions')
try:
    response = await executor.run(json_body)
except:
    action_name = json_body.get("next_action")
    exception = ActionExecutionRejection(
        action_name, "Modified CustomAction threw ActionExecutionRejection."
    )
    logger.error(exception.message)
    raise exception

Keep in mind that you have to insert the path for the actions.py you want to use inside the PATH variable and that this approach means modifying the rasa core. I am not sure why you want to do what you mentioned, but this possibly helps you.

Kind regards
Julian

@JulianGerhard Can you please share more details here, I am still struggling with it,

and any other way without modifying rasa core?

thanks

1 Like

Hi, @rsawriya my code looks something like this for testing out the bot on server. To simulate users, you could make functions with different names or just this one function iterating over a list of users. Albeit, testing with RasaX is convenient if you aren’t looking for an approach which is developer/coder friendly. Hope I could be of help

def func1():
    timer = []
    sender = "user1"
    words = ['hi', 'i am good', 'sad']
    description = {}
    c = 0
    while c != 15:
        message = random.choice(words)

        start = time.time()

        requests.post('http://localhost:5002/webhooks/rest/webhook', json={"message": message, "sender": sender})

        end = time.time()
        timer.append((end - start))
        description[(end - start), c] = message
        c = c + 1
        if c == 15:
            break
    count = [i + 1 for i in range(len(timer))]
    plt.plot(count, timer)
    plt.xlabel('iteration')
    plt.ylabel('time')
    plt.show()
    print(description)
    print("1 finish")

It works with rasa 3.6.17 if you interact with html requests like

payload = {
        "sender": update.message.from_user.id,
        "message": user_input
    }