{
  "name": "Email Reply Classifier",
  "nodes": [
    {
      "parameters": {
        "pollTimes": { "item": [{ "mode": "everyMinute", "minute": 5 }] },
        "filters": { "readStatus": "unread" }
      },
      "id": "a1b2c3d4-0001-0001-0001-000000000001",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1,
      "position": [240, 300],
      "credentials": { "gmailOAuth2": { "id": "YOUR_GMAIL_CREDENTIAL_ID", "name": "Gmail OAuth2" } }
    },
    {
      "parameters": {
        "resource": "chat",
        "operation": "create",
        "model": "gpt-4o",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are an email classifier. Classify the email reply into exactly one of these categories: INTERESTED, NOT_INTERESTED, PRICE_QUESTION, OUT_OF_OFFICE. Reply with only the category label, nothing else."
            },
            {
              "role": "user",
              "content": "=Classify this email reply:\n\nSubject: {{ $json.subject }}\n\nBody: {{ $json.text }}"
            }
          ]
        }
      },
      "id": "a1b2c3d4-0002-0002-0002-000000000002",
      "name": "Classify Reply",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1,
      "position": [460, 300],
      "credentials": { "openAiApi": { "id": "YOUR_OPENAI_CREDENTIAL_ID", "name": "OpenAI API" } }
    },
    {
      "parameters": {
        "dataType": "string",
        "value1": "={{ $json.message.content.trim() }}",
        "rules": {
          "rules": [
            { "value2": "INTERESTED" },
            { "value2": "PRICE_QUESTION" },
            { "value2": "OUT_OF_OFFICE" },
            { "value2": "NOT_INTERESTED" }
          ]
        }
      },
      "id": "a1b2c3d4-0003-0003-0003-000000000003",
      "name": "Route by Intent",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 1,
      "position": [680, 300]
    },
    {
      "parameters": {
        "channel": "#hot-leads",
        "text": "=🔥 *Interested Reply*\n\n*From:* {{ $('Gmail Trigger').item.json.from }}\n*Subject:* {{ $('Gmail Trigger').item.json.subject }}\n\n{{ $('Gmail Trigger').item.json.text.slice(0, 300) }}\n\n*Action:* Reply within 30 minutes."
      },
      "id": "a1b2c3d4-0004-0004-0004-000000000004",
      "name": "Slack — Hot Lead Alert",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 1,
      "position": [900, 160],
      "credentials": { "slackApi": { "id": "YOUR_SLACK_CREDENTIAL_ID", "name": "Slack API" } }
    },
    {
      "parameters": {
        "resource": "chat",
        "operation": "create",
        "model": "gpt-4o",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "Write a short, professional reply to a pricing question. Acknowledge their interest, say the rate depends on scope, and offer a 15-minute call to discuss. Keep it under 80 words. No fluff."
            },
            {
              "role": "user",
              "content": "=Their message: {{ $('Gmail Trigger').item.json.text }}"
            }
          ]
        }
      },
      "id": "a1b2c3d4-0005-0005-0005-000000000005",
      "name": "Draft Price Reply",
      "type": "n8n-nodes-base.openAi",
      "typeVersion": 1,
      "position": [900, 300],
      "credentials": { "openAiApi": { "id": "YOUR_OPENAI_CREDENTIAL_ID", "name": "OpenAI API" } }
    },
    {
      "parameters": {
        "operation": "addLabel",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "labelIds": ["Label_OOO"]
      },
      "id": "a1b2c3d4-0006-0006-0006-000000000006",
      "name": "Label OOO",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 1,
      "position": [900, 440],
      "credentials": { "gmailOAuth2": { "id": "YOUR_GMAIL_CREDENTIAL_ID", "name": "Gmail OAuth2" } }
    },
    {
      "parameters": {
        "operation": "addLabel",
        "messageId": "={{ $('Gmail Trigger').item.json.id }}",
        "labelIds": ["Label_NOT_INTERESTED"]
      },
      "id": "a1b2c3d4-0007-0007-0007-000000000007",
      "name": "Label Not Interested",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 1,
      "position": [900, 580],
      "credentials": { "gmailOAuth2": { "id": "YOUR_GMAIL_CREDENTIAL_ID", "name": "Gmail OAuth2" } }
    }
  ],
  "connections": {
    "Gmail Trigger": { "main": [[{ "node": "Classify Reply", "type": "main", "index": 0 }]] },
    "Classify Reply": { "main": [[{ "node": "Route by Intent", "type": "main", "index": 0 }]] },
    "Route by Intent": {
      "main": [
        [{ "node": "Slack — Hot Lead Alert", "type": "main", "index": 0 }],
        [{ "node": "Draft Price Reply", "type": "main", "index": 0 }],
        [{ "node": "Label OOO", "type": "main", "index": 0 }],
        [{ "node": "Label Not Interested", "type": "main", "index": 0 }]
      ]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "versionId": "a1b2c3d4-aaaa-bbbb-cccc-000000000001",
  "meta": { "templateCredsSetupCompleted": false },
  "id": "workflow-email-reply-classifier",
  "tags": [{ "name": "GTM" }, { "name": "Email" }, { "name": "AI" }]
}
