{
  "name": "Intelligent email organization with AI-powered content classification for Gmail",
  "nodes": [
    {
      "id": "61d0e78d-34ea-4266-9d0d-16b917e2e934",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1580,
        -560
      ]
    },
    {
      "id": "ceeb33f9-5edd-4760-ae69-de3f8f7c7fe4",
      "name": "Replace Me",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1000,
        -600
      ]
    },
    {
      "id": "d9ddec50-7a7c-476b-af88-94d06fc3d2ce",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -1140,
        -600
      ]
    },
    {
      "id": "6fdbf75a-182d-4793-b4c7-2a3c29127a4c",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        -920,
        -700
      ]
    },
    {
      "id": "65925cff-ae6d-4d01-b04f-09081dda5f6f",
      "name": "Gmail - Get All Messages",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -2120,
        -580
      ]
    },
    {
      "id": "7c9da3f9-ab0c-4244-a086-04e36a22e5f2",
      "name": "Gmail - Single Message",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -1340,
        -640
      ]
    },
    {
      "id": "47aabef5-1f4e-4fa3-9fd9-f4ab724fc6d9",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2440,
        -960
      ],
      "parameters": {
        "width": 3820,
        "height": 740,
        "content": "## Auto Gmail Labeling (Powered by OpenAI)"
      }
    },
    {
      "id": "4635a3bf-7da7-45b7-9767-539831407a1e",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -2340,
        -580
      ]
    },
    {
      "id": "92f4c2be-42e7-49fe-a43a-66060495af30",
      "name": "Extract Email Data",
      "type": "n8n-nodes-base.set",
      "position": [
        -700,
        -700
      ]
    },
    {
      "id": "82ea2062-8dc8-4087-82e7-c45047e14d41",
      "name": "Categorize Email with AI",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -480,
        -800
      ]
    },
    {
      "id": "bd3e558c-1e2a-4962-bf65-c92edfaad559",
      "name": "Store AI Category",
      "type": "n8n-nodes-base.set",
      "position": [
        -100,
        -700
      ]
    },
    {
      "id": "b7e2e5a9-772b-4f8b-a018-d59924e80fd5",
      "name": "List All Gmail Labels",
      "type": "n8n-nodes-base.gmail",
      "position": [
        120,
        -600
      ]
    },
    {
      "id": "0361804b-a792-4f12-862e-09b6de749128",
      "name": "Check if Label Exists",
      "type": "n8n-nodes-base.compareDatasets",
      "position": [
        340,
        -720
      ]
    },
    {
      "id": "65203535-4a68-4b7e-836b-93aba10b5314",
      "name": "Apply Label to Email",
      "type": "n8n-nodes-base.gmail",
      "position": [
        780,
        -600
      ]
    },
    {
      "id": "c693da56-6238-4c21-bdb6-6e3aceffd4a5",
      "name": "Apply New Label",
      "type": "n8n-nodes-base.gmail",
      "position": [
        560,
        -800
      ]
    },
    {
      "id": "86a440fa-b761-4b3f-ae7b-b5fb30a11f9d",
      "name": "Create New Label",
      "type": "n8n-nodes-base.gmail",
      "position": [
        780,
        -800
      ]
    },
    {
      "id": "59b0ed3f-7a2c-44f3-8e7c-ebb91ead16d2",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -400,
        -580
      ]
    },
    {
      "id": "ced7a41e-7df9-4c73-ab00-e24677326652",
      "name": "Filter Emails Without Excluded Labels",
      "type": "n8n-nodes-base.code",
      "position": [
        -1900,
        -580
      ]
    }
  ],
  "connections": {
    "If": {
      "main": [
        [],
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Extract Email Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Replace Me": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Apply New Label": {
      "main": [
        [
          {
            "node": "Create New Label",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Gmail - Single Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create New Label": {
      "main": [
        [
          {
            "node": "Replace Me",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Gmail - Get All Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Categorize Email with AI",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Store AI Category": {
      "main": [
        [
          {
            "node": "Check if Label Exists",
            "type": "main",
            "index": 0
          },
          {
            "node": "List All Gmail Labels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Email Data": {
      "main": [
        [
          {
            "node": "Categorize Email with AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Apply Label to Email": {
      "main": [
        [
          {
            "node": "Replace Me",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check if Label Exists": {
      "main": [
        [
          {
            "node": "Apply New Label",
            "type": "main",
            "index": 0
          }
        ],
        [],
        [
          {
            "node": "Apply Label to Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List All Gmail Labels": {
      "main": [
        [
          {
            "node": "Check if Label Exists",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Gmail - Single Message": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Categorize Email with AI": {
      "main": [
        [
          {
            "node": "Store AI Category",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail - Get All Messages": {
      "main": [
        [
          {
            "node": "Filter Emails Without Excluded Labels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Emails Without Excluded Labels": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}