{
  "name": "Gmail draft-reply assistant (human approval) — Agent Setup Lab template, UNTESTED",
  "nodes": [
    {
      "parameters": {
        "content": "## Gmail draft-reply assistant\nUNTESTED template from agentsetuplab.com.\n\n1. Connect your Gmail credential on the 3 Gmail nodes.\n2. Connect an OpenAI credential on 'Write reply draft'.\n3. Edit the reply guide in the system prompt.\n4. Run on a test inbox first.\n\nThis workflow NEVER sends email. It only creates drafts and labels the thread so you can review and press Send yourself.",
        "height": 340,
        "width": 380
      },
      "id": "a1b2c3d4-0001-4000-8000-000000000001",
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-60, -120]
    },
    {
      "parameters": {
        "pollTimes": { "item": [ { "mode": "everyX", "value": 5, "unit": "minutes" } ] },
        "simple": false,
        "filters": { "labelIds": ["INBOX"], "readStatus": "unread" },
        "options": {}
      },
      "id": "a1b2c3d4-0002-4000-8000-000000000002",
      "name": "New unread email",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [380, 200]
    },
    {
      "parameters": {
        "conditions": {
          "options": { "caseSensitive": false, "leftValue": "", "typeValidation": "loose" },
          "conditions": [
            { "id": "c1", "leftValue": "={{ $json.from.value[0].address }}", "rightValue": "noreply", "operator": { "type": "string", "operation": "notContains" } },
            { "id": "c2", "leftValue": "={{ $json.from.value[0].address }}", "rightValue": "no-reply", "operator": { "type": "string", "operation": "notContains" } },
            { "id": "c3", "leftValue": "={{ JSON.stringify($json.headers || {}) }}", "rightValue": "list-unsubscribe", "operator": { "type": "string", "operation": "notContains" } }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "a1b2c3d4-0003-4000-8000-000000000003",
      "name": "Skip newsletters & no-reply",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [600, 200]
    },
    {
      "parameters": {
        "modelId": { "__rl": true, "mode": "list", "value": "gpt-4o-mini" },
        "messages": {
          "values": [
            { "role": "system", "content": "You draft email replies for a small business. Write in a friendly, brief, professional tone. Use only facts in the email or in this reply guide:\n\n[PASTE YOUR REPLY GUIDE: hours, prices, policies, common answers]\n\nIf you are not sure of a fact, write [CHECK: what to confirm] instead of guessing. Never promise refunds, discounts or dates. Output only the reply body, no subject line." },
            { "content": "=From: {{ $('New unread email').item.json.from.text }}\nSubject: {{ $('New unread email').item.json.subject }}\n\n{{ $('New unread email').item.json.text }}" }
          ]
        },
        "options": { "temperature": 0.3 }
      },
      "id": "a1b2c3d4-0004-4000-8000-000000000004",
      "name": "Write reply draft",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [840, 120]
    },
    {
      "parameters": {
        "resource": "draft",
        "subject": "=Re: {{ $('New unread email').item.json.subject }}",
        "message": "={{ $json.message.content }}",
        "options": {
          "threadId": "={{ $('New unread email').item.json.threadId }}",
          "sendTo": "={{ $('New unread email').item.json.from.value[0].address }}"
        }
      },
      "id": "a1b2c3d4-0005-4000-8000-000000000005",
      "name": "Create Gmail draft (no send)",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [1080, 120]
    },
    {
      "parameters": {
        "operation": "addLabels",
        "messageId": "={{ $('New unread email').item.json.id }}",
        "labelIds": ["REPLACE_WITH_LABEL_ID_AI_DRAFT_READY"]
      },
      "id": "a1b2c3d4-0006-4000-8000-000000000006",
      "name": "Label: AI draft ready",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [1300, 120]
    }
  ],
  "connections": {
    "New unread email": { "main": [ [ { "node": "Skip newsletters & no-reply", "type": "main", "index": 0 } ] ] },
    "Skip newsletters & no-reply": { "main": [ [ { "node": "Write reply draft", "type": "main", "index": 0 } ], [] ] },
    "Write reply draft": { "main": [ [ { "node": "Create Gmail draft (no send)", "type": "main", "index": 0 } ] ] },
    "Create Gmail draft (no send)": { "main": [ [ { "node": "Label: AI draft ready", "type": "main", "index": 0 } ] ] }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "pinData": {},
  "meta": { "templateCredsSetupCompleted": false, "source": "https://agentsetuplab.com/templates/" },
  "tags": []
}
