{
 "name": "[노드 한 장] Gmail · 본인에게 테스트 메일 한 통",
 "nodes": [
  {
   "id": "manual",
   "name": "Run manually",
   "type": "n8n-nodes-base.manualTrigger",
   "typeVersion": 1,
   "position": [
    0,
    0
   ],
   "parameters": {}
  },
  {
   "id": "profile",
   "name": "Verify Gmail profile only",
   "type": "n8n-nodes-base.httpRequest",
   "typeVersion": 4.2,
   "retryOnFail": false,
   "position": [
    240,
    0
   ],
   "parameters": {
    "url": "https://gmail.googleapis.com/gmail/v1/users/me/profile",
    "authentication": "predefinedCredentialType",
    "nodeCredentialType": "gmailOAuth2",
    "options": {}
   }
  },
  {
   "id": "guard",
   "name": "Guard own identity",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    480,
    0
   ],
   "parameters": {
    "jsCode": "const expected='YOUR_TEST_EMAIL'; if($input.first().json.emailAddress!==expected)throw new Error('STOP: Gmail identity mismatch'); return [{json:{identity_verified:true,scope:'own test account only'}}];"
   }
  },
  {
   "id": "send",
   "name": "Gmail Send exactly one",
   "type": "n8n-nodes-base.gmail",
   "typeVersion": 2.1,
   "retryOnFail": false,
   "position": [
    720,
    0
   ],
   "parameters": {
    "resource": "message",
    "operation": "send",
    "sendTo": "YOUR_TEST_EMAIL",
    "subject": "[노드 한 장] Gmail 테스트",
    "emailType": "text",
    "message": "이 메일은 n8n Gmail 노드 실습용 테스트입니다.\n본인 계정으로 한 번만 발송하며 실제 고객정보는 포함하지 않았습니다.",
    "options": {
     "appendAttribution": false
    }
   }
  },
  {
   "id": "get",
   "name": "Gmail Get exact sent ID",
   "type": "n8n-nodes-base.gmail",
   "typeVersion": 2.1,
   "retryOnFail": false,
   "position": [
    960,
    0
   ],
   "parameters": {
    "resource": "message",
    "operation": "get",
    "messageId": "={{ $json.id }}",
    "simple": false,
    "options": {
     "downloadAttachments": false
    }
   }
  },
  {
   "id": "verify",
   "name": "Verify only own test content",
   "type": "n8n-nodes-base.code",
   "typeVersion": 2,
   "position": [
    1200,
    0
   ],
   "parameters": {
    "jsCode": "const j=$input.first().json;const expectedSubject=\"[노드 한 장] Gmail 테스트\";const expectedBody=\"이 메일은 n8n Gmail 노드 실습용 테스트입니다.\\n본인 계정으로 한 번만 발송하며 실제 고객정보는 포함하지 않았습니다.\";const send=$('Gmail Send exactly one').first().json;const to=(j.to?.value||[]).map(x=>x.address);const from=(j.from?.value||[]).map(x=>x.address);const text=String(j.text||'').trim();const sent=(send.labelIds||[]).includes('SENT');return [{json:{sample:true,identity_verified:true,native_send_items:1,sent_label:sent,subject_matches:j.subject===expectedSubject,body_matches:text===expectedBody,recipient_is_own:to.includes('YOUR_TEST_EMAIL'),sender_is_own:from.includes('YOUR_TEST_EMAIL'),subject:j.subject,body:text,note:'직접 작성한 본인용 테스트 메일 · 해당 message ID만 조회'}}];"
   }
  }
 ],
 "connections": {
  "Run manually": {
   "main": [
    [
     {
      "node": "Verify Gmail profile only",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Verify Gmail profile only": {
   "main": [
    [
     {
      "node": "Guard own identity",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Guard own identity": {
   "main": [
    [
     {
      "node": "Gmail Send exactly one",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Gmail Send exactly one": {
   "main": [
    [
     {
      "node": "Gmail Get exact sent ID",
      "type": "main",
      "index": 0
     }
    ]
   ]
  },
  "Gmail Get exact sent ID": {
   "main": [
    [
     {
      "node": "Verify only own test content",
      "type": "main",
      "index": 0
     }
    ]
   ]
  }
 },
 "settings": {
  "executionOrder": "v1"
 },
 "meta": {
  "templateCredsSetupCompleted": false,
  "source": "datapopcorn.ai/workflow/nodes"
 }
}