The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "Long Term Memory Demo",
"nodes": [
{
"parameters": {
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"typeVersion": 1.1,
"position": [
80,
-40
],
"id": "76da89fb-11ce-4030-aa38-cf436afecbbc",
"name": "When chat message received"
},
{
"parameters": {
"options": {
"systemMessage": "=# ROLE\nYou are a friendly AI assistant.\nYou are currently talking to Leon.\n\n# RULES\nWhen a user sends a new message, decide if the user provided any noteworthy information that should be stored in memory. If so, call the Save Memory tool to store this information in memory. DO NOT inform the user that this information was stored in memory. Simply continue to answer the question or executing the next tasks.\n\n# Tools\n## Save Memory\nUse this tool to store information about the user. Extract and summarize interesting information from the user message and pass it to this tool.\n\n# Memories\nHere are the last noteworthy memories that you've collected from the user, including the date and time this information was collected.\n!! IMPORTANT!\nThink carefully about your responses and take the user's preferences into account!\nAlso consider the date and time that a memory was shared in order to respond with the most up to date information.\n\n{{ $json.memories.toJsonString() }}"
}
},
"type": "@n8n/n8n-nodes-langchain.agent",
"typeVersion": 1.7,
"position": [
800,
-20
],
"id": "8c867c28-6514-4869-be8d-752738941f07",
"name": "AI Agent"
},
{
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"typeVersion": 1.2,
"position": [
740,
200
],
"id": "3e8c5070-9060-41dd-87a8-8e8c88735c6a",
"name": "OpenAI Chat Model",
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "create",
"base": {
"__rl": true,
"value": "appMej2JQwZJz80ME",
"mode": "list",
"cachedResultName": "Memory",
"cachedResultUrl": "https://airtable.com/appMej2JQwZJz80ME"
},
"table": {
"__rl": true,
"value": "tblbloLzD6LHNuvxh",
"mode": "list",
"cachedResultName": "Memory",
"cachedResultUrl": "https://airtable.com/appMej2JQwZJz80ME/tblbloLzD6LHNuvxh"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"Memory": "={{ $fromAI('memory', 'Summary of memory') }}",
"User": "Leon"
},
"matchingColumns": [],
"schema": [
{
"id": "Memory",
"displayName": "Memory",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": false,
"removed": false
},
{
"id": "User",
"displayName": "User",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": false,
"removed": false
},
{
"id": "Created",
"displayName": "Created",
"required": false,
"defaultMatch": false,
"canBeUsedToMatch": true,
"display": true,
"type": "string",
"readOnly": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.airtableTool",
"typeVersion": 2.1,
"position": [
1020,
200
],
"id": "7c1f5d5b-7ff6-4b14-b7f1-569c18ffa7c7",
"name": "Save Memory",
"credentials": {
"airtableTokenApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "search",
"base": {
"__rl": true,
"value": "appMej2JQwZJz80ME",
"mode": "list",
"cachedResultName": "Memory",
"cachedResultUrl": "https://airtable.com/appMej2JQwZJz80ME"
},
"table": {
"__rl": true,
"value": "tblbloLzD6LHNuvxh",
"mode": "list",
"cachedResultName": "Memory",
"cachedResultUrl": "https://airtable.com/appMej2JQwZJz80ME/tblbloLzD6LHNuvxh"
},
"filterByFormula": "({User} = 'Leon')",
"options": {
"fields": [
"Memory",
"Created"
]
},
"sort": {
"property": [
{
"field": "Created"
}
]
}
},
"type": "n8n-nodes-base.airtable",
"typeVersion": 2.1,
"position": [
260,
100
],
"id": "23dd8996-4d3f-454f-8e41-e084ad7812a1",
"name": "Get Memories",
"alwaysOutputData": true,
"credentials": {
"airtableTokenApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"aggregate": "aggregateAllItemData",
"destinationFieldName": "memories",
"include": "specifiedFields",
"fieldsToInclude": "createdTime, Memory",
"options": {}
},
"type": "n8n-nodes-base.aggregate",
"typeVersion": 1,
"position": [
420,
100
],
"id": "d15e2921-0c03-4208-95dd-036f4b36f838",
"name": "Aggregate"
},
{
"parameters": {
"mode": "combine",
"combineBy": "combineAll",
"options": {}
},
"type": "n8n-nodes-base.merge",
"typeVersion": 3,
"position": [
620,
-20
],
"id": "d8c80615-c1d0-4ce9-9133-d7fa4d5bc3a6",
"name": "Merge"
},
{
"parameters": {
"contextWindowLength": 50
},
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"typeVersion": 1.3,
"position": [
880,
200
],
"id": "cb4d0556-7e88-47af-9ac2-04cca44b586d",
"name": "Window Buffer Memory"
}
],
"connections": {
"When chat message received": {
"main": [
[
{
"node": "Get Memories",
"type": "main",
"index": 0
},
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Save Memory": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
},
"Get Memories": {
"main": [
[
{
"node": "Aggregate",
"type": "main",
"index": 0
}
]
]
},
"Aggregate": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 1
}
]
]
},
"Merge": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"Window Buffer Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
}
},
"active": false,
"settings": {
"executionOrder": "v1"
},
"versionId": "7c2391c9-f24d-41fe-ade5-4931f168527a",
"meta": {
"templateCredsSetupCompleted": true
},
"id": "L563aWxIUBWmrdAd",
"tags": []
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
airtableTokenApiopenAiApi
About this workflow
Long Term Memory Demo. Uses chatTrigger, agent, lmChatOpenAi, airtableTool. Chat trigger; 8 nodes.
Source: https://github.com/Zie619/n8n-workflows — original creator credit. Request a take-down →