{
  "meta": {
    "instanceId": "37f50031da2d48584a7239d61fbf5ae3e1b2415708520d9af5429cf2a73a8c3d",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "ec55993a-2652-4e2d-9e25-3e507f93c487",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -560,
        912
      ],
      "webhookId": "9915b6a2-5823-45b1-9b42-95f428906e87",
      "parameters": {
        "options": {
          "allowFileUploads": true,
          "allowedFilesMimeTypes": "*"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "ce9ddc97-8776-4805-9299-e8898ccd4cdc",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        128,
        1120
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "parsedData['Line Items']"
      },
      "typeVersion": 1
    },
    {
      "id": "a4788bf0-20d2-4e21-9e68-37202475cdcd",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -976,
        912
      ],
      "parameters": {
        "width": 340,
        "height": 420,
        "content": "# Mark - Accountant\n\n![My Image](https://i.postimg.cc/XqKMCBkM/Chat-GPT-Image-Apr-25-2025-06-09-53-AM.png)\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "25cc249b-c780-4a34-8cbb-b2aa8a8adf54",
      "name": "Confirmation",
      "type": "n8n-nodes-base.set",
      "position": [
        768,
        912
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "de0be0e9-b008-40c1-84a6-c350ec326840",
              "name": "confirmation",
              "type": "string",
              "value": "All invoices have been processed"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "82edfbf5-53d1-4105-ae08-85fdd4d4a5de",
      "name": "Parsed Data",
      "type": "n8n-nodes-base.set",
      "position": [
        -48,
        1120
      ],
      "parameters": {
        "options": {
          "ignoreConversionErrors": true
        },
        "assignments": {
          "assignments": [
            {
              "id": "ac4cf2cc-36af-47a4-8638-852302ec2dbd",
              "name": "parsedData",
              "type": "object",
              "value": "={{$json[\"candidates\"][0][\"content\"][\"parts\"][0][\"text\"].replace(/^```json\\s*|\\s*```$/g, '')}}\n"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 3.4
    },
    {
      "id": "b5293bee-dadb-4de1-9142-4efaf432d90f",
      "name": "Upload PDF to Google Gemini",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -432,
        1120
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/upload/v1beta/files",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "binaryData",
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/pdf"
            }
          ]
        },
        "inputDataFieldName": "data0",
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "credential-id",
          "name": "googlePalmApi Credential"
        },
        "httpHeaderAuth": {
          "id": "credential-id",
          "name": "httpHeaderAuth Credential"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "3679bcea-f0aa-4c4e-82b0-43c147564377",
      "name": "Download Data from Google Gemini",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        -240,
        1120
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-preview-04-17:generateContent",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contents\": [\n    {\n      \"role\": \"user\",\n      \"parts\": [\n        {\n          \"text\": \"Read and analyze this document. If it is an invoice, extract and return the following fields in JSON format:\\\\n- Vendor Name\\\\n- Invoice Number\\\\n- Invoice Date\\\\n- Due Date\\\\n- Total Amount\\\\n- VAT Amount\\\\n- Line Items (Description, Quantity, Unit Price, Total Price)\\\\nIf it is not an invoice, summarize the document content instead in plain text.\"\n        },\n        {\n          \"file_data\": {\n            \"mime_type\": \"application/pdf\",\n            \"file_uri\": {{ JSON.stringify($json.file.uri) }}\n          }\n        }\n      ]\n    }\n  ],\n  \"generationConfig\": {\n    \"responseMimeType\": \"text/plain\",\n    \"maxOutputTokens\": 32768\n  }\n}\n",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "credential-id",
          "name": "googlePalmApi Credential"
        },
        "httpHeaderAuth": {
          "id": "credential-id",
          "name": "httpHeaderAuth Credential"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2951c2d7-f543-4ea7-acdb-67b9fa9c8d31",
      "name": "Table ERP",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        288,
        1120
      ],
      "parameters": {
        "columns": {
          "value": {
            "Due Date": "={{ $('Parsed Data').item.json.parsedData['Due Date'] }}",
            "Quantity": "={{ $json.Quantity }}",
            "Unit Price": "={{ $json['Unit Price'] }}",
            "VAT Amount": "={{ $('Parsed Data').item.json.parsedData['VAT Amount'] }}",
            "Total Price": "={{ $json['Total Price'] }}",
            "Vendor Name": "={{ $('Parsed Data').item.json.parsedData['Vendor Name'] }}",
            "Invoice Date": "={{ $('Parsed Data').item.json.parsedData['Invoice Date'] }}",
            "Total Amount": "={{ $('Parsed Data').item.json.parsedData['Total Amount'] }}",
            "Invoice Number": "={{ $('Parsed Data').item.json.parsedData['Invoice Number'] }}",
            "Line Item Description": "={{ $json.Description }}"
          },
          "schema": [
            {
              "id": "Vendor Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Vendor Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoice Number",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Invoice Number",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Invoice Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Invoice Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Due Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Due Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Total Amount",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Total Amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "VAT Amount",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "VAT Amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Line Item Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Line Item Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Quantity",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Quantity",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Unit Price",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Unit Price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Total Price",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Total Price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "cellFormat": "USER_ENTERED"
        },
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Gjm3ALhZZ7I4Wto0CZYNuEr48K-bgLLK6M8K4eyuPq0/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Gjm3ALhZZ7I4Wto0CZYNuEr48K-bgLLK6M8K4eyuPq0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Gjm3ALhZZ7I4Wto0CZYNuEr48K-bgLLK6M8K4eyuPq0/edit?usp=drivesdk",
          "cachedResultName": "Test Invoice Records"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "credential-id",
          "name": "googleSheetsOAuth2Api Credential"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "d96a6fe2-fe52-4bdc-8199-7c5de0e18d03",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "disabled": true,
      "position": [
        -576,
        -2048
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "60c60b57-a29c-4b84-a364-7ff194338a23",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        416,
        912
      ],
      "parameters": {},
      "typeVersion": 3.1
    },
    {
      "id": "67e50b05-8095-4733-b14d-aac6181163aa",
      "name": "Update File Name",
      "type": "n8n-nodes-base.googleDrive",
      "onError": "continueRegularOutput",
      "position": [
        592,
        912
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "update",
        "newUpdatedFileName": "={{$('Table ERP').first().json['Vendor Name']}} - {{$('Table ERP').first().json['Invoice Number']}}"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "credential-id",
          "name": "googleDriveOAuth2Api Credential"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "08e9f03b-c1b5-4d53-8d63-5be9c1f57187",
      "name": "Save Invoice",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -240,
        912
      ],
      "parameters": {
        "name": "={{ $json.files[0].fileName }}",
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "options": {},
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1nCCa5nxntHv4u-2hSKG9K3cBxrQhA32O",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1nCCa5nxntHv4u-2hSKG9K3cBxrQhA32O",
          "cachedResultName": "Invoices"
        },
        "inputDataFieldName": "data0"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "credential-id",
          "name": "googleDriveOAuth2Api Credential"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "65beec00-7e7f-4f2c-8e49-8c5bc9bcac5a",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -992,
        832
      ],
      "parameters": {
        "color": 5,
        "width": 1988,
        "height": 528,
        "content": "# Invoice Processing"
      },
      "typeVersion": 1
    },
    {
      "id": "d9428d0b-67e2-4f01-af5c-418814e5adbf",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -992,
        -144
      ],
      "parameters": {
        "color": 5,
        "width": 1604,
        "height": 608,
        "content": "# Expenses Processing"
      },
      "typeVersion": 1
    },
    {
      "id": "49d55301-45d9-436a-be83-205938ac8e43",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -976,
        -64
      ],
      "parameters": {
        "width": 340,
        "height": 480,
        "content": "# Donna - Accountant\n\n![My Image](https://i.postimg.cc/yY6MHQ0m/Chat-GPT-Image-Apr-25-2025-12-19-57-PM.png)\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "c638cf56-555c-489d-bb83-bf385ae88af4",
      "name": "Google Drive Trigger",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -544,
        80
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1vBeKYr7XpinvUUCNYDKOiNIhNcDI5By_",
          "cachedResultUrl": "https://drive.google.com/drive/YOUR_AWS_SECRET_KEY_HERE_",
          "cachedResultName": "Expense Receipts"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "credential-id",
          "name": "googleDriveOAuth2Api Credential"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "947a8138-e565-4738-b1c8-8b85068ba6e4",
      "name": "Split Out1",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        400,
        -80
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "parsedData['Line Items']"
      },
      "typeVersion": 1
    },
    {
      "id": "df7a4279-7e74-4faf-8d5a-b87a657ce9d2",
      "name": "Parsed Data1",
      "type": "n8n-nodes-base.set",
      "position": [
        240,
        -128
      ],
      "parameters": {
        "options": {
          "ignoreConversionErrors": true
        },
        "assignments": {
          "assignments": [
            {
              "id": "ac4cf2cc-36af-47a4-8638-852302ec2dbd",
              "name": "parsedData",
              "type": "object",
              "value": "={{$json[\"candidates\"][0][\"content\"][\"parts\"][0][\"text\"].replace(/^```json\\s*|\\s*```$/g, '')}}\n"
            }
          ]
        }
      },
      "retryOnFail": true,
      "typeVersion": 3.4
    },
    {
      "id": "32e2ac3c-d6eb-404b-99df-0ed49d18b3fe",
      "name": "Upload PDF to Google Gemini1",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -160,
        -128
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/upload/v1beta/files",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "binaryData",
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/pdf"
            }
          ]
        },
        "inputDataFieldName": "data",
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "credential-id",
          "name": "googlePalmApi Credential"
        },
        "httpHeaderAuth": {
          "id": "credential-id",
          "name": "httpHeaderAuth Credential"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "2a020ce2-5406-410f-8530-42c8abdc2128",
      "name": "Download Data from Google Gemini1",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        32,
        -128
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-preview-04-17:generateContent",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contents\": [\n    {\n      \"role\": \"user\",\n      \"parts\": [\n        {\n          \"text\": \"Read and analyze this document. If it is an expense receipt, extract and return the following fields in JSON format:\\n- Merchant Name\\n- Transaction Date\\n- Total Amount\\n- Tax Amount (if available)\\n- Payment Method\\n- Line Items (Description, Quantity, Unit Price, Total Price) if available\\nIf it is not an expense receipt, summarize the document content instead in plain text.\"\n        },\n        {\n          \"file_data\": {\n            \"mime_type\": \"application/pdf\",\n            \"file_uri\": {{ JSON.stringify($json.file.uri) }}\n          }\n        }\n      ]\n    }\n  ],\n  \"generationConfig\": {\n    \"responseMimeType\": \"text/plain\",\n    \"maxOutputTokens\": 32768\n  }\n}\n",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "credential-id",
          "name": "googlePalmApi Credential"
        },
        "httpHeaderAuth": {
          "id": "credential-id",
          "name": "httpHeaderAuth Credential"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "0f89afbd-3b0b-48a6-b92d-838655f3424e",
      "name": "Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        192,
        128
      ],
      "parameters": {
        "columns": {
          "value": {
            "Category": "={{ $json.output.category }}",
            "Quantity": "={{ $('Split Out1').item.json.Quantity }}",
            "Tax Amount": "={{ $('Parsed Data1').item.json.parsedData['Tax Amount'] }}",
            "Unit Price": "={{ $('Split Out1').item.json['Unit Price'] }}",
            "Total Price": "={{ $('Split Out1').item.json['Total Price'] }}",
            "Total Amount": "={{ $('Parsed Data1').item.json.parsedData['Total Amount'] }}",
            "Merchant Name": "={{ $('Parsed Data1').item.json.parsedData['Merchant Name'] }}",
            "Payment Method": "={{ $('Parsed Data1').item.json.parsedData['Payment Method'] }}",
            "Transaction Date": "={{ $('Parsed Data1').item.json.parsedData['Transaction Date'] }}",
            "Line Item Description": "={{ $('Split Out1').item.json.Description }}"
          },
          "schema": [
            {
              "id": "Merchant Name",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Merchant Name",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Transaction Date",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Transaction Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Total Amount",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Total Amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Tax Amount",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Tax Amount",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Category",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Category",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Payment Method",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Payment Method",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Line Item Description",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Line Item Description",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Quantity",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Quantity",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Unit Price",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Unit Price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Total Price",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Total Price",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "cellFormat": "USER_ENTERED"
        },
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zhOaSKk29dp0xzL8u3yVY62FEFxuo1I-9hc1pfAsQjs/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1zhOaSKk29dp0xzL8u3yVY62FEFxuo1I-9hc1pfAsQjs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zhOaSKk29dp0xzL8u3yVY62FEFxuo1I-9hc1pfAsQjs/edit?usp=drivesdk",
          "cachedResultName": "Expenses Recording"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "credential-id",
          "name": "googleSheetsOAuth2Api Credential"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "dbe2be8e-98f0-4c74-81ef-b69d80e7759d",
      "name": "Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -368,
        -128
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "credential-id",
          "name": "googleDriveOAuth2Api Credential"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "dc065b83-bae9-4cde-bfc4-2440964d600c",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -992,
        -1136
      ],
      "parameters": {
        "color": 5,
        "width": 2136,
        "height": 512,
        "content": "# Expenses Processing"
      },
      "typeVersion": 1
    },
    {
      "id": "84d2f0ab-ae05-452b-8b00-76c74f167959",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -976,
        -1056
      ],
      "parameters": {
        "width": 340,
        "height": 420,
        "content": "# Victor - Controller\n![My Image](https://i.postimg.cc/m2fryF1z/Chat-GPT-Image-Apr-25-2025-05-10-57-PM.png)\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "f8c79b50-6d77-45f1-b7df-4b48a992402d",
      "name": "Google Drive Trigger1",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -480,
        -976
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "16l6LegAqkV6axZT9WPwr_p2-20VqeiRD",
          "cachedResultUrl": "https://drive.google.com/drive/folders/16l6LegAqkV6axZT9WPwr_p2-20VqeiRD",
          "cachedResultName": "Bank Statements"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "credential-id",
          "name": "googleDriveOAuth2Api Credential"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "529732d1-eee3-471d-80b7-0ac6320ed6d2",
      "name": "Upload PDF to Google Gemini2",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        48,
        -976
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/upload/v1beta/files",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "binaryData",
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/pdf"
            }
          ]
        },
        "inputDataFieldName": "data",
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "credential-id",
          "name": "googlePalmApi Credential"
        },
        "httpHeaderAuth": {
          "id": "credential-id",
          "name": "httpHeaderAuth Credential"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1765ea24-57c2-4c5f-9ca0-70338934195d",
      "name": "Download Data from Google Gemini2",
      "type": "n8n-nodes-base.httpRequest",
      "onError": "continueErrorOutput",
      "position": [
        256,
        -976
      ],
      "parameters": {
        "url": "https://generativelanguage.googleapis.com/v1beta/models/gemini-2.5-flash-preview-04-17:generateContent",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"contents\": [\n    {\n      \"role\": \"user\",\n      \"parts\": [\n        {\n          \"text\": \"Read and analyze this document. If it is a bank statement, extract and return the following fields in JSON format:\\n- Txn ID\\n- Date\\n- Description / Payee\\n- Debit (-)\\n- Credit (+)\\n- Currency\\n- Running Balance\\n- Notes / Category (optional)\\n\\nIf it is not a bank statement, summarize the document content instead in plain text.\"\n        },\n        {\n          \"file_data\": {\n            \"mime_type\": \"application/pdf\",\n            \"file_uri\": {{ JSON.stringify($json.file.uri) }}\n          }\n        }\n      ]\n    }\n  ],\n  \"generationConfig\": {\n    \"responseMimeType\": \"text/plain\",\n    \"maxOutputTokens\": 32768\n  }\n}\n",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "googlePalmApi"
      },
      "credentials": {
        "googlePalmApi": {
          "id": "credential-id",
          "name": "googlePalmApi Credential"
        },
        "httpHeaderAuth": {
          "id": "credential-id",
          "name": "httpHeaderAuth Credential"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "6d94b80f-914f-4c60-b0b8-1fec176ba707",
      "name": "Google Sheets1",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        736,
        -976
      ],
      "parameters": {
        "columns": {
          "value": {
            "Date": "={{ $json.Date }}",
            "Currency": "={{ $json.Currency }}",
            "Debit (-)": "={{ $json['Debit (-)'] }}",
            "Credit (+)": "={{ $json['Credit (+)'] }}",
            "Running Balance": "={{ $json['Running Balance'] }}",
            "Description / Payee": "={{ $json['Description / Payee'] }}"
          },
          "schema": [
            {
              "id": "Transaction ID",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Transaction ID",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Date",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Date",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Description / Payee",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Description / Payee",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Debit (-)",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Debit (-)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Credit (+)",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Credit (+)",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Currency",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Currency",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Running Balance",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Running Balance",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Notes / Category",
              "type": "string",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "Notes / Category",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {
          "cellFormat": "USER_ENTERED"
        },
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1SOknw2I6hgXwwaaRHPPogtGjCP4pUjK-xsfIYYwJnvo/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1SOknw2I6hgXwwaaRHPPogtGjCP4pUjK-xsfIYYwJnvo",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1SOknw2I6hgXwwaaRHPPogtGjCP4pUjK-xsfIYYwJnvo/edit?usp=drivesdk",
          "cachedResultName": "Bank Transactions Record"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "credential-id",
          "name": "googleSheetsOAuth2Api Credential"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "55f393cc-9c47-42db-8803-f1e090459605",
      "name": "Google Drive1",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -256,
        -976
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "credential-id",
          "name": "googleDriveOAuth2Api Credential"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "4b5d634e-53f9-41d5-938c-7cf6efe61411",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        912,
        -976
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "9f21fb2a-c48b-4918-ba56-c98384e1546d",
              "name": "response",
              "type": "string",
              "value": "Recorded!"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "03bc404a-d364-42b4-900f-ca61e4dd9b67",
      "name": "Edit Fields1",
      "type": "n8n-nodes-base.set",
      "position": [
        400,
        128
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "9f21fb2a-c48b-4918-ba56-c98384e1546d",
              "name": "response",
              "type": "string",
              "value": "Recorded!"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "347e16d9-febc-4f44-8539-112ca95e3df5",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        512,
        -976
      ],
      "parameters": {
        "jsCode": "const raw = $json.candidates[0].content.parts[0].text;\nconst match = raw.match(/```json\\s*([\\s\\S]*?)\\s*```/);\nlet body   = (match ? match[1] : raw)\n\t           .replace(/[\\u0000-\\u001F\\u007F-\\u009F]/g, '')\n\t           .replace(/,\\s*([}\\]])/g, '$1');\n\nlet data;\ntry {\n\tdata = JSON.parse(body);            // ← will throw a readable n8n error if still bad\n} catch (err) {\n\tthrow new Error('LLM returned invalid JSON ➜ ' + err.message);\n}\n\n// Normalise: array of rows no matter what\nif (!Array.isArray(data)) data = data.transactions || [data];\nreturn data.map(t => ({ json: t }));\n"
      },
      "typeVersion": 2
    },
    {
      "id": "5ebbafe9-d67e-4e86-be8c-e02c79f177d4",
      "name": "Basic LLM Chain",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -160,
        128
      ],
      "parameters": {
        "text": "={{ $('Download Data from Google Gemini1').item.json.candidates[0].content.parts[0].text }}",
        "messages": {
          "messageValues": [
            {
              "message": "=You are EXPENSE-CLASSIFIER, an expert bookkeeping agent.\n\nTask  \n• Read the input text of one expense (bank-transaction line, receipt, or invoice memo).  \n• Choose exactly **one** category from the allowed list below that best fits.  \n• If no perfect fit exists, pick the closest logical category (never return “unknown”).  \n• Respond ONLY with valid JSON that matches the schema in the next block—no extra keys, no markdown.\n\nAllowed categories  \n- Cost of Goods Sold  \n- Advertising & Marketing  \n- Payroll & Wages  \n- Employee Benefits  \n- Contract Labor  \n- Rent & Leases  \n- Utilities  \n- Office Supplies & G&A  \n- Software & Cloud Subscriptions  \n- Travel Meals & Entertainment  \n- Professional Services  \n- Insurance  \n- Repairs & Maintenance  \n- Taxes & Licenses  \n- Interest Expense  \n- Depreciation & Amortization  \n- Other Miscellaneous\n"
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.6
    },
    {
      "id": "f1a9203a-0d21-46f0-aa9a-afff675427dc",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -160,
        304
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "id": "credential-id",
          "name": "openRouterApi Credential"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "9638204f-cb80-4fb5-a146-055160fd1437",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -16,
        304
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"category\": \"Advertising & Marketing\"\n}\n"
      },
      "typeVersion": 1.2
    },
    {
      "id": "1cbde03d-4562-4b08-9001-e3e13bc7cf9b",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -352,
        -2048
      ],
      "parameters": {
        "text": "={{ $json }}",
        "options": {
          "systemMessage": "You are FinanceDataBot, a specialized agent for extracting and analyzing financial data from spreadsheets.\n\nPRIMARY FUNCTION:\nYour sole purpose is to access, extract, and analyze data from financial spreadsheets when requested by an orchestrator agent. You have access to three key spreadsheets:\n1. Invoices - Contains invoice records with details on clients, amounts, dates, and payment status\n2. Expenses - Contains expense records with categories, amounts, dates, and other relevant details\n3. Transactions - Contains bank transaction records with dates, descriptions, amounts, and transaction types\n\nRESPONSE GUIDELINES:\n1. Always respond with accurate, concise data extractions based on the specific request\n2. Format numerical data appropriately (currency with 2 decimal places)\n3. When providing lists, use clean table formatting\n4. Include summary statistics when appropriate (totals, averages, etc.)\n5. Never share opinions or engage in casual conversation - stay focused on data extraction only\n\nDATA EXTRACTION CAPABILITIES:\n- Filter by date ranges (e.g., \"invoices for December\")\n- Sort and limit results (e.g., \"last 10 transactions\")\n- Calculate aggregates (e.g., \"total value of invoices\")\n- Perform basic analysis (e.g., \"highest expense category\")\n- Identify patterns or anomalies when specifically requested\n\nERROR HANDLING:\n- If data is missing or unavailable, clearly state what information could not be retrieved\n- If a request is ambiguous, ask for clarification on specific parameters needed\n- If a request is outside your capabilities, explain what you can and cannot provide\n\nSECURITY CONSIDERATIONS:\n- You only have access to the three specified spreadsheets\n- Do not attempt to access or modify any other data sources\n- Treat all financial data as confidential\n\nExample requests you should be able to handle:\n- \"What are the last 10 bank transactions?\"\n- \"What is the total value of invoices for December 2023?\"\n- \"List all unpaid invoices sorted by amount\"\n- \"What was our highest expense category last month?\"\n- \"Show me transactions over $1000 in the past week\"\n- \"Calculate the average invoice amount by client\""
        },
        "promptType": "define"
      },
      "typeVersion": 1.9
    },
    {
      "id": "a0d38cbe-d401-458d-afde-7b46172f1b9a",
      "name": "OpenRouter Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        -448,
        -1808
      ],
      "parameters": {
        "model": "openai/gpt-4.1",
        "options": {}
      },
      "credentials": {
        "openRouterApi": {
          "id": "credential-id",
          "name": "openRouterApi Credential"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8fea6832-8064-46d3-a71e-eb42b325e58b",
      "name": "Invoices",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -128,
        -1808
      ],
      "parameters": {
        "options": {
          "dataLocationOnSheet": {
            "values": {
              "rangeDefinition": "detectAutomatically"
            }
          }
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Gjm3ALhZZ7I4Wto0CZYNuEr48K-bgLLK6M8K4eyuPq0/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1Gjm3ALhZZ7I4Wto0CZYNuEr48K-bgLLK6M8K4eyuPq0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1Gjm3ALhZZ7I4Wto0CZYNuEr48K-bgLLK6M8K4eyuPq0/edit?usp=drivesdk",
          "cachedResultName": "Test Invoice Records"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "credential-id",
          "name": "googleSheetsOAuth2Api Credential"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "39e1c9dd-e85d-4548-8c62-24209f4b8fc0",
      "name": "Expenses",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        -32,
        -1808
      ],
      "parameters": {
        "options": {
          "dataLocationOnSheet": {
            "values": {
              "rangeDefinition": "detectAutomatically"
            }
          }
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zhOaSKk29dp0xzL8u3yVY62FEFxuo1I-9hc1pfAsQjs/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1zhOaSKk29dp0xzL8u3yVY62FEFxuo1I-9hc1pfAsQjs",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1zhOaSKk29dp0xzL8u3yVY62FEFxuo1I-9hc1pfAsQjs/edit?usp=drivesdk",
          "cachedResultName": "Expenses Recording"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "credential-id",
          "name": "googleSheetsOAuth2Api Credential"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "df86bfde-6554-4bfd-8cfe-3cc2cfc6d4f8",
      "name": "Transactions",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        64,
        -1808
      ],
      "parameters": {
        "options": {
          "dataLocationOnSheet": {
            "values": {
              "rangeDefinition": "detectAutomatically"
            }
          }
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1SOknw2I6hgXwwaaRHPPogtGjCP4pUjK-xsfIYYwJnvo/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1SOknw2I6hgXwwaaRHPPogtGjCP4pUjK-xsfIYYwJnvo",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1SOknw2I6hgXwwaaRHPPogtGjCP4pUjK-xsfIYYwJnvo/edit?usp=drivesdk",
          "cachedResultName": "Bank Transactions Record"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "credential-id",
          "name": "googleSheetsOAuth2Api Credential"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "bf1db04b-5b67-4334-ab21-1e6e4d40fa6a",
      "name": "Edit Fields2",
      "type": "n8n-nodes-base.set",
      "position": [
        0,
        -2048
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "599d7fa9-e8c5-4c3a-8957-f94c498014bd",
              "name": "Response",
              "type": "string",
              "value": "={{ $json }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "64afa6b9-e8eb-4d73-b124-c19f4051e75d",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -960,
        -2080
      ],
      "parameters": {
        "width": 340,
        "height": 420,
        "content": "# Andrew - CFO\n\n![My Image](https://i.postimg.cc/xT23Z3Ty/Chat-GPT-Image-Apr-24-2025-08-02-30-AM.png)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "583b7a38-910e-4c9f-8c8d-cd0997addc60",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -976,
        -2160
      ],
      "parameters": {
        "color": 5,
        "width": 1232,
        "height": 520,
        "content": "# Finance\n"
      },
      "typeVersion": 1
    },
    {
      "id": "953aaa49-78d5-44b3-846b-c139b2c1d9cb",
      "name": "Sticky Note25",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3792,
        1104
      ],
      "parameters": {
        "color": 7,
        "width": 1344,
        "height": 816,
        "content": "# AutoSolutions.ai - AI Consulting Services\n## Didac Fernandez Girona\n\n\n\n![My Image](https://i.postimg.cc/qvRLbFDL/Long-logo.png)"
      },
      "typeVersion": 1
    },
    {
      "id": "b39dfed5-8164-4ea1-939f-6ed5ade480ba",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3984,
        -2480
      ],
      "parameters": {
        "width": 784,
        "height": 2256,
        "content": "# 🤖 AI-Powered Financial Document Processing Workflow\n\n## 📋 Overview\nThis comprehensive workflow automates financial document processing using AI, handling invoices, expense receipts, and bank statements. It features four AI personas representing different financial roles and automatically extracts, categorizes, and stores financial data in Google Sheets.\n\n## ⭐ Key Features\n- 📄 **Multi-Document Support**: Processes invoices, expense receipts, and bank statements\n- 🧠 **AI-Powered Extraction**: Uses Google Gemini for intelligent data extraction\n- 🏷️ **Automatic Categorization**: Smart expense categorization with 17 predefined categories\n- 💬 **Financial Analysis Agent**: Query your financial data using natural language\n- 📁 **Automated File Management**: Renames and organizes processed documents\n- 👥 **Role-Based Processing**: Four distinct AI personas for different financial functions\n\n## 🔧 Workflow Components\n\n### 1. 📄 Invoice Processing (Mark - Accountant)\n**🚀 Trigger**: Chat interface for invoice uploads\n**⚙️ Process**:\n- 📤 Upload invoice via chat interface\n- 🧠 AI extracts: Vendor Name, Invoice Number, Invoice Date, Due Date, Total Amount, VAT Amount, Line Items\n- 📊 Data saved to \"Test Invoice Records\" Google Sheet\n- 📝 File automatically renamed as \"{Vendor Name} - {Invoice Number}\"\n- ✅ Confirmation message sent\n\n### 2. 🧾 Expense Processing (Donna - Accountant)\n**🚀 Trigger**: Google Drive folder monitoring (\"Expense Receipts\")\n**⚙️ Process**:\n- ⏰ Monitors expense receipts folder every minute\n- 🧠 AI extracts: Merchant Name, Transaction Date, Total Amount, Tax Amount, Payment Method, Line Items\n- 🏷️ Automatic expense categorization using predefined categories\n- 📊 Data saved to \"Expenses Recording\" Google Sheet\n\n**📋 Expense Categories**:\n- 📦 Cost of Goods Sold\n- 📢 Advertising & Marketing\n- 💰 Payroll & Wages\n- 🎯 Employee Benefits\n- 🤝 Contract Labor\n- 🏢 Rent & Leases\n- ⚡ Utilities\n- 📎 Office Supplies & G&A\n- 💻 Software & Cloud Subscriptions\n- ✈️ Travel Meals & Entertainment\n- 👔 Professional Services\n- 🛡️ Insurance\n- 🔧 Repairs & Maintenance\n- 🏛️ Taxes & Licenses\n- 💳 Interest Expense\n- 📉 Depreciation & Amortization\n- 📋 Other Miscellaneous\n\n### 3. 🏦 Bank Statement Processing (Victor - Controller)\n**🚀 Trigger**: Google Drive folder monitoring (\"Bank Statements\")\n**⚙️ Process**:\n- ⏰ Monitors bank statements folder every minute\n- 🧠 AI extracts: Transaction ID, Date, Description/Payee, Debit/Credit, Currency, Running Balance\n- 📊 Data saved to \"Bank Transactions Record\" Google Sheet\n\n### 4. 📈 Financial Analysis Agent (Andrew - CFO)\n**🚀 Trigger**: Manual execution for financial queries\n**🎯 Capabilities**:\n- 🗃️ Access to all three financial spreadsheets\n- 💬 Natural language queries about financial data\n- 📊 Generate reports and insights\n- ❓ Answer questions about invoices, expenses, and transactions\n\n## 🛠️ Setup Requirements\n\n### 🌐 Google Services\n1. **🚗 Google Drive API** credentials configured\n2. **📊 Google Sheets API** credentials configured  \n3. **🧠 Google Gemini API** credentials configured\n4. **🤖 OpenRouter API** credentials for LLM categorization\n\n### 📁 Required Google Drive Folders\nCreate these folders in your Google Drive:\n- 📄 \"Invoices\" (for processed invoice storage)\n- 🧾 \"Expense Receipts\" (monitored for new expense receipts)\n- 🏦 \"Bank Statements\" (monitored for new bank statements)\n\n### 📊 Required Google Sheets\nCreate these spreadsheets with appropriate column headers:\n1. **📄 \"Test Invoice Records\"** - Vendor Name, Invoice Number, Invoice Date, Due Date, Total Amount, VAT Amount, Line Item Description, Quantity, Unit Price, Total Price\n2. **🧾 \"Expenses Recording\"** - Merchant Name, Transaction Date, Total Amount, Tax Amount, Payment Method, Line Item Description, Quantity, Unit Price, Total Price, Category\n3. **🏦 \"Bank Transactions Record\"** - Transaction ID, Date, Description/Payee, Debit (-), Credit (+), Currency, Running Balance, Notes/Category\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "82e8c619-a09b-42bf-b6b9-773d20e821ac",
      "name": "Sticky Note10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3120,
        -848
      ],
      "parameters": {
        "width": 784,
        "height": 640,
        "content": "# 🛠️ Setup Requirements\n\n### 🌐 Google Services\n1. **🚗 Google Drive API** credentials configured\n2. **📊 Google Sheets API** credentials configured  \n3. **🧠 Google Gemini API** credentials configured\n4. **🤖 OpenRouter API** credentials for LLM categorization\n\n### 📁 Required Google Drive Folders\nCreate these folders in your Google Drive:\n- 📄 \"Invoices\" (for processed invoice storage)\n- 🧾 \"Expense Receipts\" (monitored for new expense receipts)\n- 🏦 \"Bank Statements\" (monitored for new bank statements)\n\n### 📊 Required Google Sheets\nCreate these spreadsheets with appropriate column headers:\n1. **📄 \"Test Invoice Records\"** - Vendor Name, Invoice Number, Invoice Date, Due Date, Total Amount, VAT Amount, Line Item Description, Quantity, Unit Price, Total Price\n2. **🧾 \"Expenses Recording\"** - Merchant Name, Transaction Date, Total Amount, Tax Amount, Payment Method, Line Item Description, Quantity, Unit Price, Total Price, Category\n3. **🏦 \"Bank Transactions Record\"** - Transaction ID, Date, Description/Payee, Debit (-), Credit (+), Currency, Running Balance, Notes/Category\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "d842268b-9d80-42da-952c-a0681736a584",
      "name": "Sticky Note11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3120,
        -2480
      ],
      "parameters": {
        "width": 784,
        "height": 1600,
        "content": "# 🎯 How to Use\n\n### 📄 Processing Invoices\n1. 💬 Access the chat interface\n2. 📤 Upload PDF invoice files\n3. ⏳ Wait for AI processing and confirmation\n4. ✅ Check \"Test Invoice Records\" Google Sheet for extracted data\n5. 📁 Processed files will be renamed and stored in \"Invoices\" folder\n\n### 🧾 Processing Expense Receipts\n1. 📤 Upload PDF receipts to \"Expense Receipts\" Google Drive folder\n2. ⚙️ Workflow automatically processes new files every minute\n3. ✅ Check \"Expenses Recording\" Google Sheet for categorized expenses\n4. 🏷️ AI automatically assigns appropriate expense categories\n\n### 🏦 Processing Bank Statements\n1. 📤 Upload PDF bank statements to \"Bank Statements\" Google Drive folder\n2. ⚙️ Workflow automatically processes new files every minute\n3. ✅ Check \"Bank Transactions Record\" Google Sheet for transaction data\n\n### 💬 Querying Financial Data\n1. ▶️ Execute the \"When Executed by Another Workflow\" trigger\n2. 🗣️ Send natural language queries about your financial data\n3. 💡 Examples:\n   - \"What are the last 10 bank transactions?\"\n   - \"What is the total value of invoices for December 2023?\"\n   - \"List all unpaid invoices sorted by amount\"\n   - \"What was our highest expense category last month?\"\n   - \"Show me transactions over $1000 in the past week\"\n\n## 📁 Supported File Formats\n- **📄 PDF files only** (invoices, receipts, bank statements)\n- 🔍 Ensure documents are clear and legible for optimal AI extraction\n\n## ⚠️ Error Handling\n- ✅ Workflow continues processing even if individual documents fail\n- 📝 Error outputs are logged for troubleshooting\n- 🔧 Failed extractions can be manually reviewed and corrected\n\n## 👥 AI Personas\n- **📄 Mark (Accountant)**: Handles invoice processing with attention to vendor details and payment terms\n- **🧾 Donna (Accountant)**: Manages expense categorization and receipt processing\n- **🏦 Victor (Controller)**: Oversees bank statement processing and transaction reconciliation\n- **📈 Andrew (CFO)**: Provides high-level financial analysis and reporting\n\n## 🎉 Benefits\n- ⏰ **Time Savings**: Automates manual data entry from financial documents\n- 🎯 **Accuracy**: AI-powered extraction reduces human error\n- 📂 **Organization**: Automatic file naming and categorization\n- 💡 **Insights**: Query financial data using natural language\n- 📈 **Scalability**: Processes multiple documents simultaneously\n- 🛡️ **Compliance**: Maintains organized records for accounting and audit purposes\n\n## 🔧 Troubleshooting\n- ✅ Ensure all API credentials are properly configured\n- 📁 Verify Google Drive folder permissions allow the workflow to access files\n- 📊 Check that Google Sheets have the correct column headers\n- 📝 Monitor workflow execution logs for any processing errors\n- 📄 Test with clear, high-quality PDF documents for best resultshooting\n- Ensure all API credentials are properly configured\n- Verify Google Drive folder permissions allow the workflow to access files\n- Check that Google Sheets have the correct column headers\n- Monitor workflow execution logs for any processing errors\n- Test with clear, high-quality PDF documents for best results"
      },
      "typeVersion": 1
    },
    {
      "id": "114a10ca-24f0-492d-af38-45795bab1666",
      "name": "📄 Invoice Processing Documentation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2224,
        816
      ],
      "parameters": {
        "color": 5,
        "width": 772,
        "height": 1112,
        "content": "# 📄 INVOICE PROCESSING SECTION\n\n## 🎯 Purpose\nThis section handles invoice processing through a chat interface. Mark, the AI Accountant, extracts key invoice data and stores it in Google Sheets.\n\n## 🔄 Process Flow\n1. **💬 Chat Trigger**: Users upload PDF invoices via chat\n2. **📁 File Storage**: Invoice saved to Google Drive \"Invoices\" folder\n3. **🤖 AI Processing**: Google Gemini extracts invoice data\n4. **📊 Data Storage**: Information saved to \"Test Invoice Records\" spreadsheet\n5. **📝 File Renaming**: File renamed as \"{Vendor Name} - {Invoice Number}\"\n6. **✅ Confirmation**: Success message sent to user\n\n## 📋 Extracted Fields\n- Vendor Name\n- Invoice Number\n- Invoice Date\n- Due Date\n- Total Amount\n- VAT Amount\n- Line Items (Description, Quantity, Unit Price, Total Price)\n\n## ⚙️ Configuration Notes\n- Chat trigger allows all file types but processes PDF only\n- Error handling continues processing even if extraction fails\n- Files are stored with original name then renamed after processing"
      },
      "typeVersion": 1
    },
    {
      "id": "b838b4c4-545c-411d-b6cd-9041479f72e9",
      "name": "Mark - Accountant",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1344,
        832
      ],
      "parameters": {
        "color": 6,
        "width": 324,
        "height": 528,
        "content": "# Mark - Accountant 👨‍💼\n\n**Role**: Invoice Processing Specialist\n\n**Responsibilities**:\n- ✅ Extract vendor information\n- ✅ Capture payment terms\n- ✅ Process line item details\n- ✅ Ensure data accuracy\n\n**AI Capabilities**:\n- 🧠 Intelligent field recognition\n- 📋 Structured data extraction\n- 🔍 Quality validation"
      },
      "typeVersion": 1
    },
    {
      "id": "de948508-c38d-47aa-9a57-3972a854fd3f",
      "name": "💾 Save File Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1344,
        1392
      ],
      "parameters": {
        "color": 3,
        "width": 268,
        "height": 488,
        "content": "# 📤 STEP 1: File Upload & Storage\n\n**Purpose**: Save uploaded invoice to Google Drive\n\n**Configuration**:\n- 📁 Target Folder: \"Invoices\"\n- 📄 Input Field: data0 (from chat upload)\n- 📝 Filename: Uses original uploaded filename\n\n**Output**: File ID and metadata for downstream processing"
      },
      "typeVersion": 1
    },
    {
      "id": "d76a1641-f669-4ca7-a72e-ea3a5f3cd6c9",
      "name": "🤖 Upload to AI Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1056,
        1392
      ],
      "parameters": {
        "color": 3,
        "width": 220,
        "height": 488,
        "content": "# 🤖 STEP 2: AI Upload\n\n**Purpose**: Upload PDF to Google Gemini for processing\n\n**Configuration**:\n- 🔗 Endpoint: Gemini File Upload API\n- 📄 Content-Type: application/pdf\n- 🔐 Auth: Google PaLM API credentials\n- 📊 Input: Binary data from chat upload\n\n**Output**: File URI for Gemini processing"
      },
      "typeVersion": 1
    },
    {
      "id": "f91e1f93-c743-400a-bbd9-520edd6169d0",
      "name": "🧠 Data Extraction Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -816,
        1392
      ],
      "parameters": {
        "color": 3,
        "width": 252,
        "height": 488,
        "content": "# 🧠 STEP 3: Data Extraction\n\n**Purpose**: Use Gemini AI to extract structured invoice data\n\n**AI Prompt**: Extracts:\n- 🏢 Vendor Name\n- 🔢 Invoice Number\n- 📅 Invoice Date\n- 📅 Due Date\n- 💰 Total Amount\n- 💰 VAT Amount\n- 📋 Line Items\n\n**Output**: JSON structured data or plain text summary"
      },
      "typeVersion": 1
    },
    {
      "id": "aa42f2bd-4ee3-45f3-a671-33eff825a42e",
      "name": "📋 JSON Parsing Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -544,
        1392
      ],
      "parameters": {
        "color": 3,
        "width": 236,
        "height": 488,
        "content": "# 📋 STEP 4: JSON Parsing\n\n**Purpose**: Clean and parse AI response into structured data\n\n**Process**:\n- 🧹 Remove markdown code blocks\n- 📊 Convert text to JSON object\n- ⚠️ Handle parsing errors gracefully\n- 🔄 Retry on failure\n\n**Output**: Clean parsedData object for spreadsheet"
      },
      "typeVersion": 1
    },
    {
      "id": "4207bb87-5651-4107-afd1-c74fa3ffe2e9",
      "name": "📑 Split Items Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -288,
        1392
      ],
      "parameters": {
        "color": 3,
        "width": 236,
        "height": 488,
        "content": "# 📑 STEP 5: Line Item Processing\n\n**Purpose**: Split line items for individual spreadsheet rows\n\n**Process**:\n- 📋 Extract Line Items array from parsed data\n- 🔄 Create separate execution for each line item\n- 📊 Enables detailed item-level tracking\n\n**Output**: Individual line items for Google Sheets"
      },
      "typeVersion": 1
    },
    {
      "id": "09ea2e0e-3455-4a4f-b104-caf7e145ed59",
      "name": "📊 Save to Sheet Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        1392
      ],
      "parameters": {
        "color": 3,
        "width": 268,
        "height": 488,
        "content": "# 📊 STEP 6: Save to Spreadsheet\n\n**Purpose**: Store extracted invoice data in Google Sheets\n\n**Mapping**:\n- 🏢 Vendor Name → Header data\n- 🔢 Invoice Number → Header data\n- 📅 Dates → Header data\n- 💰 Amounts → Header data\n- 📋 Line Items → Individual rows\n\n**Sheet**: Test Invoice Records\n**Format**: USER_ENTERED (preserves formatting)"
      },
      "typeVersion": 1
    },
    {
      "id": "7696a262-8c9c-4f0a-89ba-0998fef40fcb",
      "name": "🔗 Merge Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        1392
      ],
      "parameters": {
        "color": 3,
        "width": 218,
        "height": 486,
        "content": "# 🔗 STEP 7: Data Merge\n\n**Purpose**: Combine file metadata with processed data\n\n**Inputs**:\n- 📁 File information from Google Drive\n- 📊 Processed invoice data from sheets\n\n**Output**: Combined data for file renaming"
      },
      "typeVersion": 1
    },
    {
      "id": "f6db208f-ead8-4762-afde-d82c511344e8",
      "name": "📝 Rename Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        496,
        1392
      ],
      "parameters": {
        "color": 3,
        "width": 202,
        "height": 486,
        "content": "# 📝 STEP 8: File Renaming\n\n**Purpose**: Rename file with vendor and invoice number\n\n**Format**: \"{Vendor Name} - {Invoice Number}\"\n\n**Example**: \"Acme Corp - INV-2024-001\"\n\n**Error Handling**: Continues even if renaming fails"
      },
      "typeVersion": 1
    },
    {
      "id": "c23af4ed-ad50-4992-8bd2-fb884121e17c",
      "name": "✅ Confirmation Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        720,
        1392
      ],
      "parameters": {
        "color": 3,
        "width": 250,
        "height": 486,
        "content": "# ✅ STEP 9: Confirmation\n\n**Purpose**: Send success message to user\n\n**Message**: Confirms invoice processing completion\n\n**Includes**: Reference to check Google Sheet\n\n**User Experience**: Clear feedback on completion"
      },
      "typeVersion": 1
    },
    {
      "id": "619818b5-2e30-46ef-a1fe-c9653e9fe662",
      "name": "🧾 Expense Processing Documentation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2224,
        -448
      ],
      "parameters": {
        "color": 5,
        "width": 772,
        "height": 1232,
        "content": "# 🧾 EXPENSE PROCESSING SECTION\n\n## 🎯 Purpose\nThis section monitors a Google Drive folder for new expense receipts. Donna, the AI Accountant, extracts expense data and automatically categorizes it using AI.\n\n## 🔄 Process Flow\n1. **📁 Drive Monitor**: Watches \"Expense Receipts\" folder every minute\n2. **📥 File Download**: Downloads new PDF files\n3. **🤖 AI Processing**: Google Gemini extracts expense data\n4. **🏷️ AI Categorization**: OpenRouter LLM categorizes expenses\n5. **📊 Data Storage**: Information saved to \"Expenses Recording\" spreadsheet\n6. **✅ Completion**: Process confirmation\n\n## 📋 Extracted Fields\n- Merchant Name\n- Transaction Date\n- Total Amount\n- Tax Amount\n- Payment Method\n- Line Items (if available)\n- AI-Generated Category\n\n## 🏷️ Expense Categories (17 Total)\n- 📦 Cost of Goods Sold\n- 📢 Advertising & Marketing\n- 💰 Payroll & Wages\n- 🎯 Employee Benefits\n- 🤝 Contract Labor\n- 🏢 Rent & Leases\n- ⚡ Utilities\n- 📎 Office Supplies & G&A\n- 💻 Software & Cloud Subscriptions\n- ✈️ Travel Meals & Entertainment\n- 👔 Professional Services\n- 🛡️ Insurance\n- 🔧 Repairs & Maintenance\n- 🏛️ Taxes & Licenses\n- 💳 Interest Expense\n- 📉 Depreciation & Amortization\n- 📋 Other Miscellaneous\n\n## ⚙️ Configuration Notes\n- Monitors folder every minute for new files\n- Processes PDF files automatically\n- AI categorization uses structured output parsing\n- Error handling continues processing other files"
      },
      "typeVersion": 1
    },
    {
      "id": "be419798-2cc6-4819-9a1d-59201efe77c3",
      "name": "📁 Expense Trigger Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        176
      ],
      "parameters": {
        "color": 4,
        "width": 492,
        "height": 296,
        "content": "# 📁 EXPENSE TRIGGER\n\n**Purpose**: Monitor Google Drive folder for new expense receipts\n\n**Configuration**:\n- 📂 Folder: \"Expense Receipts\"\n- ⏰ Frequency: Every minute\n- 🚨 Event: File created\n- 📄 File Types: All (but processes PDF)\n\n**Output**: File metadata for new uploads"
      },
      "typeVersion": 1
    },
    {
      "id": "791fb721-f346-42d8-9628-1d5b2db5ab24",
      "name": "🏷️ Categorization Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        640,
        -144
      ],
      "parameters": {
        "color": 4,
        "width": 492,
        "height": 296,
        "content": "# 🏷️ AI CATEGORIZATION\n\n**Purpose**: Automatically categorize expenses using AI\n\n**Process**:\n- 🤖 Uses OpenRouter LLM\n- 📋 17 predefined categories\n- 🎯 Structured JSON output\n- 🧠 Context-aware classification\n\n**Output**: Category assignment for expense"
      },
      "typeVersion": 1
    },
    {
      "id": "39b5e552-93b9-437b-b2ce-2ca403a7cd8a",
      "name": "🏦 Bank Statement Processing Documentation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2224,
        -1328
      ],
      "parameters": {
        "color": 5,
        "width": 772,
        "height": 856,
        "content": "# 🏦 BANK STATEMENT PROCESSING SECTION\n\n## 🎯 Purpose\nThis section monitors a Google Drive folder for new bank statements. Victor, the AI Controller, extracts transaction data for reconciliation and analysis.\n\n## 🔄 Process Flow\n1. **📁 Drive Monitor**: Watches \"Bank Statements\" folder every minute\n2. **📥 File Download**: Downloads new PDF bank statements\n3. **🤖 AI Processing**: Google Gemini extracts transaction data\n4. **🔄 Data Parsing**: Custom code handles multiple transactions\n5. **📊 Data Storage**: Information saved to \"Bank Transactions Record\" spreadsheet\n6. **✅ Completion**: Process confirmation\n\n## 📋 Extracted Fields\n- Transaction ID\n- Date\n- Description / Payee\n- Debit (-)\n- Credit (+)\n- Currency\n- Running Balance\n- Notes / Category (optional)\n\n## ⚙️ Configuration Notes\n- Monitors folder every minute for new files\n- Processes PDF bank statements automatically\n- Custom JavaScript code handles transaction arrays\n- Error handling continues processing other files\n- Supports multiple transaction formats"
      },
      "typeVersion": 1
    },
    {
      "id": "cba011da-354b-4c58-9942-f6f5fb6b4135",
      "name": "Victor - Controller",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1344,
        -1136
      ],
      "parameters": {
        "color": 6,
        "width": 324,
        "height": 512,
        "content": "# Victor - Controller 👨‍💼\n\n**Role**: Bank Statement Processing & Transaction Reconciliation\n\n**Responsibilities**:\n- ✅ Extract transaction details\n- ✅ Process multiple transactions per statement\n- ✅ Maintain running balances\n- ✅ Handle various bank formats\n\n**AI Capabilities**:\n- 🧠 Multi-transaction extraction\n- 📊 Balance reconciliation\n- 🔄 Format standardization"
      },
      "typeVersion": 1
    },
    {
      "id": "c3b83adc-d38c-4b18-ae37-a5e801c7b4d5",
      "name": "🔄 Bank Parser Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1168,
        -1136
      ],
      "parameters": {
        "color": 4,
        "width": 348,
        "height": 504,
        "content": "# 🔄 CUSTOM TRANSACTION PARSER\n\n**Purpose**: Parse multiple bank transactions from AI response\n\n**Features**:\n- 🧹 Cleans JSON formatting\n- 📊 Handles multiple response formats\n- 🔄 Converts to n8n array format\n- ⚠️ Comprehensive error handling\n\n**Output**: Individual transaction objects"
      },
      "typeVersion": 1
    },
    {
      "id": "173fbf7e-f00e-4ab8-a1b9-a63aacb17648",
      "name": "📈 Financial Analysis Documentation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2224,
        -2480
      ],
      "parameters": {
        "color": 5,
        "width": 756,
        "height": 1104,
        "content": "# 📈 FINANCIAL ANALYSIS AGENT SECTION\n\n## 🎯 Purpose\nAndrew, the AI CFO, provides intelligent financial analysis and reporting. He can access all three financial spreadsheets and answer complex queries using natural language.\n\n## 🔄 Process Flow\n1. **▶️ Manual Trigger**: Execute when financial analysis is needed\n2. **🤖 AI Agent**: Uses advanced LLM for data analysis\n3. **📊 Data Access**: Connects to all three Google Sheets\n4. **💬 Natural Language**: Processes queries in plain English\n5. **📈 Analysis**: Generates insights and reports\n6. **📋 Response**: Formatted results and recommendations\n\n## 🗃️ Data Access\n- **📄 Invoices**: Client billing and payment tracking\n- **🧾 Expenses**: Categorized expense analysis\n- **🏦 Transactions**: Bank account reconciliation\n\n## 💡 Query Examples\n- \"What are the last 10 bank transactions?\"\n- \"What is the total value of invoices for December 2023?\"\n- \"List all unpaid invoices sorted by amount\"\n- \"What was our highest expense category last month?\"\n- \"Show me transactions over $1000 in the past week\"\n- \"Calculate the average invoice amount by client\"\n- \"Compare Q3 vs Q4 expenses by category\"\n- \"Generate a cash flow summary for the last quarter\"\n\n## 🤖 AI Capabilities\n- **📊 Data Analysis**: Complex calculations and aggregations\n- **📈 Trend Analysis**: Identify patterns and insights\n- **📋 Report Generation**: Structured financial reports\n- **💬 Natural Language**: No SQL or technical knowledge required\n- **🔍 Data Mining**: Find specific transactions or patterns\n\n## ⚙️ Configuration Notes\n- Uses GPT-4.1 via OpenRouter for advanced reasoning\n- Connected to all three financial spreadsheets as tools\n- Disabled by default - enable when analysis is needed\n- Maintains data confidentiality and security"
      },
      "typeVersion": 1
    },
    {
      "id": "3bca707d-5591-48aa-9d2b-463f3d116b87",
      "name": "Andrew - CFO",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1328,
        -2160
      ],
      "parameters": {
        "color": 6,
        "width": 308,
        "height": 512,
        "content": "# Andrew - CFO 👨‍💼\n\n**Role**: Financial Analysis & Strategic Reporting\n\n**Responsibilities**:\n- ✅ Generate financial insights\n- ✅ Answer complex queries\n- ✅ Create executive reports\n- ✅ Provide strategic recommendations\n\n**AI Capabilities**:\n- 🧠 Advanced data analysis\n- 📊 Multi-source data synthesis\n- 💬 Natural language processing\n- 📈 Trend identification"
      },
      "typeVersion": 1
    },
    {
      "id": "c12b117e-e2f7-4c01-895a-5d30f1b1d973",
      "name": "📊 Analysis Trigger Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        288,
        -2160
      ],
      "parameters": {
        "color": 4,
        "width": 300,
        "height": 518,
        "content": "# 📊 ANALYSIS TRIGGER\n\n**Purpose**: Manual trigger for financial analysis queries\n\n**Usage**:\n- 🔘 Enable this trigger when analysis is needed\n- 💬 Send financial queries to the AI agent\n- 📈 Get insights from all your financial data\n\n**Note**: Disabled by default for security"
      },
      "typeVersion": 1
    },
    {
      "id": "47cd562d-1c49-46c4-94ab-ce6bd0f2a2de",
      "name": "🗃️ Data Tools Instructions",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        624,
        -2160
      ],
      "parameters": {
        "color": 4,
        "width": 302,
        "height": 520,
        "content": "# 🗃️ DATA ACCESS TOOLS\n\n**Purpose**: Connect AI agent to financial spreadsheets\n\n**Tools Available**:\n- 📄 **Invoices Tool**: Invoice records and billing data\n- 🧾 **Expenses Tool**: Categorized expense tracking\n- 🏦 **Transactions Tool**: Bank transaction history\n\n**Features**:\n- 🔍 Auto-detect data ranges\n- 📊 Full spreadsheet access\n- 🔐 Secure authentication\n- 📈 Real-time data access"
      },
      "typeVersion": 1
    },
    {
      "id": "e2d55436-ebd7-48a8-9b99-02c04444afad",
      "name": "Donna - Accountant",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1344,
        -144
      ],
      "parameters": {
        "color": 6,
        "width": 324,
        "height": 608,
        "content": "# Donna - Accountant 👩‍💼\n\n**Role**: Expense Processing & Categorization Specialist\n\n**Responsibilities**:\n- ✅ Extract merchant & transaction details\n- ✅ Categorize expenses automatically\n- ✅ Process receipt line items\n- ✅ Ensure compliance categorization\n\n**AI Capabilities**:\n- 🧠 Smart expense categorization\n- 📋 Receipt data extraction\n- 🏷️ 17-category classification system"
      },
      "typeVersion": 1
    },
    {
      "id": "40503797-869e-46ec-ad59-83f94f78d757",
      "name": "Sticky Note13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1376,
        800
      ],
      "parameters": {
        "color": 7,
        "width": 2416,
        "height": 1152,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "e3db55b4-86fe-44f8-9bf8-3e97f5db942f",
      "name": "Sticky Note14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1376,
        -176
      ],
      "parameters": {
        "color": 7,
        "width": 2544,
        "height": 688,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "c3f4650a-f442-417d-b446-af32cb3bfeca",
      "name": "Sticky Note15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1376,
        -1168
      ],
      "parameters": {
        "color": 7,
        "width": 2928,
        "height": 576,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "5720a9c7-16ec-412b-80ed-a32c70eeb9f6",
      "name": "Sticky Note16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1376,
        -2208
      ],
      "parameters": {
        "color": 7,
        "width": 2352,
        "height": 608,
        "content": ""
      },
      "typeVersion": 1
    },
    {
      "id": "423bea12-2767-48d3-844b-26815d45960a",
      "name": "Sticky Note26",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3520,
        80
      ],
      "parameters": {
        "color": 7,
        "width": 848,
        "height": 848,
        "content": "![My Image](https://i.postimg.cc/3RCvSmDS/Untitled-design-10.png)"
      },
      "typeVersion": 1
    },
    {
      "id": "904576db-3e5a-4b7d-bb64-0f181163ed51",
      "name": "Sticky Note27",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1936,
        -3376
      ],
      "parameters": {
        "color": 7,
        "width": 1312,
        "height": 784,
        "content": "![My Image](https://i.postimg.cc/k4nQdT9X/replicate-prediction-w27bjb3hxxrm80csj5t8211288.jpg)"
      },
      "typeVersion": 1
    },
    {
      "id": "4b28450e-ede0-4ac3-8120-19c5dea201ab",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1552,
        -3504
      ],
      "parameters": {
        "width": 544,
        "height": 80,
        "content": "# Virtual Accounting Department"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "Google Sheets1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Update File Name",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Edit Fields2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Expenses": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Invoices": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Table ERP",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Table ERP": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Split Out1": {
      "main": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parsed Data": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive": {
      "main": [
        [
          {
            "node": "Upload PDF to Google Gemini1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parsed Data1": {
      "main": [
        [
          {
            "node": "Split Out1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save Invoice": {
      "main": [
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transactions": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive1": {
      "main": [
        [
          {
            "node": "Upload PDF to Google Gemini2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets": {
      "main": [
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets1": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Basic LLM Chain": {
      "main": [
        [
          {
            "node": "Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Update File Name": {
      "main": [
        [
          {
            "node": "Confirmation",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Google Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger1": {
      "main": [
        [
          {
            "node": "Google Drive1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Basic LLM Chain",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "Upload PDF to Google Gemini",
            "type": "main",
            "index": 0
          },
          {
            "node": "Save Invoice",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload PDF to Google Gemini": {
      "main": [
        [
          {
            "node": "Download Data from Google Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload PDF to Google Gemini1": {
      "main": [
        [
          {
            "node": "Download Data from Google Gemini1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload PDF to Google Gemini2": {
      "main": [
        [
          {
            "node": "Download Data from Google Gemini2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Data from Google Gemini": {
      "main": [
        [
          {
            "node": "Parsed Data",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Upload PDF to Google Gemini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Data from Google Gemini1": {
      "main": [
        [
          {
            "node": "Parsed Data1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Upload PDF to Google Gemini1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download Data from Google Gemini2": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Upload PDF to Google Gemini2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}