🧠 Empower your AI chatbot with long-term memory and dynamic tool routing
Needs changesWhat this workflow does
This AI workflow has 22 nodes and runs when a chat message arrives (plus 1 other trigger). Along the way it connects Google Docs, Telegram, Gmail and OpenAI Chat Model.
How it runs
Trigger: When a chat message arrives (plus 1 other trigger).
- AI Agent: runs an AI agent, with model: OpenAI Chat Model; 4 tools (🧠Save Memories, 🔎Retrieve Memories, 📫Send Memories to Gmail, 📤Send Memories to Telegram); memory: 🤯Window Buffer Memory
- Memory Tool Router (Switch): routes items into 4 branches
- Save Long Term Memories (Google Docs): update
- Retrieve Long Term Memories (Google Docs): get
- Retrieve Long Term Memories (Google Docs): get
- Retrieve Long Term Memories (Google Docs): get
- Saved response (Edit Fields (Set)): sets 1 field: response
- Respond with long term memories (Edit Fields (Set)): sets 1 field: response
- Prepare Telegram Message (Basic LLM Chain): sends a prompt to an LLM, with model: OpenAI Chat Model
- Prepare Gmail Message (Basic LLM Chain): sends a prompt to an LLM, with model: OpenAI Chat Model
…plus 2 more steps. See the full node list below.
Services it uses
Before you upgrade to n8n 3.0
1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:
- AI Agent v1 (old agent modes) in 🧠 AI Agent w/Long Term Memory (v1.7): replace with Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.
Rather not rewrite it? Many of these flows can be rebuilt in Make (free plan).
| Removed in 3.0 | Replace with |
|---|---|
| AI Agent v1 (old agent modes) 🧠 AI Agent w/Long Term Memory (v1.7) | Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent. |
Nodes used (12)
- Execute Workflow Trigger
n8n-nodes-base.executeWorkflowTrigger - Google Docs
n8n-nodes-base.googleDocs - Edit Fields (Set)
n8n-nodes-base.set - Telegram
n8n-nodes-base.telegram - Gmail
n8n-nodes-base.gmail - OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Call n8n Workflow Tool
@n8n/n8n-nodes-langchain.toolWorkflow - Simple Memory
@n8n/n8n-nodes-langchain.memoryBufferWindow - AI Agent
@n8n/n8n-nodes-langchain.agent - Chat Trigger
@n8n/n8n-nodes-langchain.chatTrigger - Basic LLM Chain
@n8n/n8n-nodes-langchain.chainLlm - Switch
n8n-nodes-base.switch
From the author
Empower Your AI Chatbot with Long-Term Memory and Dynamic Tool Routing This n8n workflow equips your AI agent with long-term memory and a dynamic tools router, enabling it to provide intelligent, context-aware responses while managing tasks across multiple…