{
  "name": "Rendex — Email an HTML Report as a PNG Attachment",
  "nodes": [
    {
      "parameters": {
        "content": "## HTML Report → PNG → Email — Setup\n\n**1. Rendex node** (\"Rendex — Render Report PNG\"): open it, click the **Credentials** dropdown, and pick/create your **Rendex API** credential (a `rdx_` key). Credentials are never embedded in a template.\n\n**2. Build Report Data**: this Code node emits sample KPI values so the report renders on the first run. Replace it with your real source (Google Sheets, Postgres, an HTTP API) — keep the output under `reportData` so the template's `{{placeholders}}` fill in.\n\n**3. Email the Report**: pick your **Gmail / SMTP** credential and set the recipient. The PNG lands on the binary property `data` and is already attached.\n\n**4.** The Schedule fires weekly (Mon 08:00). Adjust it, then activate. Free tier — 100 renders/mo.",
        "height": 300,
        "width": 540
      },
      "id": "sticky-setup",
      "name": "Setup — read me first",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [220, 120]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "weeks",
              "weeksInterval": 1,
              "triggerAtDay": [1],
              "triggerAtHour": 8,
              "triggerAtMinute": 0
            }
          ]
        }
      },
      "id": "schedule-weekly",
      "name": "Schedule: Weekly Mon 08:00",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [240, 480]
    },
    {
      "parameters": {
        "jsCode": "// Pull fresh KPI values from your data source here (Sheets, Postgres, an API).\n// This sample emits static values so the report template renders on the first run.\n// Keep everything under `reportData` — the Rendex node's Template Data reads it\n// to fill the {{week}} {{mrr}} {{signups}} {{churn}} placeholders.\nreturn [{\n  json: {\n    reportData: {\n      week: new Date().toISOString().slice(0, 10),\n      mrr: '$48,250',\n      signups: '312',\n      churn: '1.8%',\n    },\n  },\n}];"
      },
      "id": "build-report-data",
      "name": "Build Report Data",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [480, 480]
    },
    {
      "parameters": {
        "resource": "screenshot",
        "operation": "capture",
        "source": "html",
        "html": "<!doctype html><html><head><meta charset=\"utf-8\"><style>body{font-family:system-ui,sans-serif;color:#0f172a;margin:0;padding:40px;width:1000px}h1{color:#ea580c;margin:0 0 24px}.cards{display:flex;gap:16px}.card{flex:1;padding:20px;border:1px solid #e2e8f0;border-radius:12px}.lbl{font-size:12px;text-transform:uppercase;color:#64748b}.val{font-size:32px;font-weight:700}</style></head><body><h1>Weekly Performance — {{week}}</h1><div class=\"cards\"><div class=\"card\"><div class=\"lbl\">MRR</div><div class=\"val\">{{mrr}}</div></div><div class=\"card\"><div class=\"lbl\">New signups</div><div class=\"val\">{{signups}}</div></div><div class=\"card\"><div class=\"lbl\">Churn</div><div class=\"val\">{{churn}}</div></div></div></body></html>",
        "templateData": "={{ $json.reportData }}",
        "format": "png",
        "binaryPropertyName": "data",
        "additionalOptions": {
          "width": 1000,
          "fullPage": true,
          "deviceScaleFactor": 2
        }
      },
      "id": "rendex-render-report",
      "name": "Rendex — Render Report PNG",
      "type": "n8n-nodes-rendex.rendex",
      "typeVersion": 1,
      "position": [720, 480]
    },
    {
      "parameters": {
        "sendTo": "={{ $env.NOTIFY_EMAIL || 'team@example.com' }}",
        "subject": "=Weekly performance report — {{ $('Build Report Data').item.json.reportData.week }}",
        "emailType": "text",
        "message": "Hi team,\n\nThis week's performance report is attached as a PNG.\n\nAutomated by n8n + Rendex.",
        "options": {
          "attachmentsUi": {
            "attachmentsBinary": [
              {
                "property": "data"
              }
            ]
          }
        }
      },
      "id": "gmail-send-report",
      "name": "Email the Report",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [960, 480],
      "credentials": {
        "gmailOAuth2": {
          "id": "gmail-oauth2",
          "name": "Gmail account"
        }
      }
    }
  ],
  "connections": {
    "Schedule: Weekly Mon 08:00": {
      "main": [
        [
          {
            "node": "Build Report Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Report Data": {
      "main": [
        [
          {
            "node": "Rendex — Render Report PNG",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rendex — Render Report PNG": {
      "main": [
        [
          {
            "node": "Email the Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "instanceId": ""
  }
}
