Internal Automation · Document Generation2026
Annual club reports, generated end to end
End-to-end pipeline that aggregates evaluation data, runs Word mail-merge, auto-fixes layout issues, and publishes finalized reports to the site.
250+ h
of report production removed every year

- Client
- Distinguished Clubs
- Year
- 2026
- Type
- Internal Automation · Document Generation
What was the problem?
Distinguished Clubs generates detailed Word evaluation reports for every member club every year. Each report pulled data from multiple sources (internal APIs, survey datasets, club records), used a Word mail-merge template, then required someone to manually fix recurring design and layout issues before publishing — 250+ hours a year of pure document grunt work.
A club's report is not one template filled once. Over 300 fields of data feed it: club details, staff, department by department results, scores and survey answers. Different clubs have different departments, so a generic template always has holes, such as a department that does not exist at a club or a score block with nothing in it.
After the merge, someone had to find and fix those recurring design and layout problems by hand, report after report, before anything could be published.
How did I approach it?
Every source is first flattened into one CSV row per club with a fixed schema, and the Word merge reads only that CSV. Data sources can change without touching the document code, and a person can open the CSV and see exactly what went into a report.
The merge is the easy half. The harder half is everything the merge leaves behind, so the merge is followed by a set of cleanup rules that remove what is empty or wrong, instead of keeping a different template for every kind of club.
Staff trigger it from HubSpot. A CRM card on the club's company record lets them pick a report type and click Generate. The backend queues the job and writes the download links back to the company record when it finishes. Generation takes a few minutes, so the card returns immediately and the links appear once the job is done.
What did I build?
- Aggregate
- Map fields
- Merge
- Auto-fix layout
- Publish
- 1Aggregates evaluation data across internal APIs, surveys, and club records.
- 2Maps every required mail-merge field automatically.
- 3Runs the merge with the Word template.
- 4Auto-fixes the recurring design and layout issues that previously needed manual cleanup.
- 5Publishes finalized reports directly to the Distinguished Clubs site.
How does it handle the hard parts?
What does the cleanup actually remove and fix?
It removes template highlighting, unmerged field markers, empty bullets and list items, empty table rows, whole department sections when all of their fields are empty, empty summary sections, and placeholder values such as 0%, #VALUE! and N/A. It also fixes checkbox fonts, fixes orphaned headings, turns URLs into hyperlinks and swaps the cover medallion to match the club's designation.
What happens when a club has no evaluation, or several?
A club can have several evaluations on file, so the user can choose which one a report uses instead of the system assuming the newest. When no evaluation exists, the card shows an error message instead of a broken download link. The nomination letter is built from form values and HubSpot alone, with no call to the evaluation feed, so it still works for clubs without an evaluation.
How is a finished report checked?
A rule-based linter inspects the data row and the finished Word file for structural problems: empty cover fields, missing department headings, empty score blocks, a fallback path triggered silently, sparse pages. It also builds a per-department coverage matrix. An optional AI review then reads the linter's findings and writes a plain-language summary of the likely root causes, plus a draft message for the data provider grouped by cause. The AI step runs on demand, and if the linter finds nothing it is skipped.
How does it cope with the whole membership?
Reports run as jobs, processed concurrently with a configurable level of parallelism, and failed fetches are retried with exponential backoff. A batch of clubs does not have to run one at a time.
What was the result?
- 250+ hours a year of manual merging and layout fixes removed.
- Data in, published report out, with no manual step in between.
- The annual reporting cycle runs faster and the same way every year.
The 250+ hours a year on this page is the report-production time removed. The same engine also produces the designation and nomination letters.
What is it built with?
- Python
- Word mail-merge automation
- Multi-source data aggregation
- CMS publishing
- Python and FastAPI: the job queue, the data aggregation and the API behind the HubSpot card
- python-docx: does the Word merge and the cleanup by editing the document directly
- HubSpot CRM card: a React card on the company record: choose a report, generate, and see the download links
- CSV as the intermediate format: the one place where all sources meet before the merge
- automation
- document generation
- mail merge
- cms integration
Related guide
- How to automate repetitive work — How to automate repetitive tasks: score the work, pick a tool from formulas to custom code, automate data entry from email or PDF, and avoid common pitfalls.