{"product_id":"n8n-persistent-ai-agent-memory-claude-postgres-redis","title":"n8n Persistent AI Agent Memory: Claude + Postgres + Redis","description":"\u003ch3\u003eTurn Claude chats into persistent, searchable memory—powered by n8n, Redis, and Postgres (pgvector)\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow gives your AI agent \u003cstrong\u003epersistent memory\u003c\/strong\u003e across conversations by combining \u003cstrong\u003eRedis session history\u003c\/strong\u003e (recent context) with \u003cstrong\u003ePostgreSQL + pgvector\u003c\/strong\u003e (long-term memory). It uses \u003cstrong\u003eAnthropic Claude\u003c\/strong\u003e to chat and extract durable memories, \u003cstrong\u003eVoyage AI embeddings\u003c\/strong\u003e to embed them, and includes webhooks to \u003cstrong\u003eforget\u003c\/strong\u003e specific memories or clear all memories for a user.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eReceives chat via webhook (or manual trigger)\u003c\/strong\u003e: validates \u003cem\u003euserId\u003c\/em\u003e, \u003cem\u003esessionId\u003c\/em\u003e, and message, then loads configuration.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eBuilds context from Redis\u003c\/strong\u003e: loads recent conversation turns and retrieves (or generates) a cached query embedding using \u003cstrong\u003eVoyage AI\u003c\/strong\u003e stored in Redis.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eSearches long-term memories in PostgreSQL\u003c\/strong\u003e: runs a \u003cstrong\u003epgvector similarity search\u003c\/strong\u003e for the user, re-ranks results using similarity\/importance\/recency, and updates access statistics.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eGenerates a response with Claude\u003c\/strong\u003e: sends recent turns plus retrieved memory context to \u003cstrong\u003eAnthropic Claude\u003c\/strong\u003e and returns the reply to the webhook caller.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eStores new durable memories in the background\u003c\/strong\u003e: saves updated session history back to Redis, has Claude extract new durable memories, embeds them with Voyage AI, and \u003cstrong\u003eupserts into PostgreSQL\u003c\/strong\u003e while deduplicating near-duplicates.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eDaily maintenance\u003c\/strong\u003e: runs once per day to \u003cstrong\u003edecay importance\u003c\/strong\u003e and prune expired or low-importance memories in PostgreSQL.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eForgetting via webhook\u003c\/strong\u003e: deletes one memory by UUID or deletes \u003cstrong\u003eall memories for a user\u003c\/strong\u003e in PostgreSQL, and clears the corresponding Redis session.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eSaaS support bots that remember user preferences and ticket context over time\u003c\/li\u003e\n  \u003cli\u003eKnowledge assistants that build a growing, vector-searchable user memory store\u003c\/li\u003e\n  \u003cli\u003eAutomation engineers needing controllable AI memory with explicit “forget” actions\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eNodes used\u003c\/strong\u003e: if, set, code, redis, webhook, postgres\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eLong-term storage\u003c\/strong\u003e: PostgreSQL with \u003cstrong\u003epgvector\u003c\/strong\u003e similarity search\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eEmbeddings\u003c\/strong\u003e: \u003cstrong\u003eVoyage AI\u003c\/strong\u003e (cached in Redis)\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eAI model\u003c\/strong\u003e: \u003cstrong\u003eAnthropic Claude\u003c\/strong\u003e for chat and memory extraction\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":46123137466547,"sku":"N8N-20119","price":71.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/oyzvOqP7jxqvmNVATPVBa_Rd6gma6y.png?v=1790672931","url":"https:\/\/buyflowscripts.com\/products\/n8n-persistent-ai-agent-memory-claude-postgres-redis","provider":"N8N Commerce","version":"1.0","type":"link"}