One Conversation Multiple Agents and Routing - Rasa Open Source - Rasa Community Forum

👋 Introducing the Rasa Playground

One Conversation Multiple Agents and Routing

You have selected 0 posts.

6.8k views
15 likes
5 links
9 users

post by adrianhumphrey111 on Aug 27, 2018

I know that rasa_core does not support multiple domains, however, regarding having one conversation, having one agent start the conversation and another finish the conversation, what is the best way to go about this?

Some ideas I have is to subclass the agent class and implement a transfer class where I can simply transfer the tracker and any other items to a new agent and have the same input channel handle input but the input goes to a new agent?

Maybe Create a Conversation class that can keep track of a sender_id conversation and it’s current agent that it is talking to?

I have no clue where to get started.

My reasoning for this is I want an agent to be able to route to other agents that are trained at a higher probability to handle intents and custom actions, rather than to have a huge agent with a lot of intents and low probability for them and a lot of confusion.

Any Ideas?

post by jeanmetz on Aug 28, 2018

Hi @adrianhumphrey111, if I’m not mistaken you can many agents at the same time pointing to the same Redis endpoint where the tracker information will be stored. So you wouldn’t need to write your own class for context transfer, since all agents can fetch the context from the object store.

post by souvikg10 on Aug 28, 2018

We have tested Redis that has one conversation tracker (using user id) and able to continue the conversation in different languages (one bot in each language). Use the Redis tracker and user id will be unique key that determines the state of the conversation.

post by adrianhumphrey111 on Aug 28, 2018

That you very much will try to implement this now. Just a quick question, what exactly do you mean by “Use the Redis Tracker.”

post by souvikg10 on Aug 28, 2018

By default, It is stored in InMemoryTracker which you can also access but then it is restricted to one server running one bot. If you want to share the tracker between multiple agents running on multiple servers or containers, you need to store it somewhere global but the persistence level is usually not that long. You don’t want the bot to remember conversations for one particular user that happened a long time ago. Ideally you can use a tracker_store.

Rasa provides Redis implementation, you can extend it to use your own (RabbitMQ, MongoDB), If you use the RedisTrackerStore basically you spin up a Redis server where you save the tracker state.

agent.load_from_server(
                interpreter=interpreter,
                generator=endpoints.nlg,
                action_endpoint=endpoints.action,
                model_server=endpoints.model,
                tracker_store=tracker_store,
                wait_time_between_pulls=wait_time_between_pulls

You should pass the tracker_store as RedisTrackerStore with the endpoints and credentials (take idea from the tracker_store.py). Above is just an example.

Subsequent Posts

post by adrianhumphrey111 on Aug 28, 2018

This is awesome. I really appreciate the in detail explanation; I usually always try to do it for people and this is the first time I ever got one back. Lol So thank you.

post by adrianhumphrey111 on Aug 30, 2018

So in theory I could do this. Create a tracker with a sender_id. Save that tracker in the database. Create two agents. Instantiate those two agents with the same tracker. When a message comes in, with a sender_id, I pull that tracker from the database and parse which agent to route to.

post by souvikg10 on Aug 30, 2018

No worries, usually you are looking at a custom action to indicate and a gateway of some sort that can check and route to the correct agent.

post by sam on Oct 12, 2018

I am currently in the same situation, trying to create multiple agents that can interact in one conversation with the user. So I have two models, each trained on a separate dataset, but now how do I make sure that each incoming message is passed to the right agent before it’s processed? How do I go about creating such a workflow?
The way I’m thinking about implementing this is by introducing a third agent that’s only job is to read an incoming message and depending on the classification it redirects the message to one of the two agents.

post by souvikg10 on Oct 12, 2018

You can take my example above where I share context between two agents using a redis tracker though the routing in my case is simply based on a parameter. You have to put first topic classification (in financial case - Daily banking/Transfer/Credits) This MUST be a very simple classifier for you to route to the right agent.

agent = Agent(domain_file, policies = [MemoizationPolicy(), KerasPolicy(max_history=3, epochs=200, batch_size=50)])

post by adrianhumphrey111 on Jan 15, 2019

How do I add code like you just did? I'll give you an example.