Documentation Index
Fetch the complete documentation index at: https://docs.memanto.ai/llms.txt
Use this file to discover all available pages before exploring further.
n8n + Memanto
Add persistent memory to your n8n workflows using Memanto’s REST API.
n8n workflows are stateless by default — each execution starts fresh. With Memanto, you can store context from one workflow run and recall it in future runs, giving your automations a memory that grows over time.
How It Works
n8n Workflow -> HTTP Request nodes -> Memanto Server -> Moorcheh.ai
Memanto exposes a simple REST API. In n8n, you call it using the built-in HTTP Request node — no custom code or plugins required.
Memanto authenticates with Moorcheh on the server using MOORCHEH_API_KEY. n8n nodes do not send an Authorization header. The only header you pass from n8n is X-Session-Token for memory operations.
Prerequisites
- n8n (self-hosted or cloud)
- Memanto server accessible from your n8n instance, with
MOORCHEH_API_KEY configured in its environment
Step 1: Start Memanto Server
On your server or locally:
export MOORCHEH_API_KEY=your_moorcheh_key
pip install memanto
memanto serve
If n8n is running in the cloud or Docker, expose Memanto via a public URL or use a tunnel like ngrok.
Core Workflow Patterns
Pattern 1: Activate Session + Remember
Use this at the start of a workflow to open a session and store context.
Node 1 — Activate Session (HTTP Request)
| Field | Value |
|---|
| Method | POST |
| URL | http://your-memanto-server:8000/api/v2/agents/n8n-agent/activate |
| Authentication | None |
This returns a session_token. Reference it in later nodes via:
{{ $node["Activate Session"].json.session_token }}
Node 2 — Remember (HTTP Request)
| Field | Value |
|---|
| Method | POST |
| URL | http://your-memanto-server:8000/api/v2/agents/n8n-agent/remember |
| Headers | X-Session-Token: {{ $node["Activate Session"].json.session_token }} |
| JSON Body | { "content": "{{ $json.message }}", "type": "fact" } |
Pattern 2: Recall Context
Retrieve relevant memories before making an LLM call or sending a response.
Node — Recall (HTTP Request)
| Field | Value |
|---|
| Method | POST |
| URL | http://your-memanto-server:8000/api/v2/agents/n8n-agent/recall |
| Headers | X-Session-Token: {{ $node["Activate Session"].json.session_token }} |
| JSON Body | { "query": "{{ $json.userMessage }}", "limit": 5 } |
The response contains a memories array. Access the first result with:
{{ $json.memories[0].content }}
Or join all results into a single string using a Code node:
const memories = $input.first().json.memories || [];
return [{ json: { context: memories.map(m => `- ${m.content}`).join("\n") } }];
Pattern 3: AI-Powered Answer from Memory
Let Memanto answer a question directly using its built-in RAG:
Node — Answer (HTTP Request)
| Field | Value |
|---|
| Method | POST |
| URL | http://your-memanto-server:8000/api/v2/agents/n8n-agent/answer |
| Headers | X-Session-Token: {{ $node["Activate Session"].json.session_token }} |
| JSON Body | { "question": "{{ $json.question }}" } |
Returns answer — a grounded response based on stored memories, no external LLM call needed.
Example: Customer Support Workflow
This workflow receives a customer message via webhook, recalls past context, and sends a personalized reply.
[Webhook] → [Activate Session] → [Recall Context] → [Format Prompt] → [OpenAI] → [Remember Exchange] → [Respond]
Webhook Node — receives:
{ "customer_id": "cust_123", "message": "I need help with my order" }
Activate Session — POST /api/v2/agents/{{ $json.customer_id }}/activate
Using the customer ID as the agent ID gives each customer their own isolated memory.
Recall Context — POST /api/v2/agents/{{ $json.customer_id }}/recall with body { "query": "{{ $json.message }}", "limit": 5 }
Code Node — Format Prompt
const memories = $input.first().json.memories || [];
const context = memories.length
? memories.map(m => `- ${m.content}`).join("\n")
: "No prior context.";
return [{
json: {
prompt: `Customer history:\n${context}\n\nCustomer: ${$("Webhook").item.json.message}\nAgent:`
}
}];
OpenAI Node — use the formatted prompt to generate a reply.
Remember Exchange — POST /api/v2/agents/.../remember with body { "content": "<message + reply>", "type": "fact" }
Memory Types in n8n
Set the type field in the Remember body to categorize what you store:
| Type | When to use |
|---|
fact | Objective information about the user or entity |
preference | User likes, dislikes, or settings |
decision | Choices made during the workflow |
commitment | Promises or follow-up actions |
event | Things that happened (order placed, ticket opened) |
error | Issues or failures to avoid repeating |
Sessions in Long-Running Workflows
Memanto auto-renews sessions that are near expiry on memory requests, so most workflows can simply reuse the token from the activation step. There is no separate /session/extend endpoint.
For scheduled or long-lived workflows, the simplest pattern is to activate a fresh session at the start of each run rather than persisting the token between executions:
[Trigger] → [Activate Session] → ...remaining nodes use the new token...
If a request returns 401 Unauthorized, re-run the Activate Session node and continue with the new token.
Next Steps