{
  "name": "Vorlux AI | Knowledge Capture",
  "nodes": [
    {
      "id": "4b478b78-b7e8-418c-8a59-8cf0c532c41a",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        220,
        300
      ],
      "webhookId": "95e7a75a-391d-4bb9-8269-c79daae63579",
      "parameters": {
        "httpMethod": "POST",
        "path": "knowledge-capture",
        "options": {
          "responseMode": "lastNode"
        }
      }
    },
    {
      "id": "30e56f78-7fb5-44c2-a27f-e2fed100d3b9",
      "name": "Process",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        460,
        300
      ],
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const d=$input.first().json.body||$input.first().json;\nreturn [{json:{sessionId:d.sessionId||'',content:d.content||d.transcript||'',title:d.title||'Stream Knowledge',tags:d.tags||[]}}];"
      }
    },
    {
      "id": "4ea42416-234d-498d-b488-f393150d615c",
      "name": "AI Extract",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        700,
        200
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/orchestrator/execute",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"agentId\":\"docs-librarian\",\"action\":\"extract_knowledge\",\"params\":{\"content\":{{ JSON.stringify($json.content.substring(0,5000)) }}}}",
        "options": {
          "timeout": 60000
        }
      }
    },
    {
      "id": "a396d813-c65b-4e13-a37b-44fd1ce5ea2b",
      "name": "Save KB",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        700,
        400
      ],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/kb/articles",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"title\":\"{{ $node.Process.json.title }}\",\"content\":\"{{ $json.data?.result }}\",\"tags\":{{ JSON.stringify($node.Process.json.tags) }}}",
        "options": {
          "timeout": 15000
        }
      }
    },
    {
      "id": "871926d3-445b-4bb4-a7b9-3355f49717ea",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        940,
        300
      ],
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ JSON.stringify({ok:true}) }}"
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Process",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process": {
      "main": [
        [
          {
            "node": "AI Extract",
            "type": "main",
            "index": 0
          },
          {
            "node": "Save KB",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Extract": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save KB": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "saveExecutionProgress": true
  }
}