{
  "name": "Intelligent Email Triage",
  "nodes": [
    {
      "parameters": {},
      "name": "New Email Trigger",
      "type": "n8n-nodes-base.emailReadImap",
      "typeVersion": 1,
      "position": [
        450,
        300
      ],
      "notes": "Triggers the workflow when a new email is received. **ACTION REQUIRED:** Configure your email credentials (IMAP or OAuth2) and specify the folder to monitor.",
      "credentials": {
        "imap": {
          "id": "placeholder",
          "name": "Email Account"
        }
      }
    },
    {
      "parameters": {
        "url": "https://api.example.com/v1/chat/completions",
        "options": {},
        "bodyParameters": {
          "parameters": [
            {
              "name": "model",
              "value": "gpt-4"
            },
            {
              "name": "messages",
              "value": "={{ [ { \"role\": \"system\", \"content\": \"You are a classification engine. Classify the following email into one of these categories: Sales Lead, Support Request, or Other. Respond with only the category name.\" }, { \"role\": \"user\", \"content\": \"Subject: \" + $json[\"subject\"] + \"\n\nBody: \" + $json[\"text\"] + \"\" } ] }}"
            }
          ]
        },
        "authentication": "headerAuth"
      },
      "name": "Classify Email",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 1,
      "position": [
        650,
        300
      ],
      "notes": "Sends the email content to an LLM for classification. **ACTION REQUIRED:** Configure the URL and authentication for your LLM API.",
      "credentials": {
        "httpHeaderAuth": {
          "id": "placeholder",
          "name": "LLM API Key"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {},
          "rules": [
            {
              "value1": "={{ $json["choices"][0]["message"]["content"] }}",
              "operation": "contains",
              "value2": "Sales Lead"
            },
            {
              "value1": "={{ $json["choices"][0]["message"]["content"] }}",
              "operation": "contains",
              "value2": "Support Request"
            }
          ]
        }
      },
      "name": "Route by Category",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 1,
      "position": [
        850,
        300
      ],
      "notes": "Routes the workflow based on the category returned by the LLM."
    },
    {
      "parameters": {
        "fromEmail": "your-email@example.com",
        "toEmail": "={{ $json["fromEmail"] }}",
        "subject": "Re: {{ $json["subject"] }}",
        "text": "Hello,\n\nThank you for your inquiry. Our support team will get back to you shortly.\n\nBest regards,\nYour Company"
      },
      "name": "Send Auto-Reply",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 1,
      "position": [
        1050,
        400
      ],
      "notes": "Sends a confirmation email for support requests. **ACTION REQUIRED:** Configure your email credentials.",
      "credentials": {
        "smtp": {
          "id": "placeholder",
          "name": "Email Account"
        }
      }
    },
    {
      "parameters": {},
      "name": "Create CRM Lead",
      "type": "n8n-nodes-base.hubspot",
      "typeVersion": 1,
      "position": [
        1050,
        200
      ],
      "notes": "This is a placeholder for creating a lead in your CRM. Replace with the appropriate node (e.g., HubSpot, Salesforce) and configure it. **ACTION REQUIRED:** Configure your CRM node and credentials."
    }
  ],
  "connections": {
    "New Email Trigger": {
      "main": [
        [
          {
            "node": "Classify Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Classify Email": {
      "main": [
        [
          {
            "node": "Route by Category",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Route by Category": {
      "main": [
        [
          {
            "node": "Create CRM Lead",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Auto-Reply",
            "type": "main",
            "index": 1
          }
        ]
      ]
    }
  }
}