← Back to blog
"n8nClaudeAIautomation

Automated client report generation with n8n and Claude: pulling metrics, assembling summaries, and PDF delivery

A fully automated client report pipeline in n8n pulls metrics from source APIs, runs Claude to write professional summaries, converts to PDF, and delivers by email — unattended, per-client, on schedule.

The manual client report process: export data, paste numbers into a doc, write three paragraphs of summary, export to PDF, email the client. For agencies running 5-20 clients on a weekly or monthly cadence, this is the task that consumes the most time and produces the most consistent output. n8n and Claude can run it end-to-end.

Architecture

Four stages: pull metrics, structure data, generate narrative, deliver PDF.

`

Schedule Trigger

→ HTTP Request (fetch metrics: GA4 / Search Console / custom API)

→ Code node (compute deltas, flag anomalies, structure data)

→ HTTP Request (Claude: write section summaries as JSON)

→ Code node (build HTML report template)

→ HTTP Request (PDF API: html2pdf.it POST)

→ Send Email (attach binary PDF)

`

Stage 1: Pull metrics

Use HTTP Request nodes to fetch from each data source. GA4 uses the Google Analytics Data API with an OAuth2 credential. For simpler setups, most dashboard tools expose CSV exports via API or scheduled delivery — use those as inputs to a Code node that parses the CSV.

For agencies with multiple clients, store client config in Airtable or a database: one row per client with their API keys and identifiers. Use a SplitInBatches node to iterate over the client array.

Stage 2: Structure data before Claude sees it

A Code node extracts what matters and computes deltas before the Claude call. Do not send raw API JSON to Claude. Extract sessions, compute week-over-week delta percentages, select the top 5 pages, and strip everything else. Sending structured deltas lets Claude write "sessions increased 12% week-over-week" from data rather than inferring it.

Stage 3: Claude writes the summaries

One call covers a 3-section report. System prompt defines the report voice and instructs Claude to return JSON with traffic_summary, conversion_summary, seo_summary, and headline fields. User prompt carries the structured metrics object.

Add cache_control: {type: "ephemeral"} to the system prompt message block. For 20 clients per run, the prompt is cached after the first call — 90% cheaper on the repeated 19 calls.

Stage 4: Build the PDF and deliver

A Code node assembles an HTML report template using the Claude-generated text and the raw numbers. Post the HTML to html2pdf.it via HTTP Request with Content-Type text/html and Response Format Binary. The node returns a binary buffer — pass it directly to the Send Email node as an attachment named report.pdf.

What this costs

At Haiku pricing, a 3-section report runs approximately $0.002–$0.004 in Claude tokens. For 20 clients weekly with prompt caching active on the system prompt, total LLM cost is under $0.50 per month.

The PDF API (html2pdf.it) has a free tier sufficient for low-volume agency use. For self-hosted n8n, Gotenberg is a Docker-based alternative with no external API dependency.

FAQ

Does this work with Google Analytics 4?

Yes. Use the Google Analytics Data API v1 with the n8n Google Analytics OAuth2 credential. The API returns session counts, conversion events, and page data in a structured JSON response that the Code node can process directly.

What if my clients have different report structures?

Store a report_template field in the client config row. Pass it into the Claude system prompt dynamically — the Claude response JSON keys match the sections you define.

Can I use the n8n PDF node instead of html2pdf.it?

n8n does not have a native PDF node as of May 2026. The HTTP Request to html2pdf.it is the simplest approach for n8n Cloud users. For self-hosted n8n, Gotenberg (open source, Docker image) accepts HTML POST and returns PDF with no external API dependency.