{
  "name": "IMPORTANT",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {
          "q": "has:attachment"
        },
        "options": {
          "downloadAttachments": true
        }
      },
      "id": "7fa712ce-d2fe-4ddd-8de8-1c02b6cc3054",
      "name": "Trigger - New Email",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        0,
        0
      ],
      "notesInFlow": true,
      "typeVersion": 1.1,
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "notes": "has:attachment"
    },
    {
      "parameters": {
        "functionCode": "const out = [];\n\nfor (const item of items) {\n  const binaries = item.binary || {};\n  const from = item.json?.from?.value?.[0]?.address || '';\n  const subject = item.json?.subject || '';\n  const messageId = item.json?.messageId || item.json?.id || '';\n  const receivedAt = item.json?.date || item.json?.internalDate || '';\n\n  for (const [key, bin] of Object.entries(binaries)) {\n    if (!bin) continue;\n    out.push({\n      json: {\n        from,\n        subject,\n        messageId,\n        receivedAt,\n        originalFileName: bin.fileName || key\n      },\n      binary: {\n        file: bin // expose the attachment under 'file'\n      }\n    });\n  }\n}\n\nreturn out;"
      },
      "id": "4b821012-dd9e-4c50-bf22-58a1f0d5e6bc",
      "name": "Flatten Attachments",
      "type": "n8n-nodes-base.function",
      "position": [
        224,
        0
      ],
      "typeVersion": 1
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://megasporic-bewailingly-dominik.ngrok-free.dev/api/upload",
        "sendBody": true,
        "contentType": "multipart-form-data",
        "bodyParameters": {
          "parameters": [
            {
              "parameterType": "formBinaryData",
              "name": "file",
              "inputDataFieldName": "file"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        432,
        0
      ],
      "id": "75f077c1-1259-4b1d-a01f-f19d69d01559",
      "name": "HTTP Request"
    }
  ],
  "connections": {
    "Trigger - New Email": {
      "main": [
        [
          {
            "node": "Flatten Attachments",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Flatten Attachments": {
      "main": [
        [
          {
            "node": "HTTP Request",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "1326971e-23b1-49d4-812f-e2a28bb29fc6",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "2fdlTozxychtfzln",
  "tags": []
}