{
  "name": "Extract structured data from Gmail attachments to Google Sheets, GPT vision",
  "nodes": [
    {
      "id": "762adf7a-01c4-44f8-800b-b084812cf0c3",
      "name": "Workflow Description",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2384,
        1216
      ],
      "parameters": {
        "width": 380,
        "height": 776,
        "content": "##  Email Attachment Processor Template\n\nAutomatically extract structured information from emails using AI.\n\n### What this workflow does:\n1. **Monitors Gmail** for emails from specified domains\n2. **C"
      }
    },
    {
      "id": "1a385d9d-4e9a-4a56-beb3-4d3e7dd9649b",
      "name": "Email Classification Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3040,
        1184
      ],
      "parameters": {
        "width": 332,
        "height": 336,
        "content": "###  Email Type Detection\n\n**Customize keywords for your use case:**\n\n**Category A (e.g., Cancellation):**\n- Add your keywords here\n\n**Category B (e.g., Updates):**\n- Add your keywords here\n\n**Categor"
      }
    },
    {
      "id": "579e95c7-8c34-4446-a229-061652df9808",
      "name": "Gmail Labels Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6560,
        1264
      ],
      "parameters": {
        "width": 280,
        "height": 216,
        "content": "###  Gmail Labels\n\nProcessed emails are labeled:\n- Processed_CategoryA\n- Processed_CategoryB\n- Processed_CategoryC\n\nLabels are created automatically if they don't exist.\n\n**Customize label names in th"
      }
    },
    {
      "id": "e852a330-e3ae-4b4f-b887-eec29afafa25",
      "name": "File Processing Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3696,
        1152
      ],
      "parameters": {
        "width": 300,
        "height": 344,
        "content": "###  File Processing Routes\n\n**Excel files (Category C):**\n→ Direct data extraction\n\n**Excel files (Category A/B):**\n→ GPT Vision analysis\n\n**PPTX/PDF files:**\n→ Convert to images → GPT Vision\n\n**Imag"
      }
    },
    {
      "id": "eb599c2d-491a-4824-85b9-a503a4b65c47",
      "name": "ConvertAPI Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4176,
        1760
      ],
      "parameters": {
        "width": 300,
        "height": 284,
        "content": "###  ConvertAPI Setup\n\nUsed for converting PPTX/PDF to images for GPT Vision analysis.\n\nhttps://www.convertapi.com\n\n*This service is paid but offers free initial conversions.*\n\nReplace the HTTP Header"
      }
    },
    {
      "id": "5b69b7ca-b4e1-42d3-ab8b-cfb915f745a1",
      "name": "Google Sheets Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        6128,
        1136
      ],
      "parameters": {
        "width": 300,
        "height": 368,
        "content": "###  Google Sheets Output\n\nExtracted data is saved with columns:\n- email_type (Category)\n- field_1 (Date)\n- field_2 (Time)\n- field_3 (Name)\n- field_4 (Amount)\n- And more...\n\n**Customize the output sch"
      }
    },
    {
      "id": "9a32ec51-62fb-49c8-9941-60bf6a1adc13",
      "name": "AWS S3 Info",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        4208,
        1024
      ],
      "parameters": {
        "width": 300,
        "height": 288,
        "content": "###  AWS S3 Setup\n\nImages are temporarily uploaded to S3 for GPT Vision processing.\n\n**Required:**\n1. Create an S3 bucket\n2. Configure AWS credentials in n8n\n3. Update bucket name in Variables\n\nImages"
      }
    },
    {
      "id": "61bd3fd0-9fdd-4cf0-9edf-28721a2358da",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        2832,
        1536
      ]
    },
    {
      "id": "11ce6b59-1436-4ef5-a0ef-71f9aa98c763",
      "name": "Gmail - Get Emails",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3040,
        1536
      ]
    },
    {
      "id": "a6dff01e-96d5-4c57-8def-5bd8c1216c26",
      "name": "Domain Filter",
      "type": "n8n-nodes-base.code",
      "position": [
        3264,
        1536
      ]
    },
    {
      "id": "e303d6d7-5c68-4fc6-97d4-4e5e6c171472",
      "name": "Filter Valid Emails",
      "type": "n8n-nodes-base.filter",
      "position": [
        3488,
        1536
      ]
    },
    {
      "id": "6a426693-2bfc-4d4a-a17a-9f89973f9dc9",
      "name": "Gmail - Get Attachments",
      "type": "n8n-nodes-base.gmail",
      "position": [
        3712,
        1536
      ]
    },
    {
      "id": "7ce1026b-c28f-4e63-95fc-8dcb61814c3f",
      "name": "Detect File Types",
      "type": "n8n-nodes-base.code",
      "position": [
        3920,
        1536
      ]
    },
    {
      "id": "64aef15e-2374-4845-acc6-0dfe45d35c8f",
      "name": "IF - Has Excel?",
      "type": "n8n-nodes-base.if",
      "position": [
        4144,
        1536
      ]
    },
    {
      "id": "7c133bed-216b-49fe-a6d9-8e7292391f87",
      "name": "Extract from Excel",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        4368,
        1344
      ]
    },
    {
      "id": "ae047edd-7921-47cd-84c1-98f9fd5b3ae2",
      "name": "Parse Excel Data",
      "type": "n8n-nodes-base.code",
      "position": [
        5008,
        1216
      ]
    },
    {
      "id": "edbfd491-dbab-411d-a3d2-c674ee34020d",
      "name": "IF - Has PPTX/PDF?",
      "type": "n8n-nodes-base.if",
      "position": [
        4368,
        1536
      ]
    },
    {
      "id": "49b24d00-f787-4b0d-8162-d41f62f6ca0d",
      "name": "ConvertAPI to PNG",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        4592,
        1488
      ]
    },
    {
      "id": "bdd00767-8b17-4d7f-bc38-588ba5a923b9",
      "name": "Prepare for S3 Upload",
      "type": "n8n-nodes-base.code",
      "position": [
        4800,
        1488
      ]
    },
    {
      "id": "9a844a79-cb50-439f-abcf-ea9ef20d3510",
      "name": "S3 Upload (PPTX)",
      "type": "n8n-nodes-base.awsS3",
      "position": [
        5024,
        1488
      ]
    },
    {
      "id": "22f24843-db51-4bc5-aac7-bf9cf8034222",
      "name": "Collect S3 URLs",
      "type": "n8n-nodes-base.code",
      "position": [
        5248,
        1488
      ]
    },
    {
      "id": "f92643b3-d9a2-4053-b2ca-8f76294e0e67",
      "name": "Prepare GPT Request (PPTX)",
      "type": "n8n-nodes-base.code",
      "position": [
        5472,
        1488
      ]
    },
    {
      "id": "eeb04c4a-6278-4f95-b7a1-270ea8052e46",
      "name": "GPT Vision Analysis",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5664,
        1264
      ]
    },
    {
      "id": "59b8220a-6ea1-42d6-88c4-91225668facf",
      "name": "IF - Has Image?",
      "type": "n8n-nodes-base.if",
      "position": [
        4592,
        1648
      ]
    },
    {
      "id": "68b29f63-ef7c-437a-806b-19ae1e9e1be3",
      "name": "Prepare Image Metadata",
      "type": "n8n-nodes-base.code",
      "position": [
        4800,
        1616
      ]
    },
    {
      "id": "45f24d85-b9d3-4532-997c-55d6036aaa4a",
      "name": "S3 Upload (Image)",
      "type": "n8n-nodes-base.awsS3",
      "position": [
        5024,
        1648
      ]
    },
    {
      "id": "e6c8c547-bd98-4e4e-9c7f-8efb515349f1",
      "name": "Prepare GPT Request (Image)",
      "type": "n8n-nodes-base.code",
      "position": [
        5248,
        1648
      ]
    },
    {
      "id": "16937348-70e9-46da-89eb-9ab047956476",
      "name": "GPT Image Analysis",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5472,
        1760
      ]
    },
    {
      "id": "3b289245-1499-4dd3-849f-2b39cf04f65a",
      "name": "Prepare GPT Request (Text)",
      "type": "n8n-nodes-base.code",
      "position": [
        4800,
        1840
      ]
    },
    {
      "id": "27d9b48b-9762-43e5-b624-f810651664e3",
      "name": "GPT Text Analysis",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        5024,
        1840
      ]
    },
    {
      "id": "f0ac5f4d-bf3b-4a45-ab48-b1cf17f43ce1",
      "name": "Merge All Paths",
      "type": "n8n-nodes-base.merge",
      "position": [
        5904,
        1536
      ]
    },
    {
      "id": "0a1f3790-23fa-4b48-a1c6-857c88758b86",
      "name": "Parse All Results",
      "type": "n8n-nodes-base.code",
      "position": [
        6128,
        1536
      ]
    },
    {
      "id": "3b91edb4-d360-4441-ac58-bcaf1da85514",
      "name": "Filter Valid Data",
      "type": "n8n-nodes-base.filter",
      "position": [
        6352,
        1536
      ]
    },
    {
      "id": "07942913-2997-42f5-a93f-b4459ca4c119",
      "name": "Save to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        6560,
        1536
      ]
    },
    {
      "id": "93650748-aff3-423d-afa6-48dd53b5230b",
      "name": "Extract Email IDs",
      "type": "n8n-nodes-base.code",
      "position": [
        6784,
        1536
      ]
    },
    {
      "id": "613a3c8a-e875-48f5-b75b-1b121b92f173",
      "name": "Get Gmail Labels",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        6784,
        1760
      ]
    },
    {
      "id": "dab2e312-225d-4df4-a45d-4b1ab1a37558",
      "name": "Check Labels",
      "type": "n8n-nodes-base.code",
      "position": [
        7008,
        1760
      ]
    },
    {
      "id": "f169d45b-e952-4df5-bd93-7e61a4f07980",
      "name": "IF - Need Labels?",
      "type": "n8n-nodes-base.if",
      "position": [
        7232,
        1760
      ]
    },
    {
      "id": "137c484a-e4ce-4996-b603-4f2164309dc3",
      "name": "Prepare Label Creation",
      "type": "n8n-nodes-base.code",
      "position": [
        7440,
        1664
      ]
    },
    {
      "id": "28717cfd-d0dc-4040-b3fa-dd2982e05819",
      "name": "Filter Labels to Create",
      "type": "n8n-nodes-base.filter",
      "position": [
        7664,
        1664
      ]
    },
    {
      "id": "5f7f79dc-0cb8-43b8-b938-6539881c02d8",
      "name": "Create Gmail Label",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        7888,
        1664
      ]
    },
    {
      "id": "13873411-e770-4f62-a957-f0dd3690b26d",
      "name": "Get New Label IDs",
      "type": "n8n-nodes-base.code",
      "position": [
        8112,
        1664
      ]
    },
    {
      "id": "8ca950ac-7f74-4596-adf7-ca74e6b191d3",
      "name": "Pass Existing Labels",
      "type": "n8n-nodes-base.code",
      "position": [
        7440,
        1856
      ]
    },
    {
      "id": "bebcee89-dc11-4bab-8a9c-e72744778b07",
      "name": "Merge Label IDs",
      "type": "n8n-nodes-base.code",
      "position": [
        8112,
        1856
      ]
    },
    {
      "id": "ec6d8a00-ade2-4047-84fa-2f448cceb979",
      "name": "Prepare Label Application",
      "type": "n8n-nodes-base.code",
      "position": [
        8320,
        1776
      ]
    },
    {
      "id": "b6a78bf7-4974-47ee-8500-440c30991c39",
      "name": "Has Emails?",
      "type": "n8n-nodes-base.filter",
      "position": [
        8544,
        1776
      ]
    },
    {
      "id": "f1e17c5b-24d1-4168-9b06-f24be083c53f",
      "name": "Apply Gmail Labels",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        8768,
        1776
      ]
    },
    {
      "id": "config-variables-note",
      "name": "Configuration Variables",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2384,
        2040
      ],
      "parameters": {
        "width": 500,
        "height": 300,
        "content": "###  Required Variables\n\nSet these in n8n Settings > Variables:\n\n| Variable | Description |\n|----------|-------------|\n| `S3_BUCKET_NAME` | Your AWS S3 bucket name |\n| `AWS_REGION` | AWS region (e.g.,"
      }
    }
  ],
  "connections": {
    "Has Emails?": {
      "main": [
        [
          {
            "node": "Apply Gmail Labels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Labels": {
      "main": [
        [
          {
            "node": "IF - Need Labels?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Domain Filter": {
      "main": [
        [
          {
            "node": "Filter Valid Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect S3 URLs": {
      "main": [
        [
          {
            "node": "Prepare GPT Request (PPTX)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF - Has Excel?": {
      "main": [
        [
          {
            "node": "Extract from Excel",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "IF - Has PPTX/PDF?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF - Has Image?": {
      "main": [
        [
          {
            "node": "Prepare Image Metadata",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Prepare GPT Request (Text)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge All Paths": {
      "main": [
        [
          {
            "node": "Parse All Results",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Label IDs": {
      "main": [
        [
          {
            "node": "Prepare Label Application",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Gmail Labels": {
      "main": [
        [
          {
            "node": "Check Labels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Excel Data": {
      "main": [
        [
          {
            "node": "Merge All Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "S3 Upload (PPTX)": {
      "main": [
        [
          {
            "node": "Collect S3 URLs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Gmail - Get Emails",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "ConvertAPI to PNG": {
      "main": [
        [
          {
            "node": "Prepare for S3 Upload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Detect File Types": {
      "main": [
        [
          {
            "node": "IF - Has Excel?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Valid Data": {
      "main": [
        [
          {
            "node": "Save to Google Sheets",
            "type": "main",
            "index": 0
          },
          {
            "node": "Extract Email IDs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT Text Analysis": {
      "main": [
        [
          {
            "node": "Merge All Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get New Label IDs": {
      "main": [
        [
          {
            "node": "Merge Label IDs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF - Need Labels?": {
      "main": [
        [
          {
            "node": "Prepare Label Creation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Pass Existing Labels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse All Results": {
      "main": [
        [
          {
            "node": "Filter Valid Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "S3 Upload (Image)": {
      "main": [
        [
          {
            "node": "Prepare GPT Request (Image)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Gmail Label": {
      "main": [
        [
          {
            "node": "Get New Label IDs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from Excel": {
      "main": [
        [
          {
            "node": "Parse Excel Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT Image Analysis": {
      "main": [
        [
          {
            "node": "Merge All Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail - Get Emails": {
      "main": [
        [
          {
            "node": "Domain Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "IF - Has PPTX/PDF?": {
      "main": [
        [
          {
            "node": "ConvertAPI to PNG",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "IF - Has Image?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Valid Emails": {
      "main": [
        [
          {
            "node": "Gmail - Get Attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT Vision Analysis": {
      "main": [
        [
          {
            "node": "Merge All Paths",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Pass Existing Labels": {
      "main": [
        [
          {
            "node": "Merge Label IDs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare for S3 Upload": {
      "main": [
        [
          {
            "node": "S3 Upload (PPTX)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Save to Google Sheets": {
      "main": [
        [
          {
            "node": "Get Gmail Labels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Image Metadata": {
      "main": [
        [
          {
            "node": "S3 Upload (Image)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Label Creation": {
      "main": [
        [
          {
            "node": "Filter Labels to Create",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Labels to Create": {
      "main": [
        [
          {
            "node": "Create Gmail Label",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail - Get Attachments": {
      "main": [
        [
          {
            "node": "Detect File Types",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare Label Application": {
      "main": [
        [
          {
            "node": "Has Emails?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare GPT Request (PPTX)": {
      "main": [
        [
          {
            "node": "GPT Vision Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare GPT Request (Text)": {
      "main": [
        [
          {
            "node": "GPT Text Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Prepare GPT Request (Image)": {
      "main": [
        [
          {
            "node": "GPT Image Analysis",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}