{
  "name": "AI reply drafts for labeled emails",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyHour"
            }
          ]
        },
        "simple": false,
        "filters": {
          "q": "label:needs-reply"
        },
        "options": {}
      },
      "id": "4300ed2f-32ed-5d05-a5df-5846956017bb",
      "name": "Email labeled needs-reply",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [
        200,
        300
      ]
    },
    {
      "parameters": {
        "modelId": {
          "__rl": true,
          "value": "gpt-4.1-mini",
          "mode": "list",
          "cachedResultName": "GPT-4.1-MINI"
        },
        "messages": {
          "values": [
            {
              "content": "=Write a short, friendly reply to this email in my voice. Keep it under 120 words. If you need information you don't have, write [ASK] in its place. Reply with the email body only.\n\nFrom: {{ $json.from.text }}\nSubject: {{ $json.subject }}\n\n{{ $json.text }}"
            }
          ]
        },
        "options": {}
      },
      "id": "95b226f8-6bfd-5bce-947b-1448329fa383",
      "name": "Write the reply",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.8,
      "position": [
        420,
        300
      ]
    },
    {
      "parameters": {
        "resource": "draft",
        "subject": "=Re: {{ $('Email labeled needs-reply').item.json.subject }}",
        "message": "={{ $json.message.content }}",
        "options": {
          "threadId": "={{ $('Email labeled needs-reply').item.json.threadId }}",
          "sendTo": "={{ $('Email labeled needs-reply').item.json.from.value[0].address }}"
        }
      },
      "id": "7f81e296-bc22-5ca7-8d22-b234875b0b0c",
      "name": "Save as Gmail draft",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        640,
        300
      ]
    },
    {
      "parameters": {
        "content": "## Draft, not yet tested\nThis workflow was written by Automation Recipes and has NOT been run end to end yet.\n\nAfter importing: open each node, connect your own accounts (credentials), and fill in anything left blank (sheet URL, Slack channel, label names). Then run it once by hand with test data before turning it on.",
        "height": 260,
        "width": 420
      },
      "id": "0d6c0403-11be-5340-b1cc-60a6888c488c",
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        20
      ]
    }
  ],
  "connections": {
    "Email labeled needs-reply": {
      "main": [
        [
          {
            "node": "Write the reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write the reply": {
      "main": [
        [
          {
            "node": "Save as Gmail draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}