← All N8N workflows
AI & researchAgentChain LLMChat TriggerExecute Workflow TriggerGmail

🧠 Give Your AI Agent Chatbot Long Term Memory Tools Router

Configured with Agent, Chain LLM, Chat Trigger, Execute Workflow Trigger, and additional nodes. Review the connections and setup before adapting this template.

Workflow preview
TriggerWhen Executed byAnother WorkflowExecute Workflow TriggerFiles / mediaSave Long Term MemoriesGoogle DocsTransformSaved responseEdit FieldsTransformRespond with long termmemoriesEdit FieldsFiles / mediaRetrieve Long TermMemories3Google DocsMessagingSend Success Message toTelegramTelegramMessagingEmail Workflow StatsGmailAI & modelsOpenAI Chat Model2OpenAI Chat ModelAI & modelsOpenAI Chat Model3OpenAI Chat ModelSubworkflow📤Send Memories toTelegramTool WorkflowSubworkflow📫Send Memories toGmailTool WorkflowSubworkflow🧠Save MemoriesTool WorkflowSubworkflow🔎Retrieve MemoriesTool WorkflowData store🤯Window Buffer MemoryMemory Buffer WindowAI & models🧠 AI Agent w/Long TermMemoryAgentAI & models🤖OpenAI Chat ModelOpenAI Chat ModelTriggerⓂ️ When chat messagereceivedChat TriggerAI & modelsPrepare TelegramMessageChain LLMAI & modelsPrepare Gmail MessageChain LLMFiles / mediaRetrieve Long TermMemoriesGoogle DocsRoutingMemory Tool RouterSwitchFiles / mediaRetrieve Long TermMemories2Google Docs

Node categories in this workflow

  • Trigger
  • Files / media
  • Transform
  • Messaging
  • AI & models
  • Subworkflow
  • Data store
  • Routing

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
When Executed by Another WorkflowTriggerExecute Workflow TriggerSee node parameters
Save Long Term MemoriesFiles / mediaGoogle Docsupdate
Saved responseTransformEdit FieldsSee node parameters
Respond with long term memoriesTransformEdit FieldsSee node parameters
Retrieve Long Term Memories3Files / mediaGoogle Docsget
Send Success Message to TelegramMessagingTelegramSee node parameters
Email Workflow StatsMessagingGmailSee node parameters
OpenAI Chat Model2AI & modelsOpenAI Chat ModelSee node parameters
OpenAI Chat Model3AI & modelsOpenAI Chat ModelSee node parameters
📤Send Memories to TelegramSubworkflowTool WorkflowSee node parameters
📫Send Memories to GmailSubworkflowTool WorkflowSee node parameters
🧠Save MemoriesSubworkflowTool WorkflowSee node parameters
🔎Retrieve MemoriesSubworkflowTool WorkflowSee node parameters
🤯Window Buffer MemoryData storeMemory Buffer WindowSee node parameters
🧠 AI Agent w/Long Term MemoryAI & modelsAgentSee node parameters
🤖OpenAI Chat ModelAI & modelsOpenAI Chat ModelSee node parameters
Ⓜ️ When chat message receivedTriggerChat TriggerSee node parameters
Prepare Telegram MessageAI & modelsChain LLMSee node parameters
Prepare Gmail MessageAI & modelsChain LLMSee node parameters
Retrieve Long Term MemoriesFiles / mediaGoogle Docsget
Memory Tool RouterRoutingSwitchSee node parameters
Retrieve Long Term Memories2Files / mediaGoogle Docsget

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

  • gmailOAuth2
  • googleDocsOAuth2Api
  • openAiApi
  • telegramApi

Workflow notes

Enhance Your AI Workflow with Long-Term Memory and Dynamic Tool Routing

Enhance Your AI Workflow with Long-Term Memory and Dynamic Tool Routing

This n8n workflow empowers your AI agent with long-term memory and a dynamic tools router, enabling it to provide intelligent, context-aware responses while seamlessly managing tasks across multiple tools. By combining memory persistence and modular tool routing, this solution enhances the capabilities of your AI agent, making it smarter, more efficient, and highly adaptable.

🚀 How It Works

🧠 Long-Term Memory Management

  • The AI agent can save and retrieve memories using Google Docs as a storage system.
  • Persistent memory allows the agent to recall past interactions, user preferences, and contextual details for personalized responses.

🛠️ Tools Router for Dynamic Task Management

  • A tools router directs tasks to the appropriate tools based on the AI agent's instructions.
  • Supported tools include:
    • Save Memories: Store important data for future reference.
    • Retrieve Memories: Access stored information when needed.
    • Send Notifications via Gmail or Telegram: Share insights or updates with stakeholders.

🤖 AI-Powered Contextual Understanding

  • The workflow integrates an OpenAI GPT-based model to process user inputs intelligently.
  • The AI agent uses a window buffer memory for short-term context and leverages long-term memory when necessary.

📤 Multi-Channel Notifications

  • Automatically send memory summaries or workflow updates via Gmail or Telegram for enhanced communication.

🔧 Setup Steps

🔑 Configure API Credentials

Set up API connections for:

  • OpenAI (for AI processing).
  • Google Docs (for long-term memory storage).
  • Gmail/Telegram (for notifications).

⚙️ Customize Workflow Parameters

  • Adjust the AI agent's system message to align with your specific use case or tone.
  • Define routing rules in the tools router to suit your workflow needs.

🧪 Test & Deploy

  • Test the workflow by interacting with the AI agent and verifying:
    • Accurate memory saving/retrieval.
    • Correct task routing via the tools router.
    • Seamless notification delivery.
🧠 Give Your AI Agent Chatbot Long Term Memory Tools Router

🧠 Give Your AI Agent Chatbot Long Term Memory Tools Router

Purpose and structure

This folder contains the 🧠 Give Your AI Agent Chatbot Long Term Memory Tools Router workflow. Its executable nodes use agent, chainLlm, chatTrigger, executeWorkflowTrigger, gmail, googleDocs, lmChatOpenAi, memoryBufferWindow, set, switch, telegram, toolWorkflow. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

When Executed by Another Workflow, Ⓜ️ When chat message received

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Telegram/1950_Telegram_Googledocs_Automate_Triggered.json MIT; preserve source notices.

Canvas section labels

These name areas of the original canvas; they do not include explanatory instructions.

  • 1️⃣ Save Memories
  • 3️⃣ Send Memories to Telegram
  • 4️⃣ Send Memories to Gmail
  • 2️⃣ Retrieve Memories
  • Short Term Chat Memory
  • Cloud LLM
  • 🧠 AI Agent Chatbot With Long Term Memory Tools
  • 🛠️ Agentic Long Term Memory Management Tool Options
  • 👍Try Me!
  • 1️⃣ Save Long Term Memories Tool
  • 2️⃣ Retrieve Long Term Memories Tool
  • 3️⃣ Send Memories to Telegram Tool
  • 4️⃣ Send Memories to Gmail Tool
  • Memory Tool Router
  • Receive Memory Tool Instructions from Agent
  • 🛠️ Long Term Memory Tool Kit

More in AI & research