Skip to main content
doc0blade47/mem0documentation home
Sign in

n8n Workflow Nodes

Last updated Oct 11, 2026100% grounded
Relevant source files

The following files were used as context for generating this wiki page:

Overview

The Mem0 community node package for n8n integrates long-term memory capabilities into automated workflows and AI agent pipelines. By leveraging the Mem0 platform API, the node allows workflows to add, search, retrieve, update, and delete persistent memories across conversations with support for tool usage in AI nodes.

Sources: integrations/n8n-nodes-mem0/package.json:2-12, integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:20-41

Community Node Package Registration

Package Metadata and n8n Bindings

The @mem0/n8n-nodes-mem0 package identifies as an n8n community node package via its package.json manifest. The package requires Node.js >=20.15 and exposes an n8n configuration block that declares the node API version, compiled credential files, and compiled node files.

{
  "name": "@mem0/n8n-nodes-mem0",
  "version": "0.1.4",
  "engines": {
    "node": ">=20.15"
  },
  "n8n": {
    "n8nNodesApiVersion": 1,
    "credentials": [
      "dist/credentials/Mem0Api.credentials.js"
    ],
    "nodes": [
      "dist/nodes/Mem0/Mem0.node.js"
    ]
  }
}

Sources: integrations/n8n-nodes-mem0/package.json:2-3, integrations/n8n-nodes-mem0/package.json:24-26, integrations/n8n-nodes-mem0/package.json:43-51

Note

The n8n property in package.json dictates how the n8n runtime discovers compiled JavaScript assets under the dist/ directory rather than raw TypeScript source files.

Sources: integrations/n8n-nodes-mem0/package.json:43-51

Node Declaration and Categories

The node definition file Mem0.node.json registers the package identifier @mem0/n8n-nodes-mem0.mem0 with version 1.0 and codex version 1.0. It classifies the node under the AI category with a subcategory of Memory, and points to official documentation URLs for primary features and credentials.

Metadata PropertyValue / Target
Node Identifier@mem0/n8n-nodes-mem0.mem0
Node Version1.0
Codex Version1.0
CategoriesAI (Subcategory: Memory)
Primary Documentationhttps://docs.mem0.ai/integrations/n8n
Credential Documentationhttps://docs.mem0.ai/integrations/n8n

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.json:1-20

Entry Point Mechanics

The root entry point index.js acts as a placeholder module export for the package. Because n8n loads nodes and credentials directly via the paths declared in the n8n key of package.json, this entry point remains intentionally empty.

// n8n loads nodes and credentials via the "n8n" key in package.json.
// This entry point is intentionally empty.
module.exports = {};

Sources: integrations/n8n-nodes-mem0/index.js:1-3

Public Node Interface and Properties

Node Metadata and Connectivity

The Mem0 class implements the INodeType interface, exposing core descriptive metadata and connection capabilities used by the n8n runtime. The node is categorized under the transform group, operates on version 1, and displays a subtitle derived from the current operation and resource parameters ={{$parameter["operation"] + ": " + $parameter["resource"]}}. Its visual representation uses light and dark SVG icons (file:mem0.svg), and it supports execution as a tool (usableAsTool: true) inside n8n AI Agent nodes. The node accepts a single main input and produces a single main output, requiring the mem0Api credential for authentication.

description: INodeTypeDescription = {
	displayName: 'Mem0',
	name: 'mem0',
	icon: { light: 'file:mem0.svg', dark: 'file:mem0.svg' },
	group: ['transform'],
	version: 1,
	subtitle: '={{$parameter["operation"] + ": " + $parameter["resource"]}}',
	description: 'Add, search, and manage long-term memories with Mem0',
	defaults: {
		name: 'Mem0',
	},
	// Makes the node available to the AI Agent (Tools Agent) node.
	usableAsTool: true,
	inputs: [NodeConnectionTypes.Main],
	outputs: [NodeConnectionTypes.Main],
	credentials: [
		{
			name: 'mem0Api',
			required: true,
		},
	],

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:21-41

Note

Setting usableAsTool: true in the node description allows LLM agent workflows within n8n to discover and invoke Mem0 memory actions as callable tools without manual routing setup.

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:32-34

Supported Resources and Operations

The user interface exposes a primary Resource selector fixed to the memory value, alongside an Operation dropdown that dictates the action executed against the platform. Each operation maps to specific backend capabilities for managing long-term memories.

Operation NameValue IdentifierAction Description
AddaddExtract and store memories from messages
DeletedeleteDelete a single memory by ID
GetgetRetrieve a single memory by ID
Get ManygetAllList stored memories for an entity
SearchsearchSemantic search over stored memories
UpdateupdateUpdate the text or metadata of a memory

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:43-96

{
	displayName: 'Resource',
	name: 'resource',
	type: 'options',
	noDataExpression: true,
	options: [{ name: 'Memory', value: 'memory' }],
	default: 'memory',
},
{
	displayName: 'Operation',
	name: 'operation',
	type: 'options',
	noDataExpression: true,
	displayOptions: { show: { resource: ['memory'] } },
	options: [
		{
			name: 'Add',
			value: 'add',
			action: 'Add a memory',
			description: 'Extract and store memories from messages',
		},
		{
			name: 'Delete',
			value: 'delete',
			action: 'Delete a memory',
			description: 'Delete a single memory by ID',
		},
		{
			name: 'Get',
			value: 'get',
			action: 'Get a memory',
			description: 'Retrieve a single memory by ID',
		},
		{
			name: 'Get Many',
			value: 'getAll',
			action: 'Get many memories',
			description: 'List stored memories for an entity',
		},
		{
			name: 'Search',
			value: 'search',
			action: 'Search memories',
			description: 'Semantic search over stored memories',
		},
		{
			name: 'Update',
			value: 'update',
			action: 'Update a memory',
			description: 'Update the text or metadata of a memory',
		},
	],
	default: 'add',
},

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:43-96

Parameter Configuration Properties

The node properties define UI input fields conditionally displayed based on the selected resource and operation. For the add operation, users provide conversation messages with configurable roles (User, Assistant, System), a User ID string, a boolean Wait for Completion flag (defaulting to true), and additional fields. Additional fields include string identifiers (agent_id, app_id), custom categories (custom_categories), custom instructions (custom_instructions), and optional exclusion filters.

{
	displayName: 'Messages',
	name: 'messages',
	placeholder: 'Add Message',
	type: 'fixedCollection',
	typeOptions: { multipleValues: true },
	displayOptions: { show: { resource: ['memory'], operation: ['add'] } },
	default: {},
	description: 'The conversation messages to extract memories from',
	options: [
		{
			name: 'message',
			displayName: 'Message',
			values: [
				{
					displayName: 'Role',
					name: 'role',
					type: 'options',
					options: [
						{ name: 'User', value: 'user' },
						{ name: 'Assistant', value: 'assistant' },
						{ name: 'System', value: 'system' },
					],
					default: 'user',
				},
				{
					displayName: 'Content',
					name: 'content',
					type: 'string',
					typeOptions: { rows: 2 },
					default: '',
				},
			],
		},
	],
},
{
	displayName: 'User ID',
	name: 'userId',
	type: 'string',
	default: '',
	displayOptions: { show: { resource: ['memory'], operation: ['add'] } },
	description: 'Associate the memories with this user',
},
{
	displayName: 'Wait for Completion',
	name: 'waitForCompletion',
	type: 'boolean',
	default: true,
	displayOptions: { show: { resource: ['memory'], operation: ['add'] } },
	description:
		'Whether to poll until memory extraction finishes and return the resulting memories. Turn off to return immediately with the event ID.',
},
{
	displayName: 'Additional Fields',
	name: 'addFields',
	type: 'collection',
	placeholder: 'Add Field',
	default: {},
	displayOptions: { show: { resource: ['memory'], operation: ['add'] } },
	options: [
		{
			displayName: 'Agent ID',
			name: 'agent_id',
			type: 'string',
			default: '',
		},
		{
			displayName: 'App ID',
			name: 'app_id',
			type: 'string',
			default: '',
		},
		{
			displayName: 'Custom Categories',
			name: 'custom_categories',
			type: 'json',
			default: '',
			description:
				'Optional taxonomy for categorising extracted memories, as a JSON array of {category: description} objects',

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:99-190

For retrieval and management operations, the UI exposes pagination parameters (Page, Page Size, Return All), direct ID lookup fields (Memory ID), and update parameters (Text, Metadata (JSON)).

	{
		displayName: 'Page',
		name: 'page',
		type: 'number',
		typeOptions: { minValue: 1 },
		default: 1,
		displayOptions: {
			show: { resource: ['memory'], operation: ['getAll'], returnAll: [false] },
		},
	},
	{
		displayName: 'Page Size',
		name: 'pageSize',
		type: 'number',
		typeOptions: { minValue: 1 },
		default: 50,
		displayOptions: { show: { resource: ['memory'], operation: ['getAll'] } },
	},
 
	// ---- Get / Update / Delete (by ID) -------------------------------
	{
		displayName: 'Memory ID',
		name: 'memoryId',
		type: 'string',
		default: '',
		required: true,
		displayOptions: {
			show: { resource: ['memory'], operation: ['get', 'update', 'delete'] },
		},
	},
	{
		displayName: 'Text',
		name: 'text',
		type: 'string',
		default: '',
		displayOptions: { show: { resource: ['memory'], operation: ['update'] } },
		description: 'The new memory text',
	},
	{
		displayName: 'Metadata (JSON)',
		name: 'metadata',
		type: 'json',
		default: '',
		displayOptions: { show: { resource: ['memory'], operation: ['update'] } },
	},
],

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:322-367

Execution Routing and Operation Dispatch

Execution Loop Initialization

The execute method serves as the primary entry point for node execution within the n8n runtime, implementing the IExecuteFunctions interface. It retrieves input execution items via this.getInputData() and fetches authentication credentials for mem0Api. A local helper closure named request is constructed to execute authenticated HTTP methods against the base URL, which defaults to https://api.mem0.ai if unconfigured. Every outgoing request injects first-party usage attribution by attaching source: 'N8N' to the query parameters object.

async execute(this: IExecuteFunctions): Promise<INodeExecutionData[][]> {
	const items = this.getInputData();
	const returnData: INodeExecutionData[] = [];
	const credentials = await this.getCredentials('mem0Api');
	const baseUrl = (credentials.baseUrl as string) || 'https://api.mem0.ai';
 
	const request = async (
		method: IHttpRequestMethods,
		url: string,
		body?: IDataObject,
		qs?: IDataObject,
	): Promise<IDataObject> => {
		const options: IHttpRequestOptions = {
			method,
			url: `${baseUrl}${url}`,
			json: true,
			...(body ? { body } : {}),
			// First-party usage attribution: the backend reads `source` (same as OpenClaw).
			qs: { source: 'N8N', ...(qs ?? {}) },
		};
		return (await this.helpers.httpRequestWithAuthentication.call(
			this,
			'mem0Api',
			options,
		)) as IDataObject;
	};

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:370-395

Warning

The request helper automatically appends source: 'N8N' to all query strings; callers passing custom query parameters must ensure key collisions do not unintentionally override usage attribution.

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:376-395

Item Iteration and Operation Matching

Control flow iterates over each input item using a for loop, wrapping item-level execution in a try...catch block to handle runtime errors gracefully. For each item, the current operation identifier is retrieved via this.getNodeParameter('operation', i). When the operation equals add, the node extracts structured messages from the UI fixed collection and validates that at least one message is present. If no messages exist, a NodeOperationError is thrown with the corresponding item index.

for (let i = 0; i < items.length; i++) {
	try {
		const operation = this.getNodeParameter('operation', i) as string;
		let responseData: IDataObject | IDataObject[] = {};
 
		if (operation === 'add') {
			const messagesUi = this.getNodeParameter('messages.message', i, []) as IDataObject[];
			if (!messagesUi.length) {
				throw new NodeOperationError(this.getNode(), 'At least one message is required', {
					itemIndex: i,
				});
			}

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:397-408

The request body for memory addition is populated with mapped message roles and content, alongside an inference flag that defaults to true. Optional parameters such as user_id are conditionally attached to the payload if provided by the workflow configuration.

const addFields = this.getNodeParameter('addFields', i, {}) as IDataObject;
const body: IDataObject = {
	messages: messagesUi.map((m) => ({ role: m.role, content: m.content })),
	infer: addFields.infer !== undefined ? addFields.infer : true,
};
const userId = this.getNodeParameter('userId', i, '') as string;
if (userId) body.user_id = userId;

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:409-415

Entity Scoping and Filter Construction

Constructing Filter Criteria

The Mem0 node constructs entity scoping and query filter parameters using workflow node parameters fetched during execution. When configuring search, retrieval, or listing operations, parameters such as user identifiers, agent identifiers, application identifiers, run identifiers, and metadata filters are collected to scope requests against the Mem0 platform backend.

const userId = this.getNodeParameter('userId', i, '') as string;
if (userId) body.user_id = userId;

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:414-415

Note

Entity identifiers such as user_id, agent_id, app_id, and run_id act as primary boundaries for isolating long-term memory retrieval across distinct users and agent execution sessions.

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:414-415

Platform API Client Requests

HTTP Dispatch and Credentials

Communication with the Mem0 platform relies on credentials resolved through n8n's this.getCredentials('mem0Api') mechanism. The base URL defaults to https://api.mem0.ai if not specified in the credential configuration. The local request helper constructs options containing the HTTP method, the resolved endpoint URL, and JSON parsing rules, while injecting source: 'N8N' into query parameters for attribution tracking.

const credentials = await this.getCredentials('mem0Api');
const baseUrl = (credentials.baseUrl as string) || 'https://api.mem0.ai';
 
const request = async (
	method: IHttpRequestMethods,
	url: string,
	body?: IDataObject,
	qs?: IDataObject,
): Promise<IDataObject> => {
	const options: IHttpRequestOptions = {
		method,
		url: `${baseUrl}${url}`,
		json: true,
		...(body ? { body } : {}),
		// First-party usage attribution: the backend reads `source` (same as OpenClaw).
		qs: { source: 'N8N', ...(qs ?? {}) },
	};
	return (await this.helpers.httpRequestWithAuthentication.call(
		this,
		'mem0Api',
		options,
	)) as IDataObject;
};

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:373-395

Warning

The helper method executes requests using this.helpers.httpRequestWithAuthentication.call, which automatically signs outgoing payloads with the stored API key credentials bound to the mem0Api name.

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:390-394

Asynchronous Event Polling

Memory addition operations frequently run asynchronously on the platform backend, returning an event identifier and an initial status rather than immediate memory objects. When waitForCompletion is enabled, the workflow polls the platform status endpoint to resolve the long-running transaction.

// Poll settings for asynchronous (infer=true) memory addition.
const POLL_INTERVAL_MS = 1500;
const MAX_POLL_ATTEMPTS = 40; // ~60s ceiling
 

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:16-19

Polling uses a fixed interval and attempt ceiling to balance responsiveness against execution timeouts:

ConstantValueDescription
POLL_INTERVAL_MS1500Delay in milliseconds between consecutive poll status checks.
MAX_POLL_ATTEMPTS40Maximum number of poll requests before timing out (~60 seconds ceiling).

Sources: integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts:17-18

const pollEvent = async (z: ZObject, eventId: string): Promise<EventResponse> => {
	for (let attempt = 0; attempt < MAX_POLL_ATTEMPTS; attempt++) {
		const res = await z.request({ url: `/v1/event/${eventId}/`, method: 'GET' });
		const data = res.data as EventResponse;
		const status = data && data.status;
		if (status === 'SUCCEEDED') {
			return data;
		}
		if (status === 'FAILED') {
			const reason = (data && (data.error || data.message)) || 'unknown error';
			throw new z.errors.Error(`Mem0 memory event ${eventId} failed: ${reason}`, 'Mem0EventFailed', 400);
		}
		await new Promise((resolve) => setTimeout(resolve, POLL_INTERVAL_MS));
	}
	throw new z.errors.Error(
		`Timed out waiting for memory event ${eventId}. The add was accepted and is ` +
			`likely still completing on the server — a timeout here does not mean it failed.`,
		'Mem0Timeout',
		408,
	);
};

Sources: integrations/zapier-mem0/src/creates/add_memory.ts:8-28

Note

If polling exhausts MAX_POLL_ATTEMPTS, the operation throws a timeout error indicating that the memory addition was accepted and is still processing asynchronously on the server.

Sources: integrations/zapier-mem0/src/creates/add_memory.ts:22-27

Was this page helpful?