693 lines
22 KiB
JSON
693 lines
22 KiB
JSON
{
|
||
"updatedAt": "2026-01-03T12:31:08.000Z",
|
||
"createdAt": "2025-12-21T08:27:02.744Z",
|
||
"id": "N4n2HmA6azz8n7Uw",
|
||
"name": "ollama",
|
||
"active": false,
|
||
"isArchived": false,
|
||
"nodes": [
|
||
{
|
||
"parameters": {},
|
||
"type": "n8n-nodes-base.manualTrigger",
|
||
"typeVersion": 1,
|
||
"position": [
|
||
-176,
|
||
-272
|
||
],
|
||
"id": "14b9aab7-ef42-4b8b-a9de-7ca6403fc9bd",
|
||
"name": "When clicking ‘Execute workflow’"
|
||
},
|
||
{
|
||
"parameters": {
|
||
"modelId": {
|
||
"__rl": true,
|
||
"value": "ministral-3:3b",
|
||
"mode": "list",
|
||
"cachedResultName": "ministral-3:3b"
|
||
},
|
||
"messages": {
|
||
"values": [
|
||
{
|
||
"content": "=[Korrespodent Start]\n{{ $('getCorrespondent').item.json.toJsonString() }}\n[Korrespodent End]\n\n[Dokument Inhalt Start]\n{{ $('documentObject').item.json.document[0].content.substring(1,1000) }}\n[Dokument Inhalt Ende]"
|
||
}
|
||
]
|
||
},
|
||
"options": {
|
||
"system": "Kannst du bitte für dieses Dokument einen Title, Korrespondent und Dokumenttyp extrahieren. Die ich für mein Paperless verwenden kann?\nVersuche erst einen passenden Korrespondent aus meiner Liste was ich anhänge zu finden. Wenn du es nicht findest weise selber eins zu.\n\nStelle sicher das ausschließlich mit purem JSON. Nutze keine Markdown-Formatierung wie ` ` `json. Beginne direkt mit der öffnenden geschweiften Klammer {.\n\nBeispielantwort 1 wenn eine Korrespondent ID vorhanden ist\n\n{\n\"Title\": \"SLK Klinik Beinoperation\",\n\"Korrespondent-ID\": 1,\n\"Korrespondent\": \"SLK Klinik\",\n\"Dokumenttyp\": \"Arztbrief\"\n}\n\nBeispielantwort 2 wenn eine Korrespondent ID nicht vorhanden ist\n{\n\"Title\": \"SLK Klinik Beinoperation\",\n\"Korrespondent-ID\": null,\n\"Korrespondent\": \"SLK Klinik\",\n\"Dokumenttyp\": \"Arztbrief\"\n}\n\n",
|
||
"format": "json"
|
||
}
|
||
},
|
||
"type": "@n8n/n8n-nodes-langchain.ollama",
|
||
"typeVersion": 1,
|
||
"position": [
|
||
1376,
|
||
-240
|
||
],
|
||
"id": "8e7a99f1-ca7f-4b2d-8b30-22749e613aa2",
|
||
"name": "Message a model",
|
||
"executeOnce": true,
|
||
"credentials": {
|
||
"ollamaApi": {
|
||
"id": "4Timi9hA5ACxVRmT",
|
||
"name": "Ollama account"
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"parameters": {
|
||
"url": "=http://192.168.178.101:8000/api/documents/",
|
||
"authentication": "genericCredentialType",
|
||
"genericAuthType": "httpHeaderAuth",
|
||
"sendQuery": true,
|
||
"queryParameters": {
|
||
"parameters": [
|
||
{
|
||
"name": "tags__name__icontains",
|
||
"value": "inbox"
|
||
},
|
||
{
|
||
"name": "tags__id__in",
|
||
"value": "2"
|
||
},
|
||
{
|
||
"name": "tags__id__none",
|
||
"value": "16"
|
||
}
|
||
]
|
||
},
|
||
"options": {
|
||
"response": {
|
||
"response": {}
|
||
}
|
||
}
|
||
},
|
||
"type": "n8n-nodes-base.httpRequest",
|
||
"typeVersion": 4.3,
|
||
"position": [
|
||
48,
|
||
-176
|
||
],
|
||
"id": "141bc592-9bcf-4b75-8490-6ed9b312b2cf",
|
||
"name": "HTTP Request",
|
||
"credentials": {
|
||
"httpHeaderAuth": {
|
||
"id": "zyL5PgYOGlAptjwA",
|
||
"name": "paperless_api_token"
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"parameters": {
|
||
"assignments": {
|
||
"assignments": [
|
||
{
|
||
"id": "b5c0e99e-727e-4fe3-be0c-13fb5143cf8a",
|
||
"name": "=data",
|
||
"value": "={{ {...$input.first().json, \"document-id\" : $input.last().json.document[0].id} }}",
|
||
"type": "object"
|
||
}
|
||
]
|
||
},
|
||
"options": {}
|
||
},
|
||
"type": "n8n-nodes-base.set",
|
||
"typeVersion": 3.4,
|
||
"position": [
|
||
2176,
|
||
-176
|
||
],
|
||
"id": "d1346069-1484-453f-b2a1-85dc69c8cb62",
|
||
"name": "Edit Fields",
|
||
"executeOnce": false
|
||
},
|
||
{
|
||
"parameters": {
|
||
"fieldToSplitOut": "results",
|
||
"options": {}
|
||
},
|
||
"type": "n8n-nodes-base.splitOut",
|
||
"typeVersion": 1,
|
||
"position": [
|
||
272,
|
||
-176
|
||
],
|
||
"id": "74697e07-3ac6-4f65-b3d8-637472a5a0f4",
|
||
"name": "Split Out"
|
||
},
|
||
{
|
||
"parameters": {
|
||
"options": {
|
||
"reset": false
|
||
}
|
||
},
|
||
"type": "n8n-nodes-base.splitInBatches",
|
||
"typeVersion": 3,
|
||
"position": [
|
||
496,
|
||
-176
|
||
],
|
||
"id": "2c3873ee-ce74-4c04-bb32-88b7c2f51c28",
|
||
"name": "Loop Over Items",
|
||
"executeOnce": false
|
||
},
|
||
{
|
||
"parameters": {
|
||
"conditions": {
|
||
"options": {
|
||
"caseSensitive": true,
|
||
"leftValue": "",
|
||
"typeValidation": "strict",
|
||
"version": 2
|
||
},
|
||
"conditions": [
|
||
{
|
||
"id": "abfbb141-819d-4df5-abcb-3facf527e19e",
|
||
"leftValue": "={{ $json.next }}",
|
||
"rightValue": "={{ $('get_correspondents').last().json.next }}",
|
||
"operator": {
|
||
"type": "string",
|
||
"operation": "notEmpty",
|
||
"singleValue": true
|
||
}
|
||
}
|
||
],
|
||
"combinator": "and"
|
||
},
|
||
"options": {}
|
||
},
|
||
"type": "n8n-nodes-base.if",
|
||
"typeVersion": 2.2,
|
||
"position": [
|
||
272,
|
||
-432
|
||
],
|
||
"id": "c32913b1-88b1-447e-93ff-9cd6f331e88c",
|
||
"name": "weitere Seiten vorhanden",
|
||
"alwaysOutputData": false
|
||
},
|
||
{
|
||
"parameters": {
|
||
"jsCode": "const allData = []\nvar json_lst = []\n\nlet counter = 0;\ndo {\n try {\n const response = $items(\"get_correspondents\", 0, counter)[0].json;\n \n const filtered = response.results.map(item => {\n return {\n id: item.id,\n slug: item.slug,\n name: item.name\n };\n });\n allData.push(...filtered);\n } catch (error) {\n return [{json: {allData}}]; \n }\n\n counter++;\n} while(true);\n\n\n"
|
||
},
|
||
"type": "n8n-nodes-base.code",
|
||
"typeVersion": 2,
|
||
"position": [
|
||
496,
|
||
-432
|
||
],
|
||
"id": "e694365a-2f85-41a6-9f60-8442f86d9e55",
|
||
"name": "Code in JavaScript"
|
||
},
|
||
{
|
||
"parameters": {
|
||
"url": "={{ \n $('weitere Seiten vorhanden').isExecuted == false ? \"http://192.168.178.101:8000/api/correspondents/\" : $node['weitere Seiten vorhanden'].json.next\n}}",
|
||
"authentication": "genericCredentialType",
|
||
"genericAuthType": "httpHeaderAuth",
|
||
"options": {
|
||
"response": {
|
||
"response": {}
|
||
}
|
||
}
|
||
},
|
||
"type": "n8n-nodes-base.httpRequest",
|
||
"typeVersion": 4.3,
|
||
"position": [
|
||
48,
|
||
-432
|
||
],
|
||
"id": "1e3e3a80-66e9-4401-a485-786f7c70a2da",
|
||
"name": "get_correspondents",
|
||
"credentials": {
|
||
"httpHeaderAuth": {
|
||
"id": "zyL5PgYOGlAptjwA",
|
||
"name": "paperless_api_token"
|
||
}
|
||
}
|
||
},
|
||
{
|
||
"parameters": {
|
||
"operation": "upsert",
|
||
"dataTableId": {
|
||
"__rl": true,
|
||
"value": "WmMZJjFqs1LTGlxy",
|
||
"mode": "list",
|
||
"cachedResultName": "paperless_correspondent",
|
||
"cachedResultUrl": "/projects/S4tmpzSj6JlGFOze/datatables/WmMZJjFqs1LTGlxy"
|
||
},
|
||
"filters": {
|
||
"conditions": [
|
||
{
|
||
"keyName": "paperless_id",
|
||
"keyValue": "={{ $json.id }}"
|
||
}
|
||
]
|
||
},
|
||
"columns": {
|
||
"mappingMode": "defineBelow",
|
||
"value": {
|
||
"slug": "={{ $json.slug }}",
|
||
"name": "={{ $json.name }}",
|
||
"paperless_id": "={{ $json.id }}"
|
||
},
|
||
"matchingColumns": [],
|
||
"schema": [
|
||
{
|
||
"id": "slug",
|
||
"displayName": "slug",
|
||
"required": false,
|
||
"defaultMatch": false,
|
||
"display": true,
|
||
"type": "string",
|
||
"readOnly": false,
|
||
"removed": false
|
||
},
|
||
{
|
||
"id": "name",
|
||
"displayName": "name",
|
||
"required": false,
|
||
"defaultMatch": false,
|
||
"display": true,
|
||
"type": "string",
|
||
"readOnly": false,
|
||
"removed": false
|
||
},
|
||
{
|
||
"id": "paperless_id",
|
||
"displayName": "paperless_id",
|
||
"required": false,
|
||
"defaultMatch": false,
|
||
"display": true,
|
||
"type": "number",
|
||
"readOnly": false,
|
||
"removed": false
|
||
}
|
||
],
|
||
"attemptToConvertTypes": false,
|
||
"convertFieldsToString": false
|
||
},
|
||
"options": {
|
||
"dryRun": false
|
||
}
|
||
},
|
||
"type": "n8n-nodes-base.dataTable",
|
||
"typeVersion": 1,
|
||
"position": [
|
||
944,
|
||
-432
|
||
],
|
||
"id": "59dbd8c9-62d0-4c91-aac4-71ff397b5f0e",
|
||
"name": "Upsert row(s)"
|
||
},
|
||
{
|
||
"parameters": {
|
||
"fieldToSplitOut": "allData",
|
||
"options": {}
|
||
},
|
||
"type": "n8n-nodes-base.splitOut",
|
||
"typeVersion": 1,
|
||
"position": [
|
||
720,
|
||
-432
|
||
],
|
||
"id": "4dab0e48-c3fd-497c-8f68-63fffbec1526",
|
||
"name": "Split Out1"
|
||
},
|
||
{
|
||
"parameters": {
|
||
"mode": "raw",
|
||
"jsonOutput": "={\n \"document\": [{{$json.toJsonString()}}]\n}\n",
|
||
"options": {}
|
||
},
|
||
"type": "n8n-nodes-base.set",
|
||
"typeVersion": 3.4,
|
||
"position": [
|
||
720,
|
||
-240
|
||
],
|
||
"id": "9b804e40-985c-4573-8828-6f38baa284d9",
|
||
"name": "documentObject"
|
||
},
|
||
{
|
||
"parameters": {
|
||
"operation": "get",
|
||
"dataTableId": {
|
||
"__rl": true,
|
||
"value": "WmMZJjFqs1LTGlxy",
|
||
"mode": "list",
|
||
"cachedResultName": "paperless_correspondent",
|
||
"cachedResultUrl": "/projects/S4tmpzSj6JlGFOze/datatables/WmMZJjFqs1LTGlxy"
|
||
},
|
||
"returnAll": true
|
||
},
|
||
"type": "n8n-nodes-base.dataTable",
|
||
"typeVersion": 1,
|
||
"position": [
|
||
1152,
|
||
-240
|
||
],
|
||
"id": "22ee408c-f667-4610-85c1-84a0c4da444c",
|
||
"name": "getCorrespondent"
|
||
},
|
||
{
|
||
"parameters": {
|
||
"assignments": {
|
||
"assignments": [
|
||
{
|
||
"id": "5ef46e88-d057-485e-9a75-8dcd244c737f",
|
||
"name": "data",
|
||
"value": "={{ $json.content.removeMarkdown().replaceAll('`','') }}",
|
||
"type": "object"
|
||
}
|
||
]
|
||
},
|
||
"options": {}
|
||
},
|
||
"type": "n8n-nodes-base.set",
|
||
"typeVersion": 3.4,
|
||
"position": [
|
||
1728,
|
||
-240
|
||
],
|
||
"id": "3caf3164-5298-47ea-9696-eec8fd64bb39",
|
||
"name": "dataPreparationToJSON"
|
||
},
|
||
{
|
||
"parameters": {
|
||
"mode": "combine",
|
||
"combineBy": "combineAll",
|
||
"options": {}
|
||
},
|
||
"type": "n8n-nodes-base.merge",
|
||
"typeVersion": 3.2,
|
||
"position": [
|
||
1968,
|
||
-144
|
||
],
|
||
"id": "d81c00ae-3947-4625-bb23-f00a24a21ee7",
|
||
"name": "Merge"
|
||
},
|
||
{
|
||
"parameters": {
|
||
"method": "PATCH",
|
||
"url": "=http://192.168.178.101:8000/api/documents/{{ $json.data['document-id'] }}/",
|
||
"authentication": "genericCredentialType",
|
||
"genericAuthType": "httpHeaderAuth",
|
||
"sendBody": true,
|
||
"bodyParameters": {
|
||
"parameters": [
|
||
{
|
||
"name": "title",
|
||
"value": "={{ $json.data.data.Title }}"
|
||
},
|
||
{
|
||
"name": "tags",
|
||
"value": "={{ $json.data.document[0].tags.concat([16]) }}"
|
||
}
|
||
]
|
||
},
|
||
"options": {
|
||
"response": {
|
||
"response": {}
|
||
}
|
||
}
|
||
},
|
||
"type": "n8n-nodes-base.httpRequest",
|
||
"typeVersion": 4.3,
|
||
"position": [
|
||
2400,
|
||
-176
|
||
],
|
||
"id": "74982eed-7fa2-4d69-9ae0-c2be5e28c5b0",
|
||
"name": "Patch Document",
|
||
"credentials": {
|
||
"httpHeaderAuth": {
|
||
"id": "zyL5PgYOGlAptjwA",
|
||
"name": "paperless_api_token"
|
||
}
|
||
},
|
||
"notes": "Tag ID 16 = n8nAI\n"
|
||
},
|
||
{
|
||
"parameters": {
|
||
"conditions": {
|
||
"options": {
|
||
"caseSensitive": true,
|
||
"leftValue": "",
|
||
"typeValidation": "strict",
|
||
"version": 2
|
||
},
|
||
"conditions": [
|
||
{
|
||
"id": "f3c75165-57de-407d-a23c-23d794cb78c2",
|
||
"leftValue": "={{ $json.document[0].content }}",
|
||
"rightValue": "",
|
||
"operator": {
|
||
"type": "string",
|
||
"operation": "notEmpty",
|
||
"singleValue": true
|
||
}
|
||
}
|
||
],
|
||
"combinator": "and"
|
||
},
|
||
"options": {}
|
||
},
|
||
"type": "n8n-nodes-base.if",
|
||
"typeVersion": 2.2,
|
||
"position": [
|
||
928,
|
||
-144
|
||
],
|
||
"id": "59084e9b-02d5-44cb-a94a-b7bf65d3fda5",
|
||
"name": "If"
|
||
}
|
||
],
|
||
"connections": {
|
||
"When clicking ‘Execute workflow’": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "HTTP Request",
|
||
"type": "main",
|
||
"index": 0
|
||
},
|
||
{
|
||
"node": "get_correspondents",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"HTTP Request": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Split Out",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Message a model": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "dataPreparationToJSON",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Split Out": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Loop Over Items",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Loop Over Items": {
|
||
"main": [
|
||
[],
|
||
[
|
||
{
|
||
"node": "documentObject",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Edit Fields": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Patch Document",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"weitere Seiten vorhanden": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "get_correspondents",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
],
|
||
[
|
||
{
|
||
"node": "Code in JavaScript",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"get_correspondents": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "weitere Seiten vorhanden",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Code in JavaScript": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Split Out1",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Upsert row(s)": {
|
||
"main": [
|
||
[]
|
||
]
|
||
},
|
||
"Split Out1": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Upsert row(s)",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"documentObject": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Merge",
|
||
"type": "main",
|
||
"index": 1
|
||
},
|
||
{
|
||
"node": "If",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"getCorrespondent": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Message a model",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"dataPreparationToJSON": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Merge",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Merge": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Edit Fields",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"Patch Document": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "Loop Over Items",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
},
|
||
"If": {
|
||
"main": [
|
||
[
|
||
{
|
||
"node": "getCorrespondent",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
],
|
||
[
|
||
{
|
||
"node": "Loop Over Items",
|
||
"type": "main",
|
||
"index": 0
|
||
}
|
||
]
|
||
]
|
||
}
|
||
},
|
||
"settings": {
|
||
"executionOrder": "v1"
|
||
},
|
||
"staticData": null,
|
||
"meta": {
|
||
"templateCredsSetupCompleted": true
|
||
},
|
||
"pinData": {},
|
||
"versionId": "9d4c394b-2aca-4fcb-94b3-a8954b0e0d02",
|
||
"triggerCount": 0,
|
||
"shared": [
|
||
{
|
||
"updatedAt": "2025-12-21T08:27:02.747Z",
|
||
"createdAt": "2025-12-21T08:27:02.747Z",
|
||
"role": "workflow:owner",
|
||
"workflowId": "N4n2HmA6azz8n7Uw",
|
||
"projectId": "S4tmpzSj6JlGFOze"
|
||
}
|
||
],
|
||
"tags": []
|
||
} |