{
  "name": "14 Draft reply with approval (per email)",
  "nodes": [
    {
      "id": "ece43acf-fad4-425f-a4bc-567cb06dbbe1",
      "name": "Email from the main flow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "typeVersion": 1.1,
      "position": [
        0,
        300
      ],
      "parameters": {
        "inputSource": "passthrough"
      }
    },
    {
      "id": "697e7f76-d725-48b9-9a6d-dcf9b17f136a",
      "name": "Draft reply",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3.1,
      "position": [
        240,
        300
      ],
      "parameters": {
        "promptType": "define",
        "text": "=From: {{ $json.from }}\nSubject: {{ $json.subject }}\nCategory: {{ $json.category }}\n\n{{ ($json.textPlain || '').slice(0, 3000) }}",
        "options": {
          "systemMessage": "You write a draft reply on behalf of a small business to the user's email. Write in English, brief, friendly and businesslike, without a subject line and without a signature. Never promise a price, date, lead time or discount that is not in the email. If the owner needs to add something, write FILL IN followed by what is needed.",
          "maxIterations": 4
        }
      },
      "notes": "AI only writes a draft",
      "notesInFlow": true
    },
    {
      "id": "e3bd1dfc-e12a-4004-9750-06dc5a1d3831",
      "name": "Chat model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOllama",
      "typeVersion": 1,
      "position": [
        240,
        520
      ],
      "parameters": {
        "model": "qwen2.5:7b",
        "options": {
          "temperature": 0.2
        }
      }
    },
    {
      "id": "9f945781-a240-41e4-8d61-9b1435c4f2af",
      "name": "Ask for approval",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        480,
        300
      ],
      "parameters": {
        "operation": "sendAndWait",
        "fromEmail": "info@example.com",
        "toEmail": "you@example.com",
        "subject": "=Draft reply to {{ $('Email from the main flow').item.json.from }}: {{ $('Email from the main flow').item.json.subject }}",
        "message": "=Category: {{ $('Email from the main flow').item.json.category }}\n\nThe email:\n{{ ($('Email from the main flow').item.json.textPlain || '').slice(0, 1500) }}\n\n--- Draft reply ---\n{{ $json.output }}\n\nClick Send to send this reply as is, or Don't send to handle it yourself.",
        "responseType": "approval",
        "approvalOptions": {
          "values": {
            "approvalType": "double",
            "approveLabel": "Send",
            "disapproveLabel": "Don't send"
          }
        },
        "options": {
          "appendAttribution": false,
          "limitWaitTime": {
            "values": {
              "limitType": "afterTimeInterval",
              "resumeAmount": 3,
              "resumeUnit": "days"
            }
          }
        }
      },
      "notes": "A human signs off: nothing reaches the client without a click",
      "notesInFlow": true,
      "webhookId": "7ecd2c69-c8f6-51ae-a252-beebc8c924b3"
    },
    {
      "id": "d5cba7b9-424f-4733-a829-9fdbeb1b8f8d",
      "name": "Approved?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        720,
        300
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose",
            "version": 2
          },
          "conditions": [
            {
              "id": "g",
              "leftValue": "={{ $json.data.approved }}",
              "rightValue": "",
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "d5a579ab-b3ce-49aa-b79d-b2938a1adb20",
      "name": "Send reply",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        960,
        300
      ],
      "parameters": {
        "fromEmail": "info@example.com",
        "toEmail": "={{ $('Email from the main flow').item.json.from }}",
        "subject": "=Re: {{ $('Email from the main flow').item.json.subject }}",
        "emailFormat": "text",
        "text": "={{ $('Draft reply').item.json.output }}\n\nBest regards",
        "options": {
          "appendAttribution": false
        }
      }
    },
    {
      "id": "7da951d6-7e26-49b0-ac71-2585021d92d7",
      "name": "Read me",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        -160
      ],
      "parameters": {
        "content": "## Draft reply with approval (per email)\nTested on November 11, 2026, with n8n 2.47.3.\n\n**Fill in:** a chat model (preferably a strong one: the small local model produced 17 unusable drafts out of 27), your SMTP account and your own address in 'Ask for approval'.\n\nDeliberately without a lookup tool: in our test, the agent used that tool to mention another client's open invoice. Click the button in the email yourself, in a browser. No click within 3 days means nothing is sent.",
        "height": 220,
        "width": 520,
        "color": 7
      }
    }
  ],
  "connections": {
    "Email from the main flow": {
      "main": [
        [
          {
            "node": "Draft reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Draft reply": {
      "main": [
        [
          {
            "node": "Ask for approval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Ask for approval": {
      "main": [
        [
          {
            "node": "Approved?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Approved?": {
      "main": [
        [
          {
            "node": "Send reply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat model": {
      "ai_languageModel": [
        [
          {
            "node": "Draft reply",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  }
}