Registry / ai-ml / n8n-nodes-postgres-advanced-memory

n8n-nodes-postgres-advanced-memory

JSON →
library2.3.7jsnpmunverified

An n8n community node providing advanced PostgreSQL-based chat memory for AI agents, with support for schema isolation, auto table creation, session tracking, user ID handling, working memory persistence with tool integration, and semantic search via RAG. Current stable version 2.3.7, released regularly on npm. Key differentiators include schema support (multi-tenant), automatic schema/table creation, optional session metadata table, and a dedicated Working Memory Tool node for structured memory updates. Requires n8n >=1.0 and PostgreSQL >=9.5.

npm install n8n-nodes-postgres-advanced-memory
INSTALL
IMPORT
SIG · N8N-NODES-POSTGRES
N
n8n-nodes-postgres-advanced-memory
ai-mljavascriptv2.3.7
harness data pending
Install & Compatibility
Where this runs

No compatibility data collected yet for this library.

Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

MemoryPostgresAdvanced
import { MemoryPostgresAdvanced } from 'n8n-nodes-postgres-advanced-memory'
import MemoryPostgresAdvanced from 'n8n-nodes-postgres-advanced-memory'
Named export required; default import is not available.
WorkingMemoryTool
import { WorkingMemoryTool } from 'n8n-nodes-postgres-advanced-memory'
const WorkingMemoryTool = require('n8n-nodes-postgres-advanced-memory').WorkingMemoryTool
ESM module – require is not supported; use import or dynamic import().
PostgresAdvancedMemoryNodes
import { PostgresAdvancedMemoryNodes } from 'n8n-nodes-postgres-advanced-memory'
import { postgresAdvancedMemoryNodes } from 'n8n-nodes-postgres-advanced-memory'
Use PascalCase export name as defined in package.
PostgresAdvancedMemoryCredentials
import { PostgresAdvancedMemoryCredentials } from 'n8n-nodes-postgres-advanced-memory'
import { Credentials } from 'n8n-nodes-postgres-advanced-memory'
Exact named export; do not alias.

Shows how to import, configure credentials, set memory options, and optionally initialize WorkingMemoryTool.

import { MemoryPostgresAdvanced, WorkingMemoryTool } from 'n8n-nodes-postgres-advanced-memory'; // Example instantiation with credentials and configuration const memory = new MemoryPostgresAdvanced(); memory.setCredentials('postgres', { host: process.env.PG_HOST ?? 'localhost', port: parseInt(process.env.PG_PORT ?? '5432'), database: process.env.PG_DATABASE ?? 'n8n', user: process.env.PG_USER ?? 'postgres', password: process.env.PG_PASSWORD ?? '' }); // Configure the memory node memory.setNodeOptions({ schemaName: 'my_schema', tableName: 'chat_histories', sessionKey: '={{ $json.sessionId }}', contextWindowLength: 5, sessionEnabled: true, userIdEnabled: false, workingMemoryEnabled: false, semanticSearchEnabled: false }); // Optionally initialize WorkingMemoryTool const tool = new WorkingMemoryTool(); tool.setNodeOptions({ scope: 'thread', userId: '' }); export { memory, tool };
Debug
Known issues
gotchaWorking Memory Tool must be manually added and connected to the AI Agent if workingMemoryEnabled is true.
fix
Add a WorkingMemoryTool node to your workflow and connect it as a tool input to the AI Agent.
affects: >=1.0.0
gotchaThe table for chat histories is NOT automatically created if it already exists; ensure the schema and table do not conflict with existing objects.
fix
Use a unique schema name or table name, or manually drop the existing table before first run.
affects: >=1.0.0
breakingSession key default changed from $json.sessionId to ={{ $json.sessionId }} in v2.0. If your workflows used the old default, they will break.
fix
Update sessionKey option to the new expression syntax: '={{ $json.sessionId }}'.
affects: >=2.0.0 <3.0.0
deprecatedThe 'sessionEnabled' option is deprecated as of v2.3. Use separate sessionKey and metadata table configuration instead.
fix
Remove sessionEnabled and rely on sessionKey; if you need a metadata table, set up the separate session tracking options.
affects: >=2.3.0
gotchaSemantic search requires the pgvector extension on PostgreSQL; the node does not install it automatically.
fix
Run 'CREATE EXTENSION vector;' on your PostgreSQL database before enabling semantic search.
affects: >=2.0.0
Errors
Common errors & fixes
ER_CONNECTION_REFUSED: connect ECONNREFUSED 127.0.0.1:5432
PostgreSQL server is not running or credentials are incorrect.
fix
Start PostgreSQL service and verify connection parameters (host, port, user, password).
TypeError: Cannot read properties of undefined (reading 'setCredentials')
The node instance was not properly instantiated or imported as default instead of named export.
fix
Use 'import { MemoryPostgresAdvanced } from ...' (named import) and instantiate with 'new MemoryPostgresAdvanced()'.
Error: Relation "public.n8n_chat_histories" already exists
The table already exists but node expects a fresh table or different schema/table name.
fix
Use a different table name or schema, or drop the existing table: DROP TABLE IF EXISTS public.n8n_chat_histories CASCADE;
Error: function vector_distance_il2(unknown, unknown) does not exist
pgvector extension is not installed when semantic search is enabled.
fix
Connect to database and run: CREATE EXTENSION vector; then restart n8n and the workflow.
Upgrade
Version history
2.3.7latest on npm
Audit
Dependencies
n8n-workflowrequiredRequired as peer dependency for n8n node integration
Agent activity
10 hits · last 30 days
node
4
Resources
n8n-nodes-postgres-advanced-memory — npm install n8n-nodes-postgres-advanced-memory · libregistry