{
  "name": "Detect duplicate invoice PDFs from Gmail with easybits and Google Sheets",
  "nodes": [
    {
      "id": "4477bb85-84c0-41a0-a05c-6b3bac0698f3",
      "name": "Check Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        -528,
        112
      ]
    },
    {
      "id": "51fa97a3-3b7f-42ea-9ead-4a5a9e239803",
      "name": "Already Exists?",
      "type": "n8n-nodes-base.if",
      "position": [
        -208,
        112
      ]
    },
    {
      "id": "7553896e-f939-4262-af1f-756b25c5be25",
      "name": "Add to Master List",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        64,
        256
      ]
    },
    {
      "id": "2fd986c1-a8b6-4adc-aec6-7daf8685295c",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -1328,
        112
      ]
    },
    {
      "id": "e5527bfa-9a24-4208-b1e3-ca695830d977",
      "name": "Extract from File",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -1088,
        112
      ]
    },
    {
      "id": "61cb08f9-ad41-4d68-b46d-3e44218464a2",
      "name": "Edit Fields",
      "type": "n8n-nodes-base.set",
      "position": [
        -928,
        112
      ]
    },
    {
      "id": "2b847aff-69f7-4240-b1b2-5af669594158",
      "name": "HTTP Request",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -768,
        112
      ]
    },
    {
      "id": "f6d5d00e-1e16-4fe7-bfb5-a5313c1b9d86",
      "name": "Code in JavaScript",
      "type": "n8n-nodes-base.code",
      "position": [
        -368,
        112
      ]
    },
    {
      "id": "1b20a65c-608c-4118-a914-5141edab83ac",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1392,
        -48
      ],
      "parameters": {
        "width": 224,
        "height": 336,
        "content": "## 📧 Email Intake\nPolls Gmail every minute for emails with the **invoice** label.\nDownloads attachments automatically."
      }
    },
    {
      "id": "bf9d9a2f-5a9c-404b-b926-2e508a183224",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1152,
        -48
      ],
      "parameters": {
        "width": 544,
        "height": 336,
        "content": "## 📄 Invoice Extraction with easybits\nExtracts the PDF attachment, converts it to base64, and sends it to the **easybits' extractor API** to pull structured invoice data (invoice number, amount, etc.)"
      }
    },
    {
      "id": "22ca9538-3bad-4cda-a10a-ae8ec96f79d8",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -592,
        -48
      ],
      "parameters": {
        "width": 544,
        "height": 336,
        "content": "## 🔍 Duplicate Check\nReads all rows from the **Master Finance File** in Google Sheets. A Code node compares the extracted invoice number against existing entries. Returns `duplicate: true/false`."
      }
    },
    {
      "id": "3d6bc7f4-f812-49a4-a23e-0a63f8b39e29",
      "name": "Slack: Alert Finance",
      "type": "n8n-nodes-base.slack",
      "position": [
        64,
        -64
      ]
    },
    {
      "id": "e4f0a16b-8041-4202-989b-63a647a64728",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        -208
      ],
      "parameters": {
        "width": 304,
        "height": 304,
        "content": "## 🚨 Duplicate Found\nIf the invoice **already exists** in the sheet, a Slack DM is sent to the user with the duplicate invoice number for manual review."
      }
    },
    {
      "id": "1b22bf73-e06f-40af-95d8-09564226374b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -32,
        112
      ],
      "parameters": {
        "width": 304,
        "height": 304,
        "content": "## ✅ New Invoice\nIf the invoice is **not** a duplicate, it gets appended to the Master Finance File in Google Sheets with the invoice number and total amount."
      }
    },
    {
      "id": "4d296449-cb5c-466e-b618-a39fe24ee6f0",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2192,
        -304
      ],
      "parameters": {
        "width": 784,
        "height": 832,
        "content": "# 🔍 Invoice Duplicate Checker\n\n## How It Works\nThis workflow automatically detects duplicate invoices from Gmail. Incoming PDF attachments are scanned by the easybits data extraction solution, then ch"
      }
    }
  ],
  "connections": {
    "Edit Fields": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTTP Request": {
      "main": [
        [
          {
            "node": "Check Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Extract from File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Already Exists?": {
      "main": [
        [
          {
            "node": "Slack: Alert Finance",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Add to Master List",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from File": {
      "main": [
        [
          {
            "node": "Edit Fields",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Code in JavaScript": {
      "main": [
        [
          {
            "node": "Already Exists?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Google Sheets": {
      "main": [
        [
          {
            "node": "Code in JavaScript",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}