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
- User Input: Receives messages through n8n's chat interface
- Memory Retrieval: Searches vector database for relevant past conversations
- Context Integration: AI agent uses retrieved memories to generate contextual responses
- Response Generation: Creates informed responses based on historical context
- 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
- Import this workflow into your n8n instance
- Configure credentials for OpenAI, Qdrant, and Cohere
- Create a Qdrant collection named 'ltm' with 1024 dimensions
- 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
n8n Workflow: Build Persistent Chat Memory with GPT-4o-mini and Qdrant Vector Database
This n8n workflow demonstrates how to create a conversational AI agent with persistent memory using OpenAI's GPT-4o-mini, Qdrant as a vector database, and Langchain components. It allows the AI to remember past interactions and provide contextually relevant responses.
What it does
This workflow sets up a chat agent that:
- Listens for chat messages: It acts as a trigger, initiating the workflow whenever a new chat message is received.
- Loads chat history: It takes the incoming chat message and prepares it for processing.
- Splits text for embedding: The chat message is broken down into smaller, manageable chunks to optimize the embedding process.
- Generates embeddings: It uses OpenAI's embedding model to convert the text chunks into numerical vector representations.
- Stores/Retrieves from Qdrant: These embeddings are then stored in or retrieved from a Qdrant vector database, acting as the long-term memory for the chat.
- Reranks retrieved documents (Optional): If relevant documents are retrieved, a Cohere Reranker can be used to refine their order based on relevance to the current query.
- Engages AI Agent: An AI agent, powered by an OpenAI Chat Model (e.g., GPT-4o-mini), uses the current chat message and the context retrieved from Qdrant to formulate a coherent response.
- Parses AI output: The AI's response is structured using a Structured Output Parser to ensure it adheres to a predefined format.
- Edits fields (Set): Finally, it processes and potentially modifies the AI's output before it's sent back as a response.
Prerequisites/Requirements
To use this workflow, you will need:
- n8n instance: A running n8n instance (self-hosted or cloud).
- OpenAI API Key: For the
Embeddings OpenAIandOpenAI Chat Modelnodes. - Qdrant Instance: Access to a Qdrant vector database (self-hosted or cloud) with appropriate connection details.
- Cohere API Key (Optional): If you intend to use the
Reranker Coherenode for improved document relevance.
Setup/Usage
- Import the workflow: Download the JSON provided and import it into your n8n instance.
- Configure Credentials:
- OpenAI: Set up your OpenAI API key credentials in the
Embeddings OpenAIandOpenAI Chat Modelnodes. - Qdrant: Configure your Qdrant connection details (host, API key, collection name) in the
Qdrant Vector Storenode. - Cohere (Optional): If using the reranker, set up your Cohere API key credentials in the
Reranker Coherenode.
- OpenAI: Set up your OpenAI API key credentials in the
- Activate the workflow: Once all credentials are set, activate the workflow.
- Interact with the Chat Trigger: The
When chat message receivednode acts as the entry point. You would typically connect this to a chat platform (e.g., Slack, Telegram, custom webhook) to receive user messages. The workflow is designed to process these messages and send back AI-generated responses.
This workflow provides a robust foundation for building intelligent chatbots that can maintain context across conversations, significantly enhancing user experience.
Related Templates
Two-way property repair management system with Google Sheets & Drive
This workflow automates the repair request process between tenants and building managers, keeping all updates organized in a single spreadsheet. It is composed of two coordinated workflows, as two separate triggers are required β one for new repair submissions and another for repair updates. A Unique Unit ID that corresponds to individual units is attributed to each request, and timestamps are used to coordinate repair updates with specific requests. General use cases include: Property managers who manage multiple buildings or units. Building owners looking to centralize tenant repair communication. Automation builders who want to learn multi-trigger workflow design in n8n. --- βοΈ How It Works Workflow 1 β New Repair Requests Behind the Scenes: A tenant fills out a Google Form (βRepair Request Formβ), which automatically adds a new row to a linked Google Sheet. Steps: Trigger: Google Sheets rowAdded β runs when a new form entry appears. Extract & Format: Collects all relevant form data (address, unit, urgency, contacts). Generate Unit ID: Creates a standardized identifier (e.g., BUILDING-UNIT) for tracking. Email Notification: Sends the building manager a formatted email summarizing the repair details and including a link to a Repair Update Form (which activates Workflow 2). --- Workflow 2 β Repair Updates Behind the Scenes:\ Triggered when the building manager submits a follow-up form (βRepair Update Formβ). Steps: Lookup by UUID: Uses the Unit ID from Workflow 1 to find the existing row in the Google Sheet. Conditional Logic: If photos are uploaded: Saves each image to a Google Drive folder, renames files consistently, and adds URLs to the sheet. If no photos: Skips the upload step and processes textual updates only. Merge & Update: Combines new data with existing repair info in the same spreadsheet row β enabling a full repair history in one place. --- π§© Requirements Google Account (for Forms, Sheets, and Drive) Gmail/email node connected for sending notifications n8n credentials configured for Google API access --- β‘ Setup Instructions (see more detail in workflow) Import both workflows into n8n, then copy one into a second workflow. Change manual trigger in workflow 2 to a n8n Form node. Connect Google credentials to all nodes. Update spreadsheet and folder IDs in the corresponding nodes. Customize email text, sender name, and form links for your organization. Test each workflow with a sample repair request and a repair update submission. --- π οΈ Customization Ideas Add Slack or Telegram notifications for urgent repairs. Auto-create folders per building or unit for photo uploads. Generate monthly repair summaries using Google Sheets triggers. Add an AI node to create summaries/extract relevant repair data from repair request that include long submissions.
Send WooCommerce cross-sell offers to customers via WhatsApp using Rapiwa API
Who Is This For? This n8n workflow enables automated cross-selling by identifying each WooCommerce customer's most frequently purchased product, finding a related product to recommend, and sending a personalized WhatsApp message using the Rapiwa API. It also verifies whether the user's number is WhatsApp-enabled before sending, and logs both successful and unsuccessful attempts to Google Sheets for tracking. What This Workflow Does Retrieves all paying customers from your WooCommerce store Identifies each customer's most purchased product Finds the latest product in the same category as their most purchased item Cleans and verifies customer phone numbers for WhatsApp compatibility Sends personalized WhatsApp messages with product recommendations Logs all activities to Google Sheets for tracking and analysis Handles both verified and unverified numbers appropriately Key Features Customer Segmentation: Automatically identifies paying customers from your WooCommerce store Product Analysis: Determines each customer's most purchased product Smart Recommendations: Finds the latest products in the same category as customer favorites WhatsApp Integration: Uses Rapiwa API for message delivery Phone Number Validation: Verifies WhatsApp numbers before sending messages Dual Logging System: Tracks both successful and failed message attempts in Google Sheets Rate Limiting: Uses batching and wait nodes to prevent API overload Personalized Messaging: Includes customer name and product details in messages Requirements WooCommerce store with API access Rapiwa account with API access for WhatsApp verification and messaging Google account with Sheets access Customer phone numbers in WooCommerce (stored in billing.phone field) How to Use β Step-by-Step Setup Credentials Setup WooCommerce API: Configure WooCommerce API credentials in n8n (e.g., "WooCommerce (get customer)" and "WooCommerce (get customer data)") Rapiwa Bearer Auth: Create an HTTP Bearer credential with your Rapiwa API token Google Sheets OAuth2: Set up OAuth2 credentials for Google Sheets access Configure Google Sheets Ensure your sheet has the required columns as specified in the Google Sheet Column Structure section Verify Code Nodes Code (get paying_customer): Filters customers to include only those who have made purchases Get most buy product id & Clear Number: Identifies the most purchased product and cleans phone numbers Configure HTTP Request Nodes Get customer data: Verify the WooCommerce API endpoint for retrieving customer orders Get specific product data: Verify the WooCommerce API endpoint for product details Get specific product recommend latest product: Verify the WooCommerce API endpoint for finding latest products by category Check valid WhatsApp number Using Rapiwa: Verify the Rapiwa endpoint for WhatsApp number validation Rapiwa Sender: Verify the Rapiwa endpoint for sending messages Google Sheet Required Columns Youβll need two Google Sheets (or two tabs in one spreadsheet): A Google Sheet formatted like this β€ sample The workflow uses a Google Sheet with the following columns to track coupon distribution: Both must have the following headers (match exactly): | name | number | email | address1 | price | suk | title | product link | validity | staus | | ---------- | ------------- | ----------------------------------------------- | ----------- | ----- | --- | ---------------------------------- | ------------------------------------------------------------------------------------------------------------------------------------------------------ | ---------- | -------- | | Abdul Mannan | 8801322827799 | contact@spagreen.net | mirpur dohs | 850 | | Sharp Most Demanding Hoodie x Nike | https://yourshopdomain/p-img-nike | verified | sent | | Abdul Mannan | 8801322827799 | contact@spagreen.net | mirpur dohs | 850 | | Sharp Most Demanding Hoodie x Nike | https://yourshopdomain/p-img-nike | unverified | not sent | | Abdul Mannan | 8801322827799 | contact@spagreen.net | mirpur dohs | 850 | | Sharp Most Demanding Hoodie x Nike | https://yourshopdomain/p-img-nike | verified | sent | Important Notes Phone Number Format: The workflow cleans phone numbers by removing all non-digit characters. Ensure your WooCommerce phone numbers are in a compatible format. API Rate Limits: Rapiwa and WooCommerce APIs have rate limits. Adjust batch sizes and wait times accordingly. Data Privacy: Ensure compliance with data protection regulations when sending marketing messages. Error Handling: The workflow logs unverified numbers but doesn't have extensive error handling. Consider adding error notifications for failed API calls. Product Availability: The workflow recommends the latest product in a category, but doesn't check if it's in stock. Consider adding stock status verification. Testing: Always test with a small batch before running the workflow on your entire customer list. Useful Links Dashboard: https://app.rapiwa.com Official Website: https://rapiwa.com Documentation: https://docs.rapiwa.com Support & Help WhatsApp: Chat on WhatsApp Discord: SpaGreen Community Facebook Group: SpaGreen Support Website: https://spagreen.net Developer Portfolio: Codecanyon SpaGreen
Track SDK documentation drift with GitHub, Notion, Google Sheets, and Slack
π Description Automatically track SDK releases from GitHub, compare documentation freshness in Notion, and send Slack alerts when docs lag behind. This workflow ensures documentation stays in sync with releases, improves visibility, and reduces version drift across teams. πππ¬ What This Template Does Step 1: Listens to GitHub repository events to detect new SDK releases. π§© Step 2: Fetches release metadata including version, tag, and publish date. π¦ Step 3: Logs release data into Google Sheets for record-keeping and analysis. π Step 4: Retrieves FAQ or documentation data from Notion. π Step 5: Merges GitHub and Notion data to calculate documentation drift. π Step 6: Flags SDKs whose documentation is over 30 days out of date. β οΈ Step 7: Sends detailed Slack alerts to notify responsible teams. π Key Benefits β Keeps SDK documentation aligned with product releases β Prevents outdated information from reaching users β Provides centralized release tracking in Google Sheets β Sends real-time Slack alerts for overdue updates β Strengthens DevRel and developer experience operations Features GitHub release trigger for real-time monitoring Google Sheets logging for tracking and auditing Notion database integration for documentation comparison Automated drift calculation (days since last update) Slack notifications for overdue documentation Requirements GitHub OAuth2 credentials Notion API credentials Google Sheets OAuth2 credentials Slack Bot token with chat:write permissions Target Audience Developer Relations (DevRel) and SDK engineering teams Product documentation and technical writing teams Project managers tracking SDK and doc release parity Step-by-Step Setup Instructions Connect your GitHub account and select your SDK repository. Replace YOURGOOGLESHEETID and YOURSHEET_GID with your tracking spreadsheet. Add your Notion FAQ database ID. Configure your Slack channel ID for alerts. Run once manually to validate setup, then enable automation.