Skip to main content

Build persistent chat memory with GPT-4o-mini and Qdrant vector database

Workflow preview

Workflow preview
100%
Build persistent chat memory with GPT-4o-mini and Qdrant vector database preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

Long Term Memory System for AI Agents with Vector Database Transform your AI assistants into intelligent agents with persistent memory capabilities. This production ready workflow implements a s...

Best for

  • Engineering automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

@n8n/n8n-nodes-langchain.embeddingsopenai, n8n-nodes-base.stickynote, @n8n/n8n-nodes-langchain.documentdefaultdataloader, @n8n/n8n-nodes-langchain.textsplitterrecursivecharactertextsplitter, @n8n/n8n-nodes-langchain.chattrigger, @n8n/n8n-nodes-langchain.rerankercohere, @n8n/n8n-nodes-langchain.vectorstoreqdrant, @n8n/n8n-nodes-langchain.lmchatopenai

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Einar César Santos.

Original n8n.io source

1.1 Workflow description

Title
Build persistent chat memory with GPT-4o-mini and Qdrant vector database
Workflow name
Build persistent chat memory with GPT-4o-mini and Qdrant vector database

🧠 Long-Term Memory System for AI Agents with Vector Database

Transform your AI assistants into intelligent agents with persistent memory capabilities. This production-ready workflow implements a sophisticated long-term memory system using vector databases, enabling AI agents to remember conversations, user preferences, and contextual information across unlimited sessions.

🎯 What This Template Does

This workflow creates an AI assistant that never forgets. Unlike traditional chatbots that lose context after each session, this implementation uses vector database technology to store and retrieve conversation history semantically, providing truly persistent memory for your AI agents.

🔑 Key Features

  • Persistent Context Storage: Automatically stores all conversations in a vector database for permanent retrieval
  • Semantic Memory Search: Uses advanced embedding models to find relevant past interactions based on meaning, not just keywords
  • Intelligent Reranking: Employs Cohere's reranking model to ensure the most relevant memories are used for context
  • Structured Data Management: Formats and stores conversations with metadata for optimal retrieval
  • Scalable Architecture: Handles unlimited conversations and users with consistent performance
  • No Context Window Limitations: Effectively bypasses LLM token limits through intelligent retrieval

💡 Use Cases

  • Customer Support Bots: Remember customer history, preferences, and previous issues
  • Personal AI Assistants: Maintain user preferences and conversation continuity over months or years
  • Knowledge Management Systems: Build accumulated knowledge bases from user interactions
  • Educational Tutors: Track student progress and adapt teaching based on history
  • Enterprise Chatbots: Maintain context across departments and long-term projects

🛠️ How It Works

  1. User Input: Receives messages through n8n's chat interface
  2. Memory Retrieval: Searches vector database for relevant past conversations
  3. Context Integration: AI agent uses retrieved memories to generate contextual responses
  4. Response Generation: Creates informed responses based on historical context
  5. Memory Storage: Stores new conversation data for future retrieval

📋 Requirements

  • OpenAI API Key: For embeddings and chat completions
  • Qdrant Instance: Cloud or self-hosted vector database
  • Cohere API Key: Optional, for enhanced retrieval accuracy
  • n8n Instance: Version 1.0+ with LangChain nodes

🚀 Quick Setup

  1. Import this workflow into your n8n instance
  2. Configure credentials for OpenAI, Qdrant, and Cohere
  3. Create a Qdrant collection named 'ltm' with 1024 dimensions
  4. Activate the workflow and start chatting!

📊 Performance Metrics

  • Response Time: 2-3 seconds average
  • Memory Recall Accuracy: 95%+
  • Token Usage: 50-70% reduction compared to full context inclusion
  • Scalability: Tested with 100k+ stored conversations

💰 Cost Optimization

  • Uses GPT-4o-mini for optimal cost/performance balance
  • Implements efficient chunking strategies to minimize embedding costs
  • Reranking can be disabled to save on Cohere API costs
  • Average cost: ~$0.01 per conversation

📖 Learn More

For a detailed explanation of the architecture and implementation details, check out the comprehensive guide: Long-Term Memory for LLMs using Vector Store - A Practical Approach with n8n and Qdrant

🤝 Support

  • Documentation: Full setup guide in the article above
  • Community: Share your experiences and get help in n8n community forums
  • Issues: Report bugs or request features on the workflow page

Tags: #AI #LangChain #VectorDatabase #LongTermMemory #RAG #OpenAI #Qdrant #ChatBot #MemorySystem #ArtificialIntelligence

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - Embeddings OpenAI

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOpenAi - embeddingsOpenAi
Config choices
Version 1.2

Block 2 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 3 - Default Data Loader

Type / Role
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - documentDefaultDataLoader
Config choices
Version 1

Block 4 - Sticky Note 2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 5 - Recursive Character Text Splitter

Type / Role
@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter - textSplitterRecursiveCharacterTextSplitter
Config choices
Version 1

Block 6 - Sticky Note 3

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 7 - When chat message received

Type / Role
@n8n/n8n-nodes-langchain.chatTrigger - chatTrigger
Config choices
Version 1.1

Block 8 - Sticky Note 4

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 9 - Embeddings for Retrieval

Type / Role
@n8n/n8n-nodes-langchain.embeddingsOpenAi - embeddingsOpenAi
Config choices
Version 1.2

Block 10 - Sticky Note 5

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 11 - Reranker Cohere

Type / Role
@n8n/n8n-nodes-langchain.rerankerCohere - rerankerCohere
Config choices
Version 1

Block 12 - Sticky Note 6

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 13 - RAG_MEMORY

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreQdrant - vectorStoreQdrant
Config choices
Version 1.2

Block 14 - Sticky Note 7

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 15 - OpenAI Chat Model

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Block 16 - Structured Output Parser

Type / Role
@n8n/n8n-nodes-langchain.outputParserStructured - outputParserStructured
Config choices
Version 1.3

Block 17 - Sticky Note 8

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 18 - Format Response

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.4

Block 19 - Sticky Note 9

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 20 - AI Agent

Type / Role
@n8n/n8n-nodes-langchain.agent - agent
Config choices
Version 2

Block 21 - Sticky Note 10

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Store Conversation

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreQdrant - vectorStoreQdrant
Config choices
Version 1.2

Block 23 - Sticky Note 11

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 24 - GPT-4o-mini (Main)

Type / Role
@n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
Config choices
Version 1.2

Showing the first 24 of 25 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Build persistent chat memory with GPT-4o-mini and Qdrant vector database
Complexity advanced
Nodes 25
Categories Engineering, AI RAG
Author Einar César Santos
Published 02 Aug 2025

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/6829/6829.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Build persistent chat memory with GPT-4o-mini and Qdrant vector database do?

Long Term Memory System for AI Agents with Vector Database Transform your AI assistants into intelligent agents with persistent memory capabilities. This production ready workflow implements a s...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering, AI RAG use case.