{
 "name": "[노드 한 장] Simple Memory · 같은 세션에서 앞말 기억하기",
 "nodes": [
  {
   "id": "manual",
   "name": "Run manually",
   "type": "n8n-nodes-base.manualTrigger",
   "typeVersion": 1,
   "position": [
    0,
    0
   ],
   "parameters": {}
  },
  {
   "id": "prepare",
   "name": "Prepare sample",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    240,
    0
   ],
   "parameters": {
    "jsCode": "// 직접 작성한 샘플 대화: 1회 실행 후 아래 chatInput을 질문으로 바꿔 같은 세션에서 실행하세요.\nreturn [{json:{sample:true,sessionId:'TEST_SESSION_A',sessionLabel:'TEST_SESSION_A',turn:1,chatInput:\"가상 프로젝트 별칭은 '달빛배'야. 기억해 줘.\"}}];"
   }
  },
  {
   "id": "agent",
   "name": "AI Agent",
   "type": "@n8n/n8n-nodes-langchain.agent",
   "typeVersion": 3.1,
   "position": [
    480,
    0
   ],
   "parameters": {
    "promptType": "define",
    "text": "={{ $json.chatInput }}",
    "options": {
     "systemMessage": "당신은 가상 프로젝트 별칭을 기억하는 실습 도우미입니다. 기억해 달라는 요청에는 '기억했습니다.'라고만 답하세요. 별칭을 질문받으면 이전 대화에 명시된 별칭만 그대로 답하세요. 이전 대화나 현재 입력에 별칭이 없다면 추측하지 말고 '기억된 별칭이 없습니다.'라고만 답하세요. 한국어로 간결하게 답하세요.",
     "maxIterations": 2
    }
   }
  },
  {
   "id": "model",
   "name": "OpenAI Chat Model",
   "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
   "typeVersion": 1.3,
   "position": [
    400,
    240
   ],
   "parameters": {
    "model": {
     "__rl": true,
     "mode": "id",
     "value": "gpt-4.1-mini"
    },
    "responsesApiEnabled": false,
    "options": {
     "temperature": 0,
     "maxTokens": 150
    }
   }
  },
  {
   "id": "memory",
   "name": "Simple Memory",
   "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
   "typeVersion": 1.3,
   "position": [
    620,
    240
   ],
   "parameters": {
    "sessionIdType": "customKey",
    "sessionKey": "={{ $json.sessionId }}",
    "contextWindowLength": 5
   }
  },
  {
   "id": "show",
   "name": "Show safe result",
   "type": "n8n-nodes-base.set",
   "typeVersion": 3.4,
   "position": [
    760,
    0
   ],
   "parameters": {
    "assignments": {
     "assignments": [
      {
       "id": "a",
       "name": "session",
       "type": "string",
       "value": "={{ $('Prepare sample').first().json.sessionLabel }}"
      },
      {
       "id": "b",
       "name": "turn",
       "type": "number",
       "value": "={{ $('Prepare sample').first().json.turn }}"
      },
      {
       "id": "c",
       "name": "sample_message",
       "type": "string",
       "value": "={{ $('Prepare sample').first().json.chatInput }}"
      },
      {
       "id": "d",
       "name": "ai_output",
       "type": "string",
       "value": "={{ $json.output }}"
      },
      {
       "id": "e",
       "name": "sample",
       "type": "boolean",
       "value": true
      }
     ]
    },
    "options": {}
   }
  }
 ],
 "connections": {
  "Run manually": {
   "main": [
    [
     {
      "node": "Prepare sample",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Prepare sample": {
   "main": [
    [
     {
      "node": "AI Agent",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "OpenAI Chat Model": {
   "ai_languageModel": [
    [
     {
      "node": "AI Agent",
      "type": "ai_languageModel",
      "index": 0
     }
    ]
   ]
  },
  "Simple Memory": {
   "ai_memory": [
    [
     {
      "node": "AI Agent",
      "type": "ai_memory",
      "index": 0
     }
    ]
   ]
  },
  "AI Agent": {
   "main": [
    [
     {
      "node": "Show safe result",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {
  "executionOrder": "v1"
 },
 "meta": {
  "templateCredsSetupCompleted": false,
  "source": "datapopcorn.ai/workflow/nodes"
 }
}