Mem0 Chat Memory
AI-generatedSummary
Loads and optionally stores chat conversation history via Mem0, scoped by a session key, and supplies it as memory for AI agents.
Inputs
- authType — Authentication method for Mem0 API; either 'cloud' (managed service) or 'selfHosted' (self‑hosted instance).
- sessionIdType — How to determine the session identifier: read it automatically from the incoming item or provide a custom key via sessionKey.
- sessionKey — Custom session identifier used when sessionIdType is 'customKey'; can include expressions like ={{ $json.message.chat.id }}.
- userId — Optional user ID to scope memories to a specific user.
- agentId — Optional agent ID to scope memories to a specific agent.
- contextWindowLength — Number of recent message exchanges to load into context (each exchange = 2 messages); 0 loads all.
Output shape
A single n8n item on the 'ai_memory' output containing the loaded memory data (messages array and optional metadata).
If no messages are stored or contextWindowLength is 0 the output may be empty; errors are propagated as failed executions rather than returning an error envelope.
Examples
Example 1: Default cloud auth with automatic session from incoming runId
authType: cloud; sessionIdType: fromInput (default); sessionKey empty; all other fields default.
Example 2: Self‑hosted instance with custom session key derived from chat ID
authType: selfHosted; sessionIdType: customKey; sessionKey: ={{ $json.message.chat.id }}; userId empty; agentId empty; contextWindowLength 5.