{
  "name": "NameDrop Domain Alerts",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "namedrop-alerts"
      },
      "id": "webhook-trigger",
      "name": "NameDrop Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1.1,
      "position": [
        200,
        300
      ]
    },
    {
      "parameters": {
        "jsCode": "const item = $input.first().json;\n\nconst statusColors = {\n  available: '#22c55e',\n  registered: '#ef4444',\n  expiring_soon: '#eab308',\n  grace_period: '#f97316',\n  redemption: '#f97316',\n  pending_delete: '#3b82f6',\n  unknown: '#9ca3af',\n  error: '#9ca3af'\n};\n\nconst statusLabels = {\n  available: 'Available',\n  registered: 'Registered',\n  expiring_soon: 'Expiring Soon',\n  grace_period: 'Grace Period',\n  redemption: 'Redemption',\n  pending_delete: 'Pending Delete',\n  unknown: 'Unknown',\n  error: 'Error'\n};\n\nconst color = statusColors[item.new_status] || '#9ca3af';\nconst label = statusLabels[item.new_status] || item.new_status;\nconst isUrgent = ['available', 'pending_delete'].includes(item.new_status);\n\nlet detailRows = '';\nif (item.previous_status) {\n  detailRows += `<tr><td style=\"padding:6px 12px;color:#94a3b8;\">Previous</td><td style=\"padding:6px 12px;color:#e2e8f0;\">${item.previous_status}</td></tr>`;\n}\nif (item.expiry_date) {\n  detailRows += `<tr><td style=\"padding:6px 12px;color:#94a3b8;\">Expiry</td><td style=\"padding:6px 12px;color:#e2e8f0;\">${item.expiry_date}</td></tr>`;\n}\nif (item.registrar) {\n  detailRows += `<tr><td style=\"padding:6px 12px;color:#94a3b8;\">Registrar</td><td style=\"padding:6px 12px;color:#e2e8f0;\">${item.registrar}</td></tr>`;\n}\nif (item.tags && item.tags.length > 0) {\n  detailRows += `<tr><td style=\"padding:6px 12px;color:#94a3b8;\">Tags</td><td style=\"padding:6px 12px;color:#e2e8f0;\">${item.tags.join(', ')}</td></tr>`;\n}\nif (item.auto_register) {\n  detailRows += `<tr><td style=\"padding:6px 12px;color:#94a3b8;\">Auto-register</td><td style=\"padding:6px 12px;color:#22c55e;\">Enabled</td></tr>`;\n}\n\nconst html = `\n<div style=\"background:#0f172a;padding:32px;font-family:-apple-system,BlinkMacSystemFont,'Segoe UI',Roboto,sans-serif;\">\n  <div style=\"max-width:480px;margin:0 auto;background:#1e293b;border-radius:12px;overflow:hidden;border:1px solid #334155;\">\n    <div style=\"background:${color};padding:16px 24px;\">\n      <h1 style=\"margin:0;color:#fff;font-size:14px;font-weight:600;text-transform:uppercase;letter-spacing:1px;\">NameDrop Alert</h1>\n    </div>\n    <div style=\"padding:24px;\">\n      <p style=\"margin:0 0 4px;color:#94a3b8;font-size:13px;\">Domain</p>\n      <p style=\"margin:0 0 16px;color:#f1f5f9;font-size:22px;font-family:'SF Mono',Monaco,Consolas,monospace;font-weight:700;\">${item.domain}</p>\n      <div style=\"display:inline-block;background:${color}22;border:1px solid ${color};border-radius:6px;padding:4px 12px;margin-bottom:20px;\">\n        <span style=\"color:${color};font-size:13px;font-weight:600;\">${label}</span>\n      </div>\n      ${detailRows ? `<table style=\"width:100%;border-collapse:collapse;margin-top:8px;\">${detailRows}</table>` : ''}\n    </div>\n    <div style=\"padding:16px 24px;border-top:1px solid #334155;\">\n      <p style=\"margin:0;color:#64748b;font-size:11px;\">Checked at ${item.checked_at} &middot; NameDrop</p>\n    </div>\n  </div>\n</div>`;\n\nconst subjectPrefix = isUrgent ? '[URGENT] ' : '';\nconst subject = `${subjectPrefix}NameDrop: ${item.domain} \u2014 ${label}`;\n\nreturn [{ json: { ...item, emailHtml: html, emailSubject: subject } }];"
      },
      "id": "format-email",
      "name": "Format Email",
      "type": "n8n-nodes-base.code",
      "typeVersion": 1,
      "position": [
        450,
        300
      ]
    },
    {
      "parameters": {
        "fromEmail": "namedrop@example.com",
        "toEmail": "you@example.com",
        "subject": "={{ $json.emailSubject }}",
        "html": "={{ $json.emailHtml }}"
      },
      "id": "send-email",
      "name": "Send Email",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2,
      "position": [
        700,
        300
      ]
    }
  ],
  "connections": {
    "NameDrop Webhook": {
      "main": [
        [
          {
            "node": "Format Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format Email": {
      "main": [
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  }
}