Overview
Introduction to Workflow Connectors
Workflow Tool Connectors allow you to easily integrate Mem0's long-term memory layer into popular multi-agent frameworks, automation tools, and developer environments. By connecting Mem0 to tools like LangChain, n8n, OpenClaw, and Pi-Agent, your AI agents gain the ability to recall user preferences, store durable facts across sessions, and maintain context over time without starting from scratch.
Note
Depending on the framework you choose, you can use either the cloud-based Mem0 Platform or a self-hosted open-source backend.
Supported Frameworks and Connectors
Mem0 provides dedicated modules and plugins for various platforms and workflow engines.
| Integration / Framework | Connector Type | Supported Capabilities |
|---|---|---|
| LangChain | Community Memory Class (Mem0Memory) | Chat history management, semantic memory search, and automatic context injection. |
| n8n | Community Node (@mem0/n8n-nodes-mem0) | Add, search, get, update, and delete memories within automated workflows and AI Agent nodes. |
| OpenClaw | Plugin (openclaw-mem0) | Auto-recall, auto-capture, multi-agent isolation, CLI controls, and platform/OSS dual mode. |
| Pi-Agent / Other Coding Agents | Extension / Plugin | Tool registration (mem0_memory), project/session/global scoping, and telemetry tracking. |
Sources: LangChain integration (mem0-ts/src/community/src/integrations/langchain/mem0.ts), n8n node description (integrations/n8n-nodes-mem0/nodes/Mem0/Mem0.node.ts), OpenClaw plugin (integrations/openclaw/index.ts), Pi-Agent extension (integrations/pi-agent-plugin/src/memory/tools.ts).
Connecting Mem0 to LangChain
LangChain Memory Integration Overview
The Mem0Memory class integrates Mem0 directly into LangChain chat models and conversation chains, managing memory storage and retrieval automatically.
Configuration and Setup
- Install the required Mem0 package in your TypeScript or JavaScript project.
- Initialize the
Mem0Memoryclass by providing your Mem0 API key and a session or user identifier. - Attach the memory instance to your LangChain conversation chain or chat model configuration.
import { Mem0Memory } from "@mem0/community";
import { ChatOpenAI } from "@langchain/openai";
import { ConversationChain } from "langchain/chains";
const memory = new Mem0Memory({
sessionId: "user123",
apiKey: "your-api-key",
memoryOptions: {
user_id: "user123",
run_id: "run123"
},
});
const model = new ChatOpenAI({
modelName: "gpt-4o-mini",
temperature: 0,
});
const chain = new ConversationChain({ llm: model, memory });Tip
You can toggle separateMessages in Mem0MemoryInput if you prefer receiving chat history as a list of separate messages containing a system message, rather than a single condensed human message.
Automating Workflows with n8n
n8n Community Node Overview
The Mem0 community node for n8n (@mem0/n8n-nodes-mem0) allows you to build automated workflows that interact with your long-term memory layer, making it fully compatible with n8n's AI Agent (Tools Agent) node.
Setting Up the Mem0 Node
- Add the Mem0 node to your n8n workflow canvas.
- Create new Mem0 API credentials by providing your API key and base URL (defaults to
https://api.mem0.ai). - Choose the Resource (Memory) and the desired Operation:
- Add: Extract and store memories from messages.
- Search: Search stored facts by meaning and semantic relevance.
- Get All: List or page through stored memories.
- Get / Update / Delete: Manage specific memories by their unique Memory ID.
Important
When using the Add operation, ensure you configure at least one entity identifier (such as User ID, Agent ID, Run ID, or App ID) so the system knows who owns the stored memory.
Integrating with OpenClaw
OpenClaw Plugin Overview
The OpenClaw Mem0 plugin brings persistent memory to OpenClaw agents, supporting both the Mem0 cloud platform and self-hosted open-source backends.
Key Features and CLI Initialization
- Auto-Recall & Auto-Capture: Automatically injects relevant memories before each agent turn and captures key conversation facts afterward.
- Per-Agent Isolation: Multi-agent setups automatically read and write from separate user identifier namespaces using session routing.
- Dual Mode: Configure for either cloud platform usage or self-hosted open-source deployments.
You can initialize and log into the OpenClaw Mem0 plugin using the command-line interface:
openclaw mem0 init --api-key <your-api-key>Supported authentication and provider configuration choices include:
- Mem0 Platform API Key: Authenticated via the
MEM0_API_KEYenvironment variable or--mem0-api-key. - Open Source with OpenAI: Self-hosted mode using OpenAI for language models and embeddings.
- OpenSource with Ollama: Fully local mode with no external API keys required.
Sources: OpenClaw plugin configuration (integrations/openclaw/openclaw.plugin.json).
Managing Scopes and Entities
Entity Scoping Overview
When working across multi-agent frameworks, proper scoping ensures that memories are retrieved by the correct user, agent, or project.
- User ID (
user_id): Identifies the human user who owns the memory. Essential for cross-session recall. - Agent ID (
agent_id): Partitions memories by specific AI agents in multi-agent environments. - Run ID / Session ID (
run_id): Isolates memories to a specific workflow execution run or chat session. - App ID (
app_id): Groups memories by project, repository, or application namespace.
Warning
Destructive operations like deleting all memories (delete_all_memories) will permanently erase data within the targeted scope. Always verify your scope parameters before executing wipe commands.
Related
On This Page
OverviewIntroduction to Workflow ConnectorsSupported Frameworks and ConnectorsConnecting Mem0 to LangChainLangChain Memory Integration OverviewConfiguration and SetupAutomating Workflows with n8nn8n Community Node OverviewSetting Up the Mem0 NodeIntegrating with OpenClawOpenClaw Plugin OverviewKey Features and CLI InitializationManaging Scopes and EntitiesEntity Scoping OverviewRelated