Files
mem0/docs/integrations/n8n.mdx
T
kartik-mem0 a8e2a49209 fix(n8n): escape ids in URLs, add agent/run filters, run tests in CI
Three review findings on the Mem0 n8n node:

- Memory IDs and event IDs were interpolated raw into request paths, so a
  value containing / or .. could reach a different endpoint than intended.
  Wrap all four sites in encodeURIComponent.

- Search and Get Many could only filter by user_id, leaving agent- and
  run-scoped memories unreachable from the node. Both now accept User ID,
  Agent ID, and Run ID. Multiple ids combine with OR because Mem0 indexes
  entities separately and an AND across them matches nothing. User ID is
  no longer marked required; the node still fails with a clear message
  when all three are empty, rather than letting the API return a raw 400.

- n8n-nodes-mem0-checks.yml ran lint and build but never the jest suite,
  so the tests could rot unnoticed. Add a test job matching the layout of
  pi-agent-plugin-checks.yml.

Tests cover flat single-entity filters, the OR combination, agent-only
listing, the empty-entity guard on both operations, and id escaping in
the get/delete/poll URLs. Docs and README document the new fields and the
OR semantics.
2026-07-29 22:02:13 +05:30

94 lines
4.0 KiB
Plaintext

---
title: n8n
description: "Add long-term memory to n8n workflows and AI Agents with the Mem0 community node, no code required."
---
The [`@mem0/n8n-nodes-mem0`](https://www.npmjs.com/package/@mem0/n8n-nodes-mem0) community node brings [Mem0](https://mem0.ai) memory to [n8n](https://n8n.io). Add, search, and manage long-term memories inside any workflow, and use it as a tool for the n8n AI Agent.
## Overview
The node wraps the hosted Mem0 REST API and supports six operations on the **Memory** resource:
| Operation | Endpoint |
| --- | --- |
| **Add** | `POST /v3/memories/add/` |
| **Search** | `POST /v3/memories/search/` |
| **Get** | `GET /v1/memories/{id}/` |
| **Get Many** | `POST /v3/memories/` |
| **Update** | `PUT /v1/memories/{id}/` |
| **Delete** | `DELETE /v1/memories/{id}/` |
It is marked `usableAsTool`, so the n8n AI Agent (Tools Agent) can call it directly to remember and recall information.
## Installation
Install it like any n8n community node:
1. In n8n, go to **Settings → Community Nodes → Install**.
2. Enter `@mem0/n8n-nodes-mem0` and confirm.
The node then appears in the nodes panel under the AI category.
## Authentication
Create a **Mem0 API** credential in n8n:
- **API Key**: from the <a href="https://app.mem0.ai/dashboard/api-keys?utm_source=oss&utm_medium=integration-n8n" rel="nofollow">Mem0 API Key dashboard</a>. Sent as `Authorization: Token <key>`.
- **Base URL**: defaults to `https://api.mem0.ai`.
## Operations
### Add
Extracts and stores memories from one or more messages. Provide at least one entity id (**User ID**, or **Agent ID** / **Run ID** in Additional Fields); the node validates this before calling the API.
Additional Fields also expose:
| Field | Purpose |
| --- | --- |
| **Metadata (JSON)** | Arbitrary JSON attached to each extracted memory |
| **Infer** | On by default. Turn off to store messages verbatim instead of running LLM extraction |
| **Custom Instructions** | Free-text guidance steering what the extractor keeps or ignores, for this call |
| **Custom Categories** | JSON array of `{category: description}` objects, replacing the project-level catalog for this call |
Extraction is asynchronous. **Wait for Completion** (on by default) polls the event until it finishes and returns the resulting memories; turn it off to return immediately with the event ID.
### Search
Semantic search over stored memories. Provide a **Query**, at least one entity id, and an optional **Limit**.
### Get Many
Lists stored memories for the entity ids you supply. Turn on **Return All** to page through every memory automatically; leave it off to fetch a single **Page**. **Page Size** applies either way.
### Entity filters on Search and Get Many
Both operations take **User ID**, **Agent ID**, and **Run ID**. At least one is required (the API rejects a query with no entity scope), and the node fails with a clear message before making the call if you leave all three empty.
Supply several and they are combined with **OR**, so the result set is the union of the three scopes:
```json
{ "OR": [{ "user_id": "alice" }, { "agent_id": "support-bot" }] }
```
This is deliberate. Mem0 indexes each entity separately, so an `AND` across `user_id` and `agent_id` matches nothing even when a memory was written with both. To narrow rather than widen, run one operation per entity id.
### Get / Update / Delete
Operate on a single memory by **Memory ID**. Update accepts new **Text** and/or **Metadata (JSON)**.
## Choosing a `userId`
The `userId` is a stable string you choose to identify whose memories these are. It is not looked up in the dashboard. Common choices are your app's internal user ID, an email, or a UUID. Use the same value across Add, Search, and Get Many so recall works.
<CardGroup cols={2}>
<Card title="Zapier Integration" icon="bolt" href="/integrations/zapier">
Add memory to Zaps across thousands of apps
</Card>
<Card title="Flowise Integration" icon="blocks" href="/integrations/flowise">
Add memory to Flowise chatflows
</Card>
</CardGroup>
<Snippet file="star-on-github.mdx" />