{
  "name": "Auto-label Gmail with Ollama AI and draft smart replies",
  "nodes": [
    {
      "id": "e654e5c9-b2d2-4fda-b7c9-848a63fc2d93",
      "name": "Sticky Note - Main Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -400,
        -112
      ],
      "parameters": {
        "width": 740,
        "height": 1000,
        "content": "## Classify Gmail emails with AI and auto-label with smart reply drafts\n\nAutomatically classify every incoming email using a local AI model (Ollama), apply Gmail labels, and generate smart reply draft"
      }
    },
    {
      "id": "9fb47ffc-8479-4013-80dd-ea78e55d6227",
      "name": "Sticky Note - Email Intake",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        960
      ],
      "parameters": {
        "width": 560,
        "height": 260,
        "content": "## 📥 Email Intake\nGmail trigger watches inbox for unread emails, then extracts and cleans email data"
      }
    },
    {
      "id": "6c54a558-173b-44b8-80f8-38825cb5d8c6",
      "name": "Sticky Note - AI Classification",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        768,
        960
      ],
      "parameters": {
        "width": 520,
        "height": 308,
        "content": "## 🤖 AI Classification\nOllama analyzes email content and returns category, priority, and reply draft"
      }
    },
    {
      "id": "c3a16e2d-adc1-4e00-a31a-c409814efb02",
      "name": "Sticky Note - Route and Label",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1328,
        768
      ],
      "parameters": {
        "width": 960,
        "height": 1004,
        "content": "## 🔀 Route, Label & Draft\nSwitch by category, apply Gmail labels, create reply drafts for important emails"
      }
    },
    {
      "id": "59d64a60-80df-426e-a485-43872e4bead0",
      "name": "Sticky Note - Logging",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2352,
        960
      ],
      "parameters": {
        "width": 400,
        "height": 296,
        "content": "## 📊 Logging\nEvery processed email is logged to Google Sheets for analytics"
      }
    },
    {
      "id": "31261316-e9da-490d-9bfa-3f3d30364b22",
      "name": "Sticky Note - Warning Labels",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1344,
        1840
      ],
      "parameters": {
        "width": 360,
        "height": null,
        "content": "## ⚠️ Create Gmail Labels First\nYou must manually create these labels in Gmail before activating:\n`🔴 Urgent`, `📋 Action Required`, `💬 Follow-up`, `📰 Newsletter`, `🤖 Automated`, `🚫 Spam-Promo`\nThen upd"
      }
    },
    {
      "id": "b0f03be3-f1c2-4f44-8ec9-ee2fd8865420",
      "name": "Sticky Note - Warning Ollama",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        784,
        1344
      ],
      "parameters": {
        "width": 300,
        "height": 140,
        "content": "## ⚠️ Check Ollama Model\nDefault model: `mistral`. Make sure it's pulled:\n`ollama pull mistral`\nOr change to `llama3`, `gemma2`, etc."
      }
    },
    {
      "id": "db9674d4-8f0e-4594-85c3-fd60cce764c6",
      "name": "📥 Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        208,
        1088
      ]
    },
    {
      "id": "950c6313-8ef5-4f82-a8b0-2918e868bbfe",
      "name": "🔧 Extract Email Data",
      "type": "n8n-nodes-base.code",
      "position": [
        448,
        1088
      ]
    },
    {
      "id": "ce560c12-b054-404e-be51-d210d1b677d1",
      "name": "🤖 AI Email Classifier",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        800,
        1088
      ]
    },
    {
      "id": "abdbf241-4eb7-47b4-983d-23da8b06848f",
      "name": "🎯 Extract Classification",
      "type": "n8n-nodes-base.code",
      "position": [
        1088,
        1088
      ]
    },
    {
      "id": "24539ed4-1050-4e06-a2d3-3bef0ddaedb9",
      "name": "🔀 Route by Category",
      "type": "n8n-nodes-base.switch",
      "position": [
        1344,
        1088
      ]
    },
    {
      "id": "1b2f61c6-0e8e-41ed-85b1-7ede8ddf12db",
      "name": "🏷️ Label: Urgent",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1600,
        800
      ]
    },
    {
      "id": "6698eeaa-a2fd-429e-b552-f09438535441",
      "name": "📝 Draft Reply (Urgent)",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1840,
        800
      ]
    },
    {
      "id": "d338bc75-a2b5-41bc-96a1-88aa96a1fc25",
      "name": "🏷️ Label: Action Required",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1600,
        960
      ]
    },
    {
      "id": "1540bf40-50a9-4cea-8255-27bf0aa0cccd",
      "name": "📝 Draft Reply (Action)",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1840,
        960
      ]
    },
    {
      "id": "ef532b54-ad93-4805-94a4-af104ef20588",
      "name": "🏷️ Label: Follow-up",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1600,
        1120
      ]
    },
    {
      "id": "c360cea5-623d-45eb-8ce0-c6b7c4db9deb",
      "name": "🏷️ Label: Newsletter",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1600,
        1248
      ]
    },
    {
      "id": "4304e340-abe5-4b39-b3de-c07831ed52cf",
      "name": "🏷️ Label: Automated",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1600,
        1408
      ]
    },
    {
      "id": "139f1b21-d3bf-4e64-bb24-31e752bbde15",
      "name": "🏷️ Label: Spam-Promo",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1600,
        1600
      ]
    },
    {
      "id": "91a158e1-ccc9-4238-a69b-0418d60cb82d",
      "name": "📋 Prepare Log Entry",
      "type": "n8n-nodes-base.code",
      "position": [
        2080,
        1088
      ]
    },
    {
      "id": "3518b511-57c9-4d97-aa32-9b79631e8994",
      "name": "📊 Log to Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        2384,
        1088
      ]
    },
    {
      "id": "b39e4a70-1ccc-421f-87d6-1ac95fe53c48",
      "name": "Ollama Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "position": [
        560,
        1328
      ]
    }
  ],
  "connections": {
    "Ollama Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "🤖 AI Email Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "📥 Gmail Trigger": {
      "main": [
        [
          {
            "node": "🔧 Extract Email Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🏷️ Label: Urgent": {
      "main": [
        [
          {
            "node": "📝 Draft Reply (Urgent)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📋 Prepare Log Entry": {
      "main": [
        [
          {
            "node": "📊 Log to Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🔀 Route by Category": {
      "main": [
        [
          {
            "node": "🏷️ Label: Urgent",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "🏷️ Label: Action Required",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "🏷️ Label: Follow-up",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "🏷️ Label: Newsletter",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "🏷️ Label: Automated",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "🏷️ Label: Spam-Promo",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🔧 Extract Email Data": {
      "main": [
        [
          {
            "node": "🤖 AI Email Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🏷️ Label: Automated": {
      "main": [
        [
          {
            "node": "📋 Prepare Log Entry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🏷️ Label: Follow-up": {
      "main": [
        [
          {
            "node": "📋 Prepare Log Entry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🤖 AI Email Classifier": {
      "main": [
        [
          {
            "node": "🎯 Extract Classification",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🏷️ Label: Newsletter": {
      "main": [
        [
          {
            "node": "📋 Prepare Log Entry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🏷️ Label: Spam-Promo": {
      "main": [
        [
          {
            "node": "📋 Prepare Log Entry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📝 Draft Reply (Action)": {
      "main": [
        [
          {
            "node": "📋 Prepare Log Entry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "📝 Draft Reply (Urgent)": {
      "main": [
        [
          {
            "node": "📋 Prepare Log Entry",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🎯 Extract Classification": {
      "main": [
        [
          {
            "node": "🔀 Route by Category",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "🏷️ Label: Action Required": {
      "main": [
        [
          {
            "node": "📝 Draft Reply (Action)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}