{
  "name": "n8n_workflow",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "on_message",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -1376,
        720
      ],
      "id": "55c1ec7f-3d1e-420f-bcee-f4eeff2e216a",
      "name": "Webhook1"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ {\n  reply: $json.output\n} }}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.4,
      "position": [
        -336,
        720
      ],
      "id": "b5c9e58d-c9aa-424a-912b-163eb8791408",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "61c4137a-299b-4ae0-98c6-933d32821633",
              "name": "sessionId",
              "value": "={{$json.body.caller}}",
              "type": "string"
            },
            {
              "id": "6da0822b-e05f-4e85-9f57-a03e841b4fea",
              "name": "chatInput",
              "value": "={{ $json.body.text }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        -1040,
        720
      ],
      "id": "c823ffe7-41af-4454-9739-079db9bce181",
      "name": "Edit Fields (Set)"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.3,
      "position": [
        -1376,
        496
      ],
      "id": "6fa5b7a2-13c0-4a69-9129-70e4cc4889ba",
      "name": "When chat message received"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://changeme:8099/call",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"callerId\": \"01234567\",\n  \"message\": \"{{$json.chatInput}}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        -1120,
        496
      ],
      "id": "9fc9a859-aead-4f05-8fd8-c5bde41bf76b",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "hasOutputParser": true,
        "options": {
          "systemMessage": ""
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2.2,
      "position": [
        -752,
        720
      ],
      "id": "c30f46a5-ef3a-4819-8453-b2832aaaf9da",
      "name": "AI Agent1",
      "executeOnce": true
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        -800,
        944
      ],
      "id": "a556388c-47bb-4a8e-af8c-05daea74f92b",
      "name": "OpenAI Chat Model1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "typeVersion": 1.3,
      "position": [
        -656,
        976
      ],
      "id": "787fb82f-9c5b-4bf2-a614-1a6e92f639b9",
      "name": "Simple Memory1"
    }
  ],
  "connections": {
    "Webhook1": {
      "main": [
        [
          {
            "node": "Edit Fields (Set)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Edit Fields (Set)": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory1": {
      "ai_memory": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "94c5b42e-5b2e-4fbd-8730-9c636023273b",
  "id": "XYfcLjTGIIZc3k0x",
  "tags": []
}