Templates / 🧠 Empower your AI chatbot with long-term memory and dynamic tool routing

🧠 Empower your AI chatbot with long-term memory and dynamic tool routing

Needs changes

by Joseph LePage ✓ · 37,656 views · created 2025-02-27 · Support Chatbot, AI Chatbot

Needs changes. This template uses 1 thing(s) that n8n 3.0 removes: AI Agent v1 (old agent modes). 1 breaking item(s) found. Static check, last run 2026-10-19.

What 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).

  1. 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
  2. Memory Tool Router (Switch): routes items into 4 branches
  3. Save Long Term Memories (Google Docs): update
  4. Retrieve Long Term Memories (Google Docs): get
  5. Retrieve Long Term Memories (Google Docs): get
  6. Retrieve Long Term Memories (Google Docs): get
  7. Saved response (Edit Fields (Set)): sets 1 field: response
  8. Respond with long term memories (Edit Fields (Set)): sets 1 field: response
  9. Prepare Telegram Message (Basic LLM Chain): sends a prompt to an LLM, with model: OpenAI Chat Model
  10. 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

Google DocsTelegramGmailOpenAI Chat Model

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.0Replace 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)

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…

Excerpt from Joseph LePage's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.