This workflow follows the Gmail Trigger → Google Sheets recipe pattern — see all workflows that pair these two integrations.
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": "Accounting to DWH via email CSV reader (DE)",
"nodes": [
{
"parameters": {
"url": "=https://gmail.googleapis.com/gmail/v1/users/me/messages/{{ $('Get Message1').item.json.id}}/attachments/{{ $json.attachmentId }}",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "gmailOAuth2",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
1344,
480
],
"id": "d28aaf8d-38e0-5627-8d09-406ba569a02b",
"name": "Get Attachment",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"options": {
"delimiter": ";"
}
},
"type": "n8n-nodes-base.extractFromFile",
"typeVersion": 1,
"position": [
1792,
480
],
"id": "fcc743b5-e0e0-59cc-8284-5f495487b1b9",
"name": "Extract from File"
},
{
"parameters": {
"jsCode": "const output = [];\n\nfor (const item of items) {\n const parts = item.json.payload?.parts || [];\n\n for (const part of parts) {\n if (part?.body?.attachmentId) {\n output.push({\n json: part.body\n });\n }\n }\n}\n\nreturn output;\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1120,
480
],
"id": "aa42d72a-d757-5cdc-badb-f575617e194b",
"name": "Code"
},
{
"parameters": {
"schema": {
"__rl": true,
"value": "accounting",
"mode": "list",
"cachedResultName": "accounting"
},
"table": {
"__rl": true,
"value": "de_input_01",
"mode": "list",
"cachedResultName": "de_input_01"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"booking_id": "={{ $json['invoice number'] }}",
"date_of_booking": "={{ $json.date }}",
"name_of_account_eng": "=",
"t1a_account": "=",
"account": "={{ $json.account }}",
"dt_currency": "=",
"ct_currency": "=",
"currency": "={{ $json.currency }}",
"exchange_rate": "=",
"dt_pln": "={{ $json['revenue soll'] }}",
"ct_pln": "={{ $json['revenue haben'] }}",
"description": "={{ $json['posting text'] }}",
"register": "=",
"vendor": "=",
"vat": "="
},
"matchingColumns": [],
"schema": [
{
"id": "booking_id",
"displayName": "booking_id",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "date_of_booking",
"displayName": "date_of_booking",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "name_of_account_eng",
"displayName": "name_of_account_eng",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "t1a_account",
"displayName": "t1a_account",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "account",
"displayName": "account",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "dt_currency",
"displayName": "dt_currency",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "ct_currency",
"displayName": "ct_currency",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "currency",
"displayName": "currency",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "exchange_rate",
"displayName": "exchange_rate",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "dt_pln",
"displayName": "dt_pln",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "ct_pln",
"displayName": "ct_pln",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "description",
"displayName": "description",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "register",
"displayName": "register",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "vendor",
"displayName": "vendor",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "vat",
"displayName": "vat",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
2224,
480
],
"id": "338c429a-44c2-5900-af16-e33c7901d7f6",
"name": "Insert rows in a table",
"credentials": {
"postgres": {
"name": "<your credential>"
}
},
"onError": "continueErrorOutput"
},
{
"parameters": {
"url": "=https://gmail.googleapis.com/gmail/v1/users/me/messages/{{$('Gmail Trigger DE').item.json.id}}",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "gmailOAuth2",
"options": {}
},
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.2,
"position": [
896,
480
],
"id": "3cc34be4-c178-58e1-aa4f-e625a59fe758",
"name": "Get Message1",
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"jsCode": "if (!$json.data) {\n throw new Error('No base64 data found in JSON input');\n}\n\n// Decode base64 string from JSON\nconst text = Buffer.from($json.data, 'base64').toString('utfREDACTED');\n\n// Remove line breaks inside quoted fields\nconst cleaned = text.replace(/\"([^\"]*)\"/gs, m =>\n m.replace(/\\r?\\n/g, ' ')\n);\n\n// Remove empty lines\nconst finalText = cleaned\n .split('\\n')\n .filter(l => l.trim() !== '')\n .join('\\n');\n\n// Return as proper binary so CSV node can read it\nreturn [{\n binary: {\n data: {\n data: Buffer.from(finalText).toString('base64'),\n mimeType: 'text/csv',\n fileName: 'cleaned.csv',\n },\n },\n}];\n"
},
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1568,
480
],
"id": "2be9f76b-ac3c-5578-9944-00cefdbd51c6",
"name": "Code in JavaScript"
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict",
"version": 3
},
"conditions": [
{
"id": "7bd24b5d-72b6-4443-967c-2eREDACTEDabbab252d",
"leftValue": "={{ $json.N }}",
"rightValue": 0,
"operator": {
"type": "number",
"operation": "exists",
"singleValue": true
}
}
],
"combinator": "and"
},
"options": {}
},
"type": "n8n-nodes-base.filter",
"typeVersion": 2.3,
"position": [
224,
0
],
"id": "6d88550f-6925-5cc4-baeb-d23b3248b33a",
"name": "Filter1"
},
{
"parameters": {
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_003",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 933915568,
"mode": "list",
"cachedResultName": "d_DE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_003/edit#gid=93391556REDACTED"
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
0,
0
],
"id": "e754a908-e1fb-580d-9a6a-746730e9d68c",
"name": "Status Update step ",
"retryOnFail": true,
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "update",
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_003",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 933915568,
"mode": "list",
"cachedResultName": "d_DE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_003/edit#gid=93391556REDACTED"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"N": "={{ $json.N }}",
"Status": "To do"
},
"matchingColumns": [
"N"
],
"schema": [
{
"id": "N",
"displayName": "N",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Step",
"displayName": "Step",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "Status",
"displayName": "Status",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Date",
"displayName": "Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "Webhook",
"displayName": "Webhook",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "Source",
"displayName": "Source",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "row_number",
"displayName": "row_number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"readOnly": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
448,
0
],
"id": "8e5fe246-e3bd-54eb-95c4-e70b7b09fae6",
"name": "Status Update step 3",
"retryOnFail": true,
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "update",
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_003",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 933915568,
"mode": "list",
"cachedResultName": "d_DE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_003/edit#gid=93391556REDACTED"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"Status": "Done",
"N": "10",
"Date": "={{ $now.format('yyyy-MM-dd hh:mm') }}",
"Source": "=QB email from {{ $json.From }}"
},
"matchingColumns": [
"N"
],
"schema": [
{
"id": "N",
"displayName": "N",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Step",
"displayName": "Step",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Status",
"displayName": "Status",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Date",
"displayName": "Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Webhook",
"displayName": "Webhook",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Source",
"displayName": "Source",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "row_number",
"displayName": "row_number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"readOnly": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
672,
0
],
"id": "42c417de-12d6-58dd-8404-df6fbc82a346",
"name": "Update status1",
"retryOnFail": true,
"executeOnce": true,
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "update",
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_003",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 933915568,
"mode": "list",
"cachedResultName": "d_DE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_003/edit#gid=93391556REDACTED"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"N": "20",
"Status": "Error",
"Date": "={{ $now.format('yyyy-MM-dd hh:mm') }}",
"Webhook": "NA",
"Source": "=SQL script in nREDACTEDn"
},
"matchingColumns": [
"N"
],
"schema": [
{
"id": "N",
"displayName": "N",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Step",
"displayName": "Step",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Status",
"displayName": "Status",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Date",
"displayName": "Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Webhook",
"displayName": "Webhook",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Source",
"displayName": "Source",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "row_number",
"displayName": "row_number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"readOnly": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
912,
304
],
"id": "8a60dc03-c1ee-5ef0-b20b-c6ec52646c1b",
"name": "Update status 21",
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "update",
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_003",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 933915568,
"mode": "list",
"cachedResultName": "d_DE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_003/edit#gid=93391556REDACTED"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"N": "40",
"Status": "Done",
"Date": "={{ $now.format('yyyy-MM-dd hh:mm') }}",
"Webhook": "NA",
"Source": "=Attached file from email"
},
"matchingColumns": [
"N"
],
"schema": [
{
"id": "N",
"displayName": "N",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Step",
"displayName": "Step",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Status",
"displayName": "Status",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Date",
"displayName": "Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Webhook",
"displayName": "Webhook",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Source",
"displayName": "Source",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "row_number",
"displayName": "row_number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"readOnly": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
2448,
240
],
"id": "ac0a5af6-4900-5223-97bc-a26cf5978057",
"name": "Update status 22",
"executeOnce": true,
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "update",
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_003",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 933915568,
"mode": "list",
"cachedResultName": "d_DE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_003/edit#gid=93391556REDACTED"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"N": "40",
"Status": "Error",
"Date": "={{ $now.format('yyyy-MM-dd hh:mm') }}",
"Webhook": "NA",
"Source": "=Attached file from email"
},
"matchingColumns": [
"N"
],
"schema": [
{
"id": "N",
"displayName": "N",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Step",
"displayName": "Step",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Status",
"displayName": "Status",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Date",
"displayName": "Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Webhook",
"displayName": "Webhook",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Source",
"displayName": "Source",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "row_number",
"displayName": "row_number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"readOnly": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
2448,
432
],
"id": "76860019-7520-540b-a7fb-b5e051479102",
"name": "Update status 23",
"executeOnce": true,
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_003",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 1291063677,
"mode": "list",
"cachedResultName": "m_DE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_003/edit#gid=1291063677"
},
"options": {
"dataLocationOnSheet": {
"values": {
"rangeDefinition": "specifyRangeA1",
"range": "A3:D"
}
}
}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
2448,
624
],
"id": "fba0c356-beb5-52a9-a495-5701917ee8cf",
"name": "Get CoA mapping",
"executeOnce": true,
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "clear",
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_004",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 469243737,
"mode": "list",
"cachedResultName": "input_qb",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_004/edit#gid=469243737"
}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
3792,
912
],
"id": "3608cfdb-45ec-5b10-9ca1-f0838509cdc8",
"name": "Clear sheet input_qb",
"executeOnce": true,
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"disabled": true
},
{
"parameters": {
"operation": "append",
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_003",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 544841956,
"mode": "list",
"cachedResultName": "o_DE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_003/edit#gid=544REDACTED41956"
},
"columns": {
"mappingMode": "autoMapInputData",
"value": {},
"matchingColumns": [
"id"
],
"schema": [
{
"id": "distr_account",
"displayName": "distr_account",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "distr_account_type",
"displayName": "distr_account_type",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "transaction_date",
"displayName": "transaction_date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "transaction_type",
"displayName": "transaction_type",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "tr_number",
"displayName": "tr_number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "name_",
"displayName": "name_",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "item_class",
"displayName": "item_class",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "memo_descr",
"displayName": "memo_descr",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "item_split_account_full_name",
"displayName": "item_split_account_full_name",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "amount",
"displayName": "amount",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "balance",
"displayName": "balance",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "acc_name_t1a",
"displayName": "acc_name_t1a",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "bs_pl",
"displayName": "bs_pl",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "cash",
"displayName": "cash",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "id",
"displayName": "id",
"required": false,
"defaultMatch": true,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "account",
"displayName": "account",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "l1",
"displayName": "l1",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "l2",
"displayName": "l2",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "l3",
"displayName": "l3",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "l4",
"displayName": "l4",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "l5",
"displayName": "l5",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "l6",
"displayName": "l6",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "eop_yyyy_mm",
"displayName": "eop_yyyy_mm",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "eop_yyyy",
"displayName": "eop_yyyy",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
4688,
944
],
"id": "cacf7145-fa72-5d63-a895-c9ea6ef92b5e",
"name": "Insert data input_qb1",
"executeOnce": false,
"alwaysOutputData": true,
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"onError": "continueErrorOutput"
},
{
"parameters": {
"operation": "executeQuery",
"query": "--\u0444\u043e\u0440\u043c\u0430\u0442\u0438\u0440\u0443\u044e \u0434\u0430\u043d\u043d\u044b\u0435 \u0432 \u043d\u0443\u0436\u043d\u044b\u0439 \u0444\u043e\u0440\u043c\u0430\u0442\n--drop table if exists accounting.de_input_02;\n--\u0423\u0434\u0430\u043b\u0435\u043d\u0438\u0435 \u0441\u0443\u0449\u0435\u0441\u0442\u0432\u0443\u044e\u0449\u0435\u0433\u043e \u0433\u043e\u0434\u0430\nDELETE FROM accounting.de_input_02\nWHERE EXTRACT(YEAR FROM transaction_date) = '{{ $('Edit Fields').item.json.year }}'\n;\n\n--\n\n--CREATE TABLE IF NOT EXISTS accounting.de_input_02 AS \ninsert into accounting.de_input_02\n(\nSELECT \n account AS distr_account,\n NULL AS distr_account_type,\n CASE\n WHEN date_of_booking ~ '^[0-9]+(\\.[0-9]+)?$'\n THEN DATE '1REDACTED99-12-30' + (date_of_booking::numeric)::int\n ELSE to_date(date_of_booking, 'DD.MM.YYYY')\n END AS transaction_date,\n NULL AS transaction_type,\n booking_id AS tr_number,\n NULL AS name_,\n NULL AS item_class,\n description AS memo_descr,\n vendor AS item_split_account_full_name,\n (\n COALESCE(\n CAST(\n REPLACE(\n REPLACE(\n REPLACE(NULLIF(ct_pln, ''), '$', ''),\n '.', ''\n ),\n ',', '.'\n ) AS numeric\n ),\n 0\n )\n -\n COALESCE(\n CAST(\n REPLACE(\n REPLACE(\n REPLACE(NULLIF(dt_pln, ''), '$', ''),\n '.', ''\n ),\n ',', '.'\n ) AS numeric\n ),\n 0\n )\n) AS amount\n,\n NULL AS balance\nFROM accounting.de_input_01\n);\n\n--\nselect * from accounting.de_input_02\nlimit 1;",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
4016,
912
],
"id": "82f9fb46-0d47-51ee-b950-b1c92869872b",
"name": "Format data accounting.de_input_1",
"executeOnce": true,
"credentials": {
"postgres": {
"name": "<your credential>"
}
},
"onError": "continueErrorOutput"
},
{
"parameters": {
"operation": "executeQuery",
"query": "--\u0422\u0430\u0431\u043b\u0438\u0446\u0430 \u0441 \u043f\u043e\u043b\u043d\u044b\u043c \u0434\u0430\u043d\u043d\u044b\u043c\u0438 \u0434\u043b\u044f \u0432\u044b\u0433\u0440\u0443\u0437\u043a\u0438\ndrop table if exists accounting.de_01;\n--\nCREATE TABLE if not exists accounting.de_01 as (\nselect\n\tinput_02.distr_account,\n\tinput_02.distr_account_type,\n\tinput_02.transaction_date::date,\n\tinput_02.transaction_type,\n\tinput_02.tr_number,\n\tinput_02.name_,\n\tinput_02.item_class,\n\tinput_02.memo_descr,\n\tinput_02.item_split_account_full_name,\n\tinput_02.amount * coalesce(coalesce(map_02.sign_,map_01.sign_), 1) as amount,\n\tinput_02.balance,\n\tcao.acc_name_t1a,\n\tcao.bs_pl,\n\tcao.cash,\n\tplan_cao.id,\n\tplan_cao.account,\n\tplan_cao.l1,\n\tplan_cao.l2,\n\tplan_cao.l3,\n\tplan_cao.l4,\n\tplan_cao.l5,\n\tplan_cao.l6,\n\t'm' || TO_CHAR(input_02.transaction_date, 'YYYY-MM') as eop_yyyy_mm,\n\t'y' || TO_CHAR(input_02.transaction_date, 'YYYY') as eop_yyyy\n\t--plan_cao.project_efficiency_mapping\nfrom accounting.de_input_02 as input_02\nleft join --\u043f\u043b\u0430\u043d \u0441\u0447\u0435\u0442\u043e\u0432\n\t\t(select distinct on (acc_name_qb)\n\t\t\tacc_name_qb,\n\t\t\tacc_name_t1a,\n\t\t\tbs_pl,\n\t\t\tcash \n\t\tfrom accounting.de_cao_01) as cao\n\ton input_02.distr_account = cao.acc_name_qb\nleft join --\u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0438\u0435\u0440\u0430\u0440\u0445\u0438\u0438 \u0441\u0447\u0435\u0442\u043e\u0432\n\t\t(SELECT DISTINCT ON (account)\n\t\t id,\n\t\t account,\n\t\t l1,\n\t\t l2,\n\t\t l3,\n\t\t l4,\n\t\t l5,\n\t\t l6\n\t\tFROM mrp.account_hier\n\t\tORDER BY account)\n\tas plan_cao\n\ton cao.acc_name_t1a = plan_cao.account\nleft join --\u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043f\u043e \u0437\u043d\u0430\u043a\u0443 #1\n\t\t(SELECT DISTINCT ON (transaction_type)\n\t\t transaction_type,\n\t\t sign_::decimal as sign_\n\t\tFROM accounting.de_map_01\n\t\tORDER BY transaction_type)\n\tas map_01\n\ton input_02.transaction_type = map_01.transaction_type\nleft join --\u043c\u0430\u043f\u043f\u0438\u043d\u0433 \u0438\u0441\u043a\u043b\u044e\u0447\u0435\u043d\u0438\u0439 \u043f\u043e \u0441\u0447\u0435\u0442\u0443 #2\n\t\t(SELECT DISTINCT ON (account)\n\t\t account,\n\t\t sign_::decimal as sign_\n\t\tFROM accounting.de_map_02\n\t\tORDER BY account)\n\tas map_02\n\ton input_02.distr_account = map_02.account\nwhere input_02.transaction_date >= '2025-01-01'\n\tand amount <> 0\n);\n--\nselect * from accounting.de_01\n--limit 1;",
"options": {}
},
"type": "n8n-nodes-base.postgres",
"typeVersion": 2.6,
"position": [
4464,
944
],
"id": "04929b6e-b93a-5550-ba07-d49ada6b12bf",
"name": "Create table accounting.de_1",
"executeOnce": true,
"alwaysOutputData": true,
"credentials": {
"postgres": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "update",
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_003",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 933915568,
"mode": "list",
"cachedResultName": "d_DE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_003/edit#gid=93391556REDACTED"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"N": "50",
"Status": "Done",
"Date": "={{ $now.format('yyyy-MM-dd hh:mm') }}",
"Webhook": "NA"
},
"matchingColumns": [
"N"
],
"schema": [
{
"id": "N",
"displayName": "N",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Step",
"displayName": "Step",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "Status",
"displayName": "Status",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Date",
"displayName": "Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Webhook",
"displayName": "Webhook",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Source",
"displayName": "Source",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "row_number",
"displayName": "row_number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"readOnly": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
2896,
336
],
"id": "daeac1f4-05b7-56ac-af4b-eee5123904de",
"name": "Update status 24",
"executeOnce": true,
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "update",
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_003",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 933915568,
"mode": "list",
"cachedResultName": "d_DE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_003/edit#gid=93391556REDACTED"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"N": "60",
"Status": "Done",
"Date": "={{ $now.format('yyyy-MM-dd hh:mm') }}",
"Webhook": "NA",
"Source": "accounting.de_input_01"
},
"matchingColumns": [
"N"
],
"schema": [
{
"id": "N",
"displayName": "N",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Step",
"displayName": "Step",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "Status",
"displayName": "Status",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Date",
"displayName": "Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Webhook",
"displayName": "Webhook",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Source",
"displayName": "Source",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "row_number",
"displayName": "row_number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"readOnly": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
4240,
624
],
"id": "23f192bf-efe2-5a86-b6d9-04b041a12b5c",
"name": "Update status 25",
"executeOnce": true,
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "update",
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_003",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 933915568,
"mode": "list",
"cachedResultName": "d_DE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_003/edit#gid=93391556REDACTED"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"N": "REDACTED0",
"Status": "Done",
"Date": "={{ $now.format('yyyy-MM-dd hh:mm') }}",
"Webhook": "NA"
},
"matchingColumns": [
"N"
],
"schema": [
{
"id": "N",
"displayName": "N",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Step",
"displayName": "Step",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "Status",
"displayName": "Status",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Date",
"displayName": "Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Webhook",
"displayName": "Webhook",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Source",
"displayName": "Source",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "row_number",
"displayName": "row_number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"readOnly": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
4912,
656
],
"id": "2149b517-562d-555b-b137-4f9ead50261b",
"name": "Update status 26",
"executeOnce": true,
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "update",
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_003",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 933915568,
"mode": "list",
"cachedResultName": "d_DE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_003/edit#gid=93391556REDACTED"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"N": "REDACTED0",
"Status": "Error",
"Date": "={{ $now.format('yyyy-MM-dd hh:mm') }}",
"Webhook": "NA"
},
"matchingColumns": [
"N"
],
"schema": [
{
"id": "N",
"displayName": "N",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Step",
"displayName": "Step",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "Status",
"displayName": "Status",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Date",
"displayName": "Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Webhook",
"displayName": "Webhook",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Source",
"displayName": "Source",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "row_number",
"displayName": "row_number",
"required": false,
"defaultMatch": false,
"display": true,
"type": "number",
"canBeUsedToMatch": true,
"readOnly": true,
"removed": true
}
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
4912,
848
],
"id": "7d10c5bc-57cb-596f-b256-301dff21fef3",
"name": "Update status 27",
"executeOnce": true,
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"operation": "clear",
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_003",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 544841956,
"mode": "list",
"cachedResultName": "o_DE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_003/edit#gid=544REDACTED41956"
}
},
"type": "n8n-nodes-base.googleSheets",
"typeVersion": 4.7,
"position": [
4240,
1008
],
"id": "24f235c7-d1f4-50ea-8c2b-4285f24b5785",
"name": "Clear o_DE1",
"executeOnce": true,
"alwaysOutputData": true,
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"onError": "continueErrorOutput"
},
{
"parameters": {
"operation": "update",
"documentId": {
"__rl": true,
"value": "REDACTED_SHEET_ID_003",
"mode": "id"
},
"sheetName": {
"__rl": true,
"value": 933915568,
"mode": "list",
"cachedResultName": "d_DE",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/REDACTED_SHEET_ID_003/edit#gid=93391556REDACTED"
},
"columns": {
"mappingMode": "defineBelow",
"value": {
"N": "51",
"Status": "Done",
"Date": "={{ $now.format('yyyy-MM-dd hh:mm') }}",
"Webhook": "NA"
},
"matchingColumns": [
"N"
],
"schema": [
{
"id": "N",
"displayName": "N",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": false
},
{
"id": "Step",
"displayName": "Step",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "Status",
"displayName": "Status",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Date",
"displayName": "Date",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Webhook",
"displayName": "Webhook",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true
},
{
"id": "Source",
"displayName": "Source",
"required": false,
"defaultMatch": false,
"display": true,
"type": "string",
"canBeUsedToMatch": true,
"removed": true
},
{
"id": "row_number",
"displayName": "row_number",
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.
gmailOAuth2googleSheetsOAuth2Apipostgres
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
Accounting to DWH via email CSV reader (DE). Uses httpRequest, postgres, googleSheets, gmailTrigger. Event-driven trigger; 55 nodes.
Source: https://github.com/SamvelMkhitaryan/n8n-automation-portfolio/blob/main/06-accounting-etl-pipeline/workflow.json — 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 acts as a junior finance research analyst for a UK boutique M&A or corporate finance team. It listens for Slack messages, classifies the request, gathers company or market data, and prod
Bill Payment Automated Invoices (Contractor invoice). Uses httpRequest, googleSheets, emailSend, postgres. Event-driven trigger; 25 nodes.
AI Money Tracker Chatbot. Uses telegramTrigger, postgres, googleSheets, telegram. Event-driven trigger; 24 nodes.
This n8n workflow retrieves AI agent chat memory logs stored in Postgres and pushes them to Google Sheets, creating one sheet per session. It’s useful for teams building chat-based products or agents
This n8n workflow automates the transformation of spreadsheet data into professional charts and graphs using AI-driven analysis. Triggered via Slack, it processes uploaded files (Excel, CSV, Google Sh