{
  "name": "RAG Assistant - Query",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "rag-query",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "webhook-rag",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [
        240,
        300
      ]
    },
    {
      "parameters": {
        "functionCode": "const inputItem = $input.item;\nconst body = inputItem?.json?.body || inputItem?.json || {};\nconst q = body.query || body.question || body.q;\n\nif (!q || typeof q !== 'string') {\n  throw new Error('\u041f\u043e\u043b\u0435 query (\u0438\u043b\u0438 question, q) \u043e\u0431\u044f\u0437\u0430\u0442\u0435\u043b\u044c\u043d\u043e. \u041f\u0440\u0438\u043c\u0435\u0440: {\"query\": \"\u0427\u0442\u043e \u0442\u0430\u043a\u043e\u0435 RAG?\"}');\n}\n\nreturn [{ json: { query: String(q).trim() } }];"
      },
      "id": "parse-query",
      "name": "Parse Query",
      "type": "n8n-nodes-base.function",
      "typeVersion": 1,
      "position": [
        460,
        300
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $env.RAG_API_URL || 'http://localhost:8000' }}/query",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ { \"query\": $json.query } }}",
        "options": {}
      },
      "id": "http-rag-query",
      "name": "RAG API: Query",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.1,
      "position": [
        680,
        300
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ $input.item.json }}",
        "options": {}
      },
      "id": "respond-webhook",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1,
      "position": [
        900,
        300
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Parse Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Query": {
      "main": [
        [
          {
            "node": "RAG API: Query",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RAG API: Query": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 0,
  "updatedAt": "2025-01-01T00:00:00.000Z",
  "versionId": "1"
}