{
  "name": "Demo — Email Draft Replies",
  "active": false,
  "nodes": [
    {
      "id": "d389e984-3aeb-4d99-ac40-33fe629fcf23",
      "name": "README",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -176,
        -480
      ],
      "parameters": {
        "content": "## Email draft replies with AI\n\n**What it does:** every new email in your inbox gets a reply written by AI and saved as a **draft** in the same thread. Nothing is sent: you open Gmail in the morning, edit or press Send.\n\n**Setup (5 minutes):**\n1. New Email: connect your Gmail account. The Search filter skips promotions, social, updates and no-reply senders; change it if you want.\n2. OpenAI Model: add your OpenAI API key. It uses gpt-6.1-terra; pick gpt-6-luna for the cheapest option.\n3. Write Reply: change YOUR_NAME in the system message, and add how you like to write.\n4. Save Draft Reply: connect the same Gmail account.\n5. Send yourself a test email, run the workflow once, check the draft, then Publish.\n\nBuilt as a demo by Mina Saad (mina-saad.com). No credentials included.",
        "height": 400,
        "width": 560,
        "color": 6
      }
    },
    {
      "id": "9ae5ccb4-2c90-4c44-a714-f03c9b5b3df0",
      "name": "New Email",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.4,
      "position": [
        0,
        0
      ],
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "simple": false,
        "filters": {
          "labelIds": [
            "INBOX"
          ],
          "q": "-category:promotions -category:social -category:updates -from:noreply -from:no-reply",
          "readStatus": "unread"
        },
        "options": {}
      }
    },
    {
      "id": "641f35c3-6402-40ba-ae91-c6d6fcf8b6c2",
      "name": "Write Reply",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.9,
      "position": [
        240,
        0
      ],
      "parameters": {
        "promptType": "define",
        "text": "=Email from: {{ $json.from.text }}\nSubject: {{ $json.subject }}\n\n{{ $json.text }}\n\nWrite my reply to this email.",
        "hasOutputParser": false,
        "messages": {
          "messageValues": [
            {
              "type": "SystemMessagePromptTemplate",
              "message": "You draft email replies for me. I will review every draft before it is sent.\n\nRules:\n- Reply in the same language as the email (Arabic stays Arabic, English stays English).\n- Keep it short: answer what was asked, confirm what you can, ask one question if something is missing.\n- Never invent facts, prices, dates or promises. When the reply needs something you do not know, write [CHECK: what to fill in].\n- Friendly and professional, no filler.\n- Output only the reply body: no subject line, no notes to me.\n- Sign as: YOUR_NAME"
            }
          ]
        }
      }
    },
    {
      "id": "3b8e996d-3016-4ad7-915a-f2760d9a0db9",
      "name": "OpenAI Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        240,
        208
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-6.1-terra"
        },
        "builtInTools": {},
        "options": {}
      }
    },
    {
      "id": "e5c087cc-0264-4a29-a39f-6d47232f5687",
      "name": "Save Draft Reply",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        560,
        0
      ],
      "parameters": {
        "resource": "draft",
        "operation": "create",
        "subject": "=Re: {{ $('New Email').item.json.subject }}",
        "emailType": "text",
        "message": "={{ $json.text }}",
        "options": {
          "threadId": "={{ $('New Email').item.json.threadId }}",
          "sendTo": "={{ $('New Email').item.json.from.value[0].address }}"
        }
      }
    }
  ],
  "connections": {
    "New Email": {
      "main": [
        [
          {
            "node": "Write Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Write Reply": {
      "main": [
        [
          {
            "node": "Save Draft Reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Model": {
      "ai_languageModel": [
        [
          {
            "node": "Write Reply",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "tags": []
}