{
  "name": "Gmail FAQ Auto-Responder",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [{ "mode": "everyMinute" }]
        },
        "filters": {
          "readStatus": "unread"
        },
        "options": {}
      },
      "id": "gfaq0001-0001-4000-8000-000000000001",
      "name": "Watch for New Emails",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1,
      "position": [240, 300]
    },
    {
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a helpful customer support agent. Classify the following email as either 'faq' (a common question you can answer from knowledge) or 'human' (needs a human). If 'faq', also provide a polite draft reply. Respond in JSON: {\"type\": \"faq\"|\"human\", \"reply\": \"...\"}."
            },
            {
              "role": "user",
              "content": "Subject: {{ $json.subject }}\\n\\n{{ $json.text }}"
            }
          ]
        },
        "options": {
          "temperature": 0.2,
          "maxTokens": 500
        }
      },
      "id": "gfaq0001-0002-4000-8000-000000000002",
      "name": "Classify and Draft Reply",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1,
      "position": [460, 300]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "field1",
              "name": "parsed",
              "value": "={{ JSON.parse($json.message.content) }}",
              "type": "object"
            }
          ]
        },
        "options": {}
      },
      "id": "gfaq0001-0003-4000-8000-000000000003",
      "name": "Parse LLM Response",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [680, 300]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": false, "leftValue": "", "typeValidation": "strict" },
          "conditions": [
            {
              "id": "cond1",
              "leftValue": "={{ $json.parsed.type }}",
              "rightValue": "faq",
              "operator": { "type": "string", "operation": "equals" }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "gfaq0001-0004-4000-8000-000000000004",
      "name": "Is FAQ?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [900, 300]
    },
    {
      "parameters": {
        "operation": "reply",
        "messageId": "={{ $('Watch for New Emails').item.json.id }}",
        "message": "={{ $json.parsed.reply }}",
        "options": {}
      },
      "id": "gfaq0001-0005-4000-8000-000000000005",
      "name": "Send Auto Reply",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2,
      "position": [1120, 200]
    }
  ],
  "connections": {
    "Watch for New Emails": {
      "main": [[{ "node": "Classify and Draft Reply", "type": "main", "index": 0 }]]
    },
    "Classify and Draft Reply": {
      "main": [[{ "node": "Parse LLM Response", "type": "main", "index": 0 }]]
    },
    "Parse LLM Response": {
      "main": [[{ "node": "Is FAQ?", "type": "main", "index": 0 }]]
    },
    "Is FAQ?": {
      "main": [
        [{ "node": "Send Auto Reply", "type": "main", "index": 0 }],
        []
      ]
    }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "meta": {},
  "pinData": {}
}
