{
  "name": "Auto-classify Gmail emails with AI and apply labels for inbox organization",
  "nodes": [
    {
      "id": "37166e51-ffb6-43fe-8bd5-fe5eb1249366",
      "name": "OpenRouter Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "position": [
        540,
        540
      ]
    },
    {
      "id": "067f6b55-dc4c-4757-b19e-2d539b8b2526",
      "name": "Aggregate Gmail Messages",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -360,
        220
      ]
    },
    {
      "id": "7807ff72-49f7-4a7b-9d75-24746d0dfdb7",
      "name": "Merge Labels & Messages",
      "type": "n8n-nodes-base.merge",
      "position": [
        240,
        320
      ]
    },
    {
      "id": "8c51f04b-3415-4d53-8624-ce8d484145b9",
      "name": "Classify Email with AI",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        520,
        320
      ]
    },
    {
      "id": "ddbdc31a-ea27-415e-b9e2-954959cfcb7a",
      "name": "New Gmail Email Received",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        -560,
        340
      ]
    },
    {
      "id": "52b3a1d8-3be8-4f57-8759-7ae9abcdb5cb",
      "name": "Fetch Available Gmail Labels",
      "type": "n8n-nodes-base.gmail",
      "position": [
        -140,
        220
      ]
    },
    {
      "id": "2d15670f-5735-4110-a1eb-d5b6b8abef89",
      "name": "Map Label Names to IDs",
      "type": "n8n-nodes-base.code",
      "position": [
        60,
        220
      ]
    },
    {
      "id": "4c5d1e4a-93ce-4f78-b0ce-8b94aff99498",
      "name": "Apply Classification Label",
      "type": "n8n-nodes-base.gmail",
      "position": [
        960,
        320
      ]
    }
  ],
  "connections": {
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Classify Email with AI",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Classify Email with AI": {
      "main": [
        [
          {
            "node": "Apply Classification Label",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Map Label Names to IDs": {
      "main": [
        [
          {
            "node": "Merge Labels & Messages",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge Labels & Messages": {
      "main": [
        [
          {
            "node": "Classify Email with AI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Gmail Messages": {
      "main": [
        [
          {
            "node": "Fetch Available Gmail Labels",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "New Gmail Email Received": {
      "main": [
        [
          {
            "node": "Aggregate Gmail Messages",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge Labels & Messages",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Fetch Available Gmail Labels": {
      "main": [
        [
          {
            "node": "Map Label Names to IDs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}