{
  "name": "Nodbot - Ollama local AI summary",
  "nodes": [
    {
      "parameters": {
        "path": "ollama-local-ai-summary",
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "id": "a5a77d45-8f1a-4b96-a0ce-5232f4594eca",
      "name": "Webhook input",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        260
      ]
    },
    {
      "parameters": {
        "jsCode": "const src = $json.body ?? $json;\nconst text = String(src.text ?? '').replace(/<[^>]*>/g, ' ').replace(/\\s+/g, ' ').trim();\nif (text.length < 80) throw new Error('Text is too short for useful summary');\nif (text.length > 60000) throw new Error('Text is too long: split before workflow');\n\nconst maxChunk = 5500;\nconst chunks = [];\nfor (let i = 0; i < text.length; i += maxChunk) {\n  chunks.push(text.slice(i, i + maxChunk));\n}\n\nconst prompt = `Сделай краткую деловую сводку на русском. Верни JSON: summary, facts, action_items, risks. Не добавляй факты, которых нет в тексте.\\n\\nТекст:\\n${chunks[0]}`;\n\nreturn [{\n  json: {\n    source_id: String(src.source_id ?? 'unknown'),\n    source_type: String(src.source_type ?? 'text'),\n    model: src.model ?? 'qwen2.5:7b-instruct',\n    ollama_body: { model: src.model ?? 'qwen2.5:7b-instruct', prompt, stream: false, options: { temperature: 0.2 } },\n    chunk_count: chunks.length,\n    audit_key: `ollama-summary:${src.source_id ?? Date.now()}`\n  }\n}];"
      },
      "id": "2bb4f4d0-3a4d-4646-9e02-5175e7e34b66",
      "name": "Normalize and chunk text",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        280,
        260
      ]
    },
    {
      "parameters": {},
      "id": "450ff618-70fe-4b23-821a-d5f488e91e03",
      "name": "Call Ollama generate",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        560,
        260
      ]
    },
    {
      "parameters": {
        "jsCode": "const src = $json.body ?? $json;\nconst text = String(src.text ?? '').replace(/<[^>]*>/g, ' ').replace(/\\s+/g, ' ').trim();\nif (text.length < 80) throw new Error('Text is too short for useful summary');\nif (text.length > 60000) throw new Error('Text is too long: split before workflow');\n\nconst maxChunk = 5500;\nconst chunks = [];\nfor (let i = 0; i < text.length; i += maxChunk) {\n  chunks.push(text.slice(i, i + maxChunk));\n}\n\nconst prompt = `Сделай краткую деловую сводку на русском. Верни JSON: summary, facts, action_items, risks. Не добавляй факты, которых нет в тексте.\\n\\nТекст:\\n${chunks[0]}`;\n\nreturn [{\n  json: {\n    source_id: String(src.source_id ?? 'unknown'),\n    source_type: String(src.source_type ?? 'text'),\n    model: src.model ?? 'qwen2.5:7b-instruct',\n    ollama_body: { model: src.model ?? 'qwen2.5:7b-instruct', prompt, stream: false, options: { temperature: 0.2 } },\n    chunk_count: chunks.length,\n    audit_key: `ollama-summary:${src.source_id ?? Date.now()}`\n  }\n}];"
      },
      "id": "976926fe-3105-4576-bfe7-b1249a784ace",
      "name": "Validate summary",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        840,
        260
      ]
    },
    {
      "parameters": {},
      "id": "5d43c01f-b4a7-4b6e-a812-75aa5b3156b1",
      "name": "Save audit log",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 2,
      "position": [
        1120,
        260
      ]
    },
    {
      "parameters": {},
      "id": "7f4036de-1f7a-479d-bda3-7eadad7b4635",
      "name": "Respond to Webhook",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 2,
      "position": [
        1400,
        260
      ]
    }
  ],
  "connections": {
    "Webhook input": {
      "main": [
        [
          {
            "node": "Normalize and chunk text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize and chunk text": {
      "main": [
        [
          {
            "node": "Call Ollama generate",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call Ollama generate": {
      "main": [
        [
          {
            "node": "Validate summary",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Validate summary": {
      "main": [
        [
          {
            "node": "Save audit log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save audit log": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [
    "nodbot",
    "production",
    "template"
  ],
  "triggerCount": 1,
  "updatedAt": "2026-05-30T00:00:00.000Z",
  "versionId": "278e5ecf-1b3b-4e78-acca-af217a5792a5",
  "meta": {
    "templateCredsSetupCompleted": false
  }
}