Connect 2 Chatbots. Integrate Python chatbot with RASA chatbot

Hi Rasa Community! :slight_smile:

I’ve been trying to connect two chatbots for a while now, but can’t find the missing piece of the puzzle and thought that maybe someone of you has made a similar attempt and maybe this is also an interesting topic for other RASA users. Here is the scenario:

Chatbot 1: RASA Chatbot

Chatbot 2: A chatbot written in Python which is capable of reasoning with the user.

Since most people here know the RASA framework, I’ll go into a bit more detail about the second chatbot. I built a graph consisting of arguments and counterarguments. When a user makes an argument, the chatbot searches for a similar argument in the graph and then presents the corresponding counterargument. If the user agrees, the chatbot simply brings something new and so on. I would have liked to write this chatbot directly in RASA, but that seemed impossible to me. So my idea right now is that when the user says a statement that could be followed by an argumentation/discussion, the RASA chatbot asks “Do you want to argue about this?”. If the user says yes, it is passed to the other chatbot, which argues with the user until there are no more arguments or the user says stop. Then the RASA chatbot takes over again. Of course it makes sense to do this through actionscripts, but I’m stuck at this point. For example, would I have to host both chatbots separately and have the user messages acted upon by one or the other chatbot according to certain criteria? If so, is that possible? Or could I somehow integrate the Python chatbot into the RASA bot as some kind of submodule? Where NLU is not done by RASA Nlu, but by the specific NLU component of my Python bot.

I would be sooo grateful for comments, tips, redirects to similar attempts (in Github) or further suggestions!

Many thanks! Linda

3 Likes

Hello!

This is described by the Handoff system.

From your question, you already seem knowledgeable, so what’s described in the link above should be enough to understand:

For example, as the final action of Two-Stage-Fallback, the bot could ask the user, “Would you like to be transferred to a human assistant?” and if they say yes, the bot sends a message with a specific payload like e.g. “handoff_to_human” to the channel. When the channel sees this message, it stops listening to the Rasa server, and sends a message to the human channel with the transcript of the chat conversation up to that point.

You probably don’t need fallback for this, a regular story should do.

Basically, when your story is completed, the bot should send a specific message to your frontend application, e.g. handoff_to_python.

When your application receives this message, of course, it doesn’t display it to the user, but starts listening to the IP/port of the Python Chatbot instead of Rasa’s.

Of course, you can customize this according to your needs.

The extract from the docs could be rewritten like this in your case:

For example, after the possible_argument intent, the bot could ask the user, “Do you want to argue about this?” and if they say yes, the bot sends a message with a specific payload like e.g. “handoff_to_python” to the application. When the applicationsees this message, it stops listening to the Rasa server, and sends a message to the Python server with the data it will need to continue.

Thank you Chris!

So this would imply that I host both chatbots separately? Implementing the python chatbot as a submodule would not be possible right? And just another thing: Would it be possible to get back to the RASA chatbot so let the RASA bot take over again when the user does not want to discuss anymore? And a last question: Is there any possibility to let the RASA chatbot’s conversational flow go over a knowledge graph?

Many thanks!

Sorry, forgot to answer that part!

You can still host the two bots on a same server, each running on a different port.

Yes, that’s most probably not possible.

Of course :slight_smile:

You will have to just implement the same logic on your Python chatbot, aka send a secret handoff_to_rasa message that will switch back.

I have no idea, sorry :sweat_smile:

1 Like

Many thanks!! :slight_smile:

1 Like