Efficient Architecture for Multi-Agent Telegram Bot in n8n: Maintaining State and Minimizing Nodes

Architectural Approach for Multi-Agent Conversation Workflow in n8n

I’m designing an n8n workflow that involves multiple agents, each with a different role, all intended to provide responses within a single conversation via Telegram. The user should be able to choose which agent they want to interact with.

Key Challenge

What’s the best architectural approach to build this process efficiently? I want to avoid creating separate nodes for each agent and restarting the workflow with every new Telegram message.

Specific Areas of Interest

  1. Efficiently managing multiple agents without duplicating nodes
  2. Maintaining conversation state across messages
  3. Dynamically routing messages to the appropriate agent
  4. Allowing users to switch between agents mid-conversation
  5. Optimizing the workflow to minimize the number of nodes used

Questions

  • How can I maintain conversation state and seamlessly switch between agents based on user choice?
  • Are there any best practices or design patterns for building such a multi-agent conversational workflow in n8n?

Any insights or suggestions would be greatly appreciated. Thank you!

It looks like your topic is missing some important information. Could you provide the following if applicable.

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:
  • **n8n version:**1.55.3
  • **Database (default: SQLite):**postgres
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app): n8n docker
  • **Operating system:**ubuntu

Hi @yaya,

The community can probably give you more suggestions, but if you haven’t checked out already, you can find some workflow templates on our website AI Agent integrations | Workflow automation with n8n that might inspire you. Here’s a workflow that uses multiple Agents for example: Automate Competitor Research with Exa.ai, Notion and AI Agents | n8n workflow template

1 Like

Thanks for the response!
Yes I know, I didn’t find any template or explanation how n8n can manage state to understand where the user is in the conversation without running all the triggers again

Did you ever figure anything out here ?

Hi @yaya @Aiagentexplorer

We are hosting a live Q&A AI session tonight - where we could talk about this topic (already added it to our agenda) so make sure to tune in :slight_smile:

1 Like