{
  "id": "jEuJ5ypSwoCxn2aR",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Sovereign AI Document Summarizer Nextcloud + IONOS AI Model Hub",
  "tags": [],
  "nodes": [
    {
      "id": "708feac6-6822-49f6-a9c7-46f261c7278a",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -96,
        32
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 23
            }
          ]
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "506f5bec-7337-4cca-a2f4-99ace5e01a78",
      "name": "Summarization Chain",
      "type": "@n8n/n8n-nodes-langchain.chainSummarization",
      "position": [
        768,
        -16
      ],
      "parameters": {
        "options": {},
        "operationMode": "documentLoader"
      },
      "typeVersion": 2
    },
    {
      "id": "a08e4150-4bb0-4e14-9cd1-7e7afc4d4698",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1024,
        160
      ],
      "parameters": {
        "options": {},
        "dataType": "binary"
      },
      "typeVersion": 1
    },
    {
      "id": "a2bef8cc-3eab-4e8e-b4c1-cb850e059736",
      "name": "Token Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterTokenSplitter",
      "position": [
        1072,
        448
      ],
      "parameters": {
        "chunkSize": 3000
      },
      "typeVersion": 1
    },
    {
      "id": "dcb28e43-cf6c-45a2-9428-f3f844ccfe9d",
      "name": "List a folder",
      "type": "n8n-nodes-base.nextCloud",
      "position": [
        144,
        32
      ],
      "parameters": {
        "resource": "folder",
        "operation": "list",
        "authentication": "oAuth2"
      },
      "credentials": {
        "nextCloudOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "52835879-fcac-4822-9337-174d325c6d80",
      "name": "Download a file",
      "type": "n8n-nodes-base.nextCloud",
      "position": [
        592,
        32
      ],
      "parameters": {
        "path": "={{ '/' + decodeURIComponent($json.path) }}",
        "operation": "download",
        "authentication": "oAuth2"
      },
      "credentials": {
        "nextCloudOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9f95c163-37c7-4cb2-9218-a55893574721",
      "name": "IONOS Cloud Chat Model",
      "type": "@ionos-cloud/n8n-nodes-ionos-cloud.ionosCloudChatModel",
      "position": [
        800,
        160
      ],
      "parameters": {
        "model": "meta-llama/Llama-3.3-70B-Instruct",
        "options": {}
      },
      "credentials": {
        "ionosCloudApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c558a1e6-d946-4854-890d-3cb79ef36749",
      "name": "Upload a file",
      "type": "n8n-nodes-base.nextCloud",
      "position": [
        1568,
        -16
      ],
      "parameters": {
        "path": "=/Notes/Summary_{{ $node[\"Download a file\"].json.path.split('/').pop() }}",
        "fileContent": "=### \ud83d\udcc2 New File Processed\n**File Name:** {{ $node[\"Download a file\"].json.path.split('/').pop() }}\n**Processed on:** {{ $today.format('yyyy-MM-dd') }}\n\n---\n#### \ud83d\udca1 AI Summary\nThis file was added to your drive. Here is the summarization of your document:\n\n{{ $json.response.text }}",
        "authentication": "oAuth2"
      },
      "credentials": {
        "nextCloudOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8093f5ef-8f8f-4471-8212-d6a90d090d8f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -768,
        -224
      ],
      "parameters": {
        "width": 512,
        "height": 544,
        "content": "##  Sovereign AI Document Summarizer\n### Nextcloud + IONOS AI Model Hub\n\nThis workflow automates document summarization while keeping full digital sovereignty. By combining Nextcloud for file storage and the IONOS AI Model Hub, your sensitive documents stay on European infrastructure.\n\n**Requirements checklist:**\n- [ ] Nextcloud OAuth2 credentials configured (read + write)\n- [ ] IONOS Cloud API token added to credentials\n- [ ] `@ionos-cloud/n8n-nodes-ionos-cloud` node package installed\n- [ ] LangChain AI nodes enabled (`@n8n/n8n-nodes-langchain`)\n- [ ] `/Notes/` folder created in your Nextcloud instance\n- [ ] Folder path set in the **List a folder** node\n\n**Data flow:**\nSchedule \u2192 List Folder \u2192 Filter \u2192 Download \u2192 Summarize \u2192 Upload Summary"
      },
      "typeVersion": 1
    },
    {
      "id": "0483a111-0308-464e-b9c2-01266aea48bb",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        -80
      ],
      "parameters": {
        "width": 832,
        "height": 368,
        "content": "## 1. Get new or modified files\n"
      },
      "typeVersion": 1
    },
    {
      "id": "29f12a6b-3314-4a28-8eda-a9ac94786c24",
      "name": "New Files Only",
      "type": "n8n-nodes-base.code",
      "position": [
        384,
        32
      ],
      "parameters": {
        "jsCode": "// Keep all files uploaded in the last 24 hours\nconst cutoff = new Date(Date.now() - 24 * 60 * 60 * 1000);\n\nreturn $input.all().filter(item => {\n  const f = item.json;\n  // Ignore folders, only process files\n  if (f.type === 'directory') return false;\n\n  const modified = new Date(f.lastmod || f.lastModified || 0);\n  return modified >= cutoff;\n});"
      },
      "typeVersion": 2
    },
    {
      "id": "98033d80-cc85-42dd-b2c7-484a49f20087",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        736,
        -80
      ],
      "parameters": {
        "width": 624,
        "height": 672,
        "content": "## 2. Process & summarize \n"
      },
      "typeVersion": 1
    },
    {
      "id": "d7b07b7f-6bbb-4e13-a7b1-7b5ed0226a88",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1376,
        -80
      ],
      "parameters": {
        "width": 624,
        "height": 368,
        "content": "## 3. Save the results and get a Note\n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "3644d4de-6102-4977-a760-d5376ccabf02",
  "connections": {
    "List a folder": {
      "main": [
        [
          {
            "node": "New Files Only",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New Files Only": {
      "main": [
        [
          {
            "node": "Download a file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Token Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Download a file": {
      "main": [
        [
          {
            "node": "Summarization Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "List a folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Summarization Chain",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Summarization Chain": {
      "main": [
        [
          {
            "node": "Upload a file",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IONOS Cloud Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Summarization Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  }
}