The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"name": "My workflow",
"nodes": [
{
"parameters": {
"downloadAttachments": true,
"options": {}
},
"id": "1d7641f6-3f78-441c-8db4-939c456da4b9",
"name": "Email Trigger (IMAP)5",
"type": "n8n-nodes-base.emailReadImap",
"typeVersion": 2,
"position": [
-4352,
2208
],
"credentials": {
"imap": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"fileName": "/tmp/invoice-{{$executionId}}.pdf",
"dataPropertyName": "attachment_0",
"options": {}
},
"id": "34763e17-c9a4-45e6-a87a-f31021642d78",
"name": "Write Binary File5",
"type": "n8n-nodes-base.writeBinaryFile",
"typeVersion": 1,
"position": [
-4112,
2208
]
},
{
"parameters": {
"command": "pdftoppm /tmp/invoice-{{$executionId}}.pdf /tmp/invoice-{{$executionId}} -png"
},
"id": "4ec8f1c6-dc28-4616-afff-59afe2c2f200",
"name": "Convert PDF \u2192 PNG5",
"type": "n8n-nodes-base.executeCommand",
"typeVersion": 1,
"position": [
-3872,
2208
]
},
{
"parameters": {
"command": "tesseract /tmp/invoice-{{$executionId}}-1.png stdout -l pol"
},
"id": "13377dc8-fb63-4314-a654-4269c4367874",
"name": "OCR (Tesseract)5",
"type": "n8n-nodes-base.executeCommand",
"typeVersion": 1,
"position": [
-3632,
2208
]
},
{
"parameters": {
"jsCode": "// Pobierz pe\u0142ny tekst z OCR\nconst text = $json[\"stdout\"];\n\n// Numer faktury\nconst matchInvoice = text.match(/Nr\\s+([A-Z0-9\\/_-]+)/i);\nlet invoiceNumber = matchInvoice ? matchInvoice[1] : \"Faktura_bez_numeru\";\n\n// Data (np. 2025-09-05)\nconst matchDate = text.match(/(\\d{4}-\\d{2}-\\d{2})/);\nlet invoiceDate = matchDate ? matchDate[1] : null;\n\nlet year = null;\nlet month = null;\nif (invoiceDate) {\n const d = new Date(invoiceDate);\n year = d.getFullYear();\n month = String(d.getMonth() + 1).padStart(2, \"0\");\n}\n\nreturn [{ json: { invoiceNumber, invoiceDate, year, month } }];"
},
"id": "a44bff37-ca47-4fca-bff9-b3839c1c3874",
"name": "Extract Invoice Data3",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
-3392,
2208
]
},
{
"parameters": {
"resource": "folder",
"name": "={{ $json.year }}",
"options": {}
},
"id": "c230b958-5567-4383-802f-129aa481ffb1",
"name": "Create Year Folder3",
"type": "n8n-nodes-base.googleDrive",
"typeVersion": 2,
"position": [
-3152,
2000
],
"credentials": {
"googleDriveOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"resource": "folder",
"name": "={{ $('Extract Invoice Data3').item.json.month }}",
"options": {}
},
"id": "bee4d4b2-f64a-4fd0-8807-57e0db48f45a",
"name": "Create Month Folder3",
"type": "n8n-nodes-base.googleDrive",
"typeVersion": 2,
"position": [
-2992,
2000
],
"credentials": {
"googleDriveOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"resource": "folder",
"name": "Zakupy",
"options": {}
},
"id": "2830020f-73e2-488e-bdeb-f88d9d62ec18",
"name": "Create Zakupy Folder3",
"type": "n8n-nodes-base.googleDrive",
"typeVersion": 2,
"position": [
-2832,
2000
],
"credentials": {
"googleDriveOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"mode": "combine",
"combinationMode": "multiplex",
"options": {}
},
"id": "47b45961-53dc-4ff0-9973-545c447ed5d5",
"name": "Merge PDF + Metadata2",
"type": "n8n-nodes-base.merge",
"typeVersion": 2,
"position": [
-2992,
2384
]
},
{
"parameters": {
"binaryData": true,
"binaryPropertyName": "attachment_0",
"name": "={{$json.invoiceNumber}}.pdf",
"parents": [
"={{ $('Create Zakupy Folder3').item.json.id }}"
],
"options": {}
},
"id": "9991c8f0-e042-4d42-aff7-b8ad28cd42b9",
"name": "Google Drive (Upload PDF)5",
"type": "n8n-nodes-base.googleDrive",
"typeVersion": 2,
"position": [
-2672,
2384
],
"credentials": {
"googleDriveOAuth2Api": {
"name": "<your credential>"
}
}
}
],
"connections": {
"Email Trigger (IMAP)5": {
"main": [
[
{
"node": "Write Binary File5",
"type": "main",
"index": 0
}
]
]
},
"Write Binary File5": {
"main": [
[
{
"node": "Convert PDF \u2192 PNG5",
"type": "main",
"index": 0
}
]
]
},
"Convert PDF \u2192 PNG5": {
"main": [
[
{
"node": "OCR (Tesseract)5",
"type": "main",
"index": 0
}
]
]
},
"OCR (Tesseract)5": {
"main": [
[
{
"node": "Extract Invoice Data3",
"type": "main",
"index": 0
}
]
]
},
"Extract Invoice Data3": {
"main": [
[
{
"node": "Create Year Folder3",
"type": "main",
"index": 0
},
{
"node": "Merge PDF + Metadata2",
"type": "main",
"index": 1
}
]
]
},
"Create Year Folder3": {
"main": [
[
{
"node": "Create Month Folder3",
"type": "main",
"index": 0
}
]
]
},
"Create Month Folder3": {
"main": [
[
{
"node": "Create Zakupy Folder3",
"type": "main",
"index": 0
}
]
]
},
"Create Zakupy Folder3": {
"main": [
[
{
"node": "Merge PDF + Metadata2",
"type": "main",
"index": 0
}
]
]
},
"Merge PDF + Metadata2": {
"main": [
[
{
"node": "Google Drive (Upload PDF)5",
"type": "main",
"index": 0
}
]
]
}
},
"active": true,
"settings": {
"executionOrder": "v1"
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
googleDriveOAuth2Apiimap
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Work. Uses emailReadImap, writeBinaryFile, executeCommand, googleDrive. Manual trigger; 10 nodes.
Source: https://gist.github.com/sebmka-hash/acc6c57795bdb502744b222d89b6b1a9 — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This workflow contains community nodes that are only compatible with the self-hosted version of n8n.
Alrouf AI Integration (Production). Uses googleSheets, chainLlm, lmChatGoogleGemini, outputParserStructured. Manual trigger; 21 nodes.
Email AI Auto-responder. Summerize and send email. Uses emailReadImap, emailSend, httpRequest, googleDrive. Event-driven trigger; 78 nodes.
Email AI Auto-responder. Summerize and send email. Uses emailReadImap, emailSend, httpRequest, googleDrive. Event-driven trigger; 78 nodes.
Email AI Auto-responder. Summerize and send email. Uses emailReadImap, emailSend, httpRequest, googleDrive. Event-driven trigger; 78 nodes.