{
  "name": "HYPEAKZ \u2014 AI Email Classifier & Auto-Responder (Local Ollama)",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute",
              "minute": 5
            }
          ]
        },
        "filters": {
          "readStatus": "unread"
        }
      },
      "id": "node-imap",
      "name": "Check Inbox (IMAP)",
      "type": "n8n-nodes-base.imapEmail",
      "typeVersion": 2,
      "position": [
        250,
        300
      ]
    },
    {
      "parameters": {
        "model": "llama3.2",
        "baseUrl": "http://ollama:11434"
      },
      "id": "node-ollama",
      "name": "Ollama Local LLM",
      "type": "@n8n/n8n-nodes-langchain.lmOllama",
      "typeVersion": 1,
      "position": [
        650,
        500
      ]
    },
    {
      "parameters": {
        "categories": {
          "categories": [
            {
              "category": "URGENT",
              "description": "Time-sensitive requests, deadlines, emergencies"
            },
            {
              "category": "CLIENT_REQUEST",
              "description": "Client questions, project inquiries, feedback"
            },
            {
              "category": "INVOICE",
              "description": "Invoices, payment requests, billing"
            },
            {
              "category": "NEWSLETTER",
              "description": "Marketing emails, newsletters, promotions"
            },
            {
              "category": "SPAM",
              "description": "Unwanted, irrelevant, or suspicious emails"
            },
            {
              "category": "INTERNAL",
              "description": "Team communication, internal updates"
            }
          ]
        },
        "options": {
          "systemMessage": "You are an email classifier for a business. Classify the email into exactly one category. Be precise."
        }
      },
      "id": "node-classifier",
      "name": "Classify Email (AI)",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "typeVersion": 1,
      "position": [
        650,
        300
      ]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.category }}",
              "operation": "equals",
              "value2": "URGENT"
            }
          ]
        }
      },
      "id": "node-switch-urgent",
      "name": "Is Urgent?",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3,
      "position": [
        900,
        200
      ]
    },
    {
      "parameters": {
        "prompt": "Write a brief, professional acknowledgment email reply. The sender's email was about: {{ $('Check Inbox (IMAP)').item.json.subject }}. Confirm receipt, mention you'll respond in detail within 2 hours. Keep it under 3 sentences. Sign as 'Best regards, [Your Name]'."
      },
      "id": "node-draft-reply",
      "name": "Draft Urgent Reply (AI)",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.4,
      "position": [
        1150,
        100
      ]
    },
    {
      "parameters": {
        "fromEmail": "={{ $env.SMTP_USER }}",
        "toEmail": "={{ $('Check Inbox (IMAP)').item.json.from }}",
        "subject": "Re: {{ $('Check Inbox (IMAP)').item.json.subject }}",
        "text": "={{ $json.text }}"
      },
      "id": "node-send-reply",
      "name": "Send Auto-Reply",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        1400,
        100
      ]
    },
    {
      "parameters": {
        "values": {
          "string": [
            {
              "name": "email_from",
              "value": "={{ $('Check Inbox (IMAP)').item.json.from }}"
            },
            {
              "name": "subject",
              "value": "={{ $('Check Inbox (IMAP)').item.json.subject }}"
            },
            {
              "name": "category",
              "value": "={{ $json.category }}"
            },
            {
              "name": "processed_at",
              "value": "={{ $now.toISO() }}"
            }
          ]
        }
      },
      "id": "node-log",
      "name": "Log to Spreadsheet",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        900,
        450
      ]
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "list"
        },
        "sheetName": {
          "__rl": true,
          "value": "Email Log"
        }
      },
      "id": "node-sheets",
      "name": "Save to Google Sheets",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1150,
        450
      ]
    }
  ],
  "connections": {
    "Check Inbox (IMAP)": {
      "main": [
        [
          {
            "node": "Classify Email (AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Email (AI)": {
      "main": [
        [
          {
            "node": "Is Urgent?",
            "type": "main",
            "index": 0
          },
          {
            "node": "Log to Spreadsheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ollama Local LLM": {
      "ai_languageModel": [
        [
          {
            "node": "Classify Email (AI)",
            "type": "ai_languageModel",
            "index": 0
          },
          {
            "node": "Draft Urgent Reply (AI)",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Is Urgent?": {
      "main": [
        [
          {
            "node": "Draft Urgent Reply (AI)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Draft Urgent Reply (AI)": {
      "main": [
        [
          {
            "node": "Send Auto-Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Log to Spreadsheet": {
      "main": [
        [
          {
            "node": "Save to Google Sheets",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "tags": [
    {
      "name": "HYPEAKZ.IO"
    },
    {
      "name": "Self-Hosted AI"
    },
    {
      "name": "Ollama"
    },
    {
      "name": "Email Automation"
    },
    {
      "name": "Privacy-First"
    }
  ]
}