{
  "name": "Weekly Deliverability Health Check",
  "nodes": [
    {
      "parameters": {
        "content": "## Setup\n1. Paste your Instantly API key into \"Check Inbox Health\".\n2. Paste a Slack incoming webhook URL into \"Alert on Low Health\".\n3. Adjust HEALTH_THRESHOLD in the code node to match your own tolerance.\n\nFrom Chapter 3: watch inbox health scores weekly, not just at setup. A domain that warmed up fine can still degrade after a bad send.",
        "height": 300,
        "width": 380
      },
      "id": "e4f5a6b7-4444-4a2b-9c3a-000000000001",
      "name": "Setup Notes",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [-200, 60]
    },
    {
      "parameters": { "rule": { "interval": [{ "field": "weeks", "triggerAtDay": [1], "triggerAtHour": 7 }] } },
      "id": "e4f5a6b7-4444-4a2b-9c3a-000000000002",
      "name": "Every Monday 7am",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [-200, 400]
    },
    {
      "parameters": {
        "method": "GET",
        "url": "https://api.instantly.ai/api/v2/accounts",
        "sendHeaders": true,
        "headerParameters": { "parameters": [{ "name": "Authorization", "value": "Bearer YOUR_INSTANTLY_API_KEY" }] },
        "options": {}
      },
      "id": "e4f5a6b7-4444-4a2b-9c3a-000000000003",
      "name": "Check Inbox Health",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [40, 400]
    },
    {
      "parameters": {
        "jsCode": "const HEALTH_THRESHOLD = 80;\nconst accounts = $input.first().json.accounts || $input.first().json || [];\nconst list = Array.isArray(accounts) ? accounts : [];\nconst low = list.filter(a => (a.health_score ?? 100) < HEALTH_THRESHOLD);\nconst lines = low.map(a => `${a.email || a.id}: ${a.health_score}`);\nreturn [{ json: { count: low.length, list: lines.length ? lines.join('\\n') : 'All inboxes healthy this week.' } }];"
      },
      "id": "e4f5a6b7-4444-4a2b-9c3a-000000000004",
      "name": "Flag Low Health",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [280, 400]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "YOUR_SLACK_INCOMING_WEBHOOK_URL",
        "sendBody": true,
        "bodyParameters": { "parameters": [{ "name": "text", "value": "=Inboxes below health threshold ({{ $json.count }}):\n\n{{ $json.list }}\n\nPause sending on any of these until health recovers." }] },
        "options": {}
      },
      "id": "e4f5a6b7-4444-4a2b-9c3a-000000000005",
      "name": "Alert on Low Health",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [520, 400]
    }
  ],
  "connections": {
    "Every Monday 7am": { "main": [[{ "node": "Check Inbox Health", "type": "main", "index": 0 }]] },
    "Check Inbox Health": { "main": [[{ "node": "Flag Low Health", "type": "main", "index": 0 }]] },
    "Flag Low Health": { "main": [[{ "node": "Alert on Low Health", "type": "main", "index": 0 }]] }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "pinData": {}
}
