{
  "name": "My workflow",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        -272,
        -96
      ],
      "id": "f34252c7-9020-413f-876e-2fddd5e0e83d",
      "name": "When clicking \u2018Execute workflow\u2019"
    },
    {
      "parameters": {
        "mode": "raw",
        "jsonOutput": "{\n  \"name\": \"Anton\",\n  \"message\": \"\u041d\u0435 \u043c\u043e\u0433\u0443 \u0432\u043e\u0439\u0442\u0438 \u0432 \u043b\u0438\u0447\u043d\u044b\u0439 \u043a\u0430\u0431\u0438\u043d\u0435\u0442, \u0443\u0436\u0435 \u0442\u0440\u0435\u0442\u0438\u0439 \u0440\u0430\u0437 \u0441\u0431\u0440\u0430\u0441\u044b\u0432\u0430\u044e \u043f\u0430\u0440\u043e\u043b\u044c, \u043d\u0438\u0447\u0435\u0433\u043e \u043d\u0435 \u043f\u043e\u043c\u043e\u0433\u0430\u0435\u0442.\"\n}\n",
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [
        -288,
        80
      ],
      "id": "7b1b3c52-dd8a-43ad-86f4-6aa12f7519c2",
      "name": "Edit Fields"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://host.docker.internal:8000/analyze",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "=name",
              "value": "={{ $json.body.name }}"
            },
            {
              "name": "message",
              "value": "={{ $json.body.message }}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.5,
      "position": [
        208,
        -112
      ],
      "id": "f631a43f-4ef1-4e76-996b-2e2551f24f25",
      "name": "HTTP Request"
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 3
          },
          "conditions": [
            {
              "id": "14dd1690-8e1a-4676-8ed8-003fb49b1c30",
              "leftValue": "={{$json.valid}}",
              "rightValue": "true",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.3,
      "position": [
        432,
        -112
      ],
      "id": "e980c830-8c48-4438-99aa-d7a15894b5c7",
      "name": "If"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://host.docker.internal:11434/api/generate",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n  \"model\": \"qwen3:8b\",\n  \"prompt\": \"\u043f\u0440\u043e\u0430\u043d\u0430\u043b\u0438\u0437\u0438\u0440\u0443\u0439 \u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435 \u043a\u043b\u0438\u0435\u043d\u0442\u0430. \u0432\u0435\u0440\u043d\u0438 \u0442\u043e\u043b\u044c\u043a\u043e json \u0441 \u043f\u043e\u043b\u044f\u043c\u0438 category, priority (low|medium|high), sentiment (positive|neutral|negative), summary \u0438 action. \u043d\u0435 \u0434\u043e\u0431\u0430\u0432\u043b\u044f\u0439 markdown \u0438 \u043f\u043e\u044f\u0441\u043d\u0435\u043d\u0438\u044f. category \u0434\u043e\u043b\u0436\u043d\u0430 \u0431\u044b\u0442\u044c \u043a\u0440\u0430\u0442\u043a\u043e\u0439. summary \u2014 \u043e\u0434\u043d\u043e \u043f\u0440\u0435\u0434\u043b\u043e\u0436\u0435\u043d\u0438\u0435. action \u2014 \u043e\u0434\u043d\u043e \u043a\u043e\u043d\u043a\u0440\u0435\u0442\u043d\u043e\u0435 \u0434\u0435\u0439\u0441\u0442\u0432\u0438\u0435.\\n\\n\u043a\u043b\u0438\u0435\u043d\u0442: {{$json.name}}\\n\u043e\u0431\u0440\u0430\u0449\u0435\u043d\u0438\u0435: {{$json.message}}\",\n  \"stream\": false,\n  \"format\": \"json\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.5,
      "position": [
        720,
        -352
      ],
      "id": "a64c0a1b-0699-4593-ac69-1147a3709b70",
      "name": "Analyze with AI"
    },
    {
      "parameters": {
        "jsCode": "return items.map(item => {\n  const analysis = JSON.parse(item.json.response);\n\n  return {\n    json: {\n      ...analysis\n    }\n  };\n});"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        976,
        -352
      ],
      "id": "75fd8203-261e-4922-a9e0-04789e4f0382",
      "name": "Code in JavaScript"
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "91e5cf6f-51e4-4d5a-880a-5a65de88673f",
              "name": "name",
              "value": "={{ $json.data.name }}",
              "type": "string"
            },
            {
              "id": "3857f9da-bce0-4d60-a3fc-9a3c57a24b47",
              "name": "message",
              "value": "={{ $json.data.message }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.5,
      "position": [
        720,
        -144
      ],
      "id": "cef29103-17b1-4552-8259-f567277a3087",
      "name": "Save requests"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        1152,
        -160
      ],
      "id": "379f716c-f87b-4eec-a8a0-095d8313ca83",
      "name": "Merge"
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "request-analyzer",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -256,
        -304
      ],
      "id": "07ec8d6d-7830-47ea-8ce2-1ab408558fd4",
      "name": "Webhook"
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={\n  \"category\": \"{{ $json.category }}\",\n  \"priority\": \"{{ $json.priority }}\",\n  \"sentiment\": \"{{ $json.sentiment }}\",\n  \"summary\": \"{{ $json.summary }}\",\n  \"action\": \"{{ $json.action }}\",\n  \"name\": \"{{ $json.name }}\",\n  \"message\": \"{{ $json.message }}\"\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        2240,
        64
      ],
      "id": "5901a0f2-1e2f-4bb4-b878-f2bce0fe8f3a",
      "name": "Respond to Webhook"
    },
    {
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      category: $json.category,\n      priority: $json.priority,\n      sentiment: $json.sentiment,\n      summary: $json.summary,\n      action: $json.action,\n      name: $json.name,\n      message: $json.message\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1872,
        0
      ],
      "id": "1054ae4e-4fd3-4064-800f-245225c6d420",
      "name": "Code in JavaScript1"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "http://python:8000/requests",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "name",
              "value": "={{$json.name}}"
            },
            {
              "name": "message",
              "value": "={{$json.message}}"
            },
            {
              "name": "text_length",
              "value": "={{$json.text_length}}"
            },
            {
              "name": "word_count",
              "value": "={{$json.word_count}}"
            },
            {
              "name": "category",
              "value": "={{$json.category}}"
            },
            {
              "name": "priority",
              "value": "={{$json.priority}}"
            },
            {
              "name": "sentiment",
              "value": "={{$json.sentiment}}"
            },
            {
              "name": "summary",
              "value": "={{$json.summary}}"
            },
            {
              "name": "action",
              "value": "={{$json.action}}"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.5,
      "position": [
        1424,
        96
      ],
      "id": "62580bf3-9d11-47e5-96ff-63a02aea19dd",
      "name": "HTTP Request1"
    },
    {
      "parameters": {
        "mode": "combine",
        "combineBy": "combineByPosition",
        "options": {}
      },
      "type": "n8n-nodes-base.merge",
      "typeVersion": 3.2,
      "position": [
        1632,
        -64
      ],
      "id": "70eaeb4e-68b1-42d8-9d24-50233d8da5a0",
      "name": "Merge1"
    },
    {
      "parameters": {
        "jsCode": "return [\n  {\n    json: {\n      name: $json.name,\n      message: $json.message,\n      text_length: $json.message.length,\n      word_count: $json.message.trim().split(/\\s+/).length,\n      category: $json.category,\n      priority: $json.priority,\n      sentiment: $json.sentiment,\n      summary: $json.summary,\n      action: $json.action\n    }\n  }\n];"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1232,
        96
      ],
      "id": "44cd58bb-80fa-4cfe-8bd7-d74bd6274355",
      "name": "Prepare DB Request"
    }
  ],
  "connections": {
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        []
      ]
    },
    "Edit Fields": {
      "main": [
        []
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If": {
      "main": [
        [
          {
            "node": "Save requests",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Analyze with AI": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save requests": {
      "main": [
        [
          {
            "node": "Analyze with AI",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          },
          {
            "node": "Prepare DB Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript1": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request1": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Code in JavaScript1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare DB Request": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": true,
  "settings": {
    "executionOrder": "v1",
    "binaryMode": "separate",
    "availableInMCP": false
  },
  "versionId": "36fab631-29cc-4134-903a-735fc17c76a5",
  "nodeGroups": [],
  "id": "IVgb6AWum4YcVZBO",
  "tags": []
}