Case Study · Workflow & Document Automation
Automated Client Intake & Agreement Pipeline
Replacing a Google Apps Script intake pipeline with a self-hosted n8n and Gotenberg microservice stack routed over Cloudflare Tunnel.
- n8n
- Gotenberg
- Docker
- Cloudflare Tunnel
- HTML5 Canvas
- Google Workspace
1. The Challenge
Onboarding a new residential pet- and house-sitting client requires capturing detailed care instructions, emergency contacts, utility shut-off locations, and a legally binding digital signature. The original system relied on a custom Google Apps Script that worked, but created three architectural constraints:
- API & formatting rigidity: Generating PDFs through Google Docs templates required temporary file copies and couldn’t natively inject raw base64 canvas signatures without staging temporary image files in Drive.
- Limited extensibility: Extending the script to talk to future self-hosted tools—like a local CRM or unified homelab alerting—meant maintaining brittle, monolithic JavaScript.
- High-sensitivity data: Intake submissions contain physical security details (lockbox codes, gate codes, alarm instructions, and travel dates) that require strict transit encryption and minimal retention at rest.
2. System Architecture
I rebuilt the pipeline as a visual, containerized microservice stack running on an isolated VLAN inside my Proxmox homelab, keeping the public-facing form lightweight and static:
- Static Intake Form & Signature Pad (Cloudflare Pages): A mobile-first HTML form captures client details alongside an HTML5
<canvas>signature pad serialized as a base64 PNG string. - Zero-Trust Ingestion (Cloudflare Tunnel → n8n Webhook): Submissions POST over HTTPS through a dedicated Cloudflare Tunnel straight to a self-hosted n8n container—requiring zero open ports on the home router.
- Isolated Local PDF Rendering (Docker Bridge → Gotenberg): An n8n Code node sanitizes fields and compiles a print-styled HTML agreement with the base64 signature embedded inline, then posts it across a private Docker network to a headless Chromium Gotenberg container that renders the PDF in RAM.
- Parallel Cloud Archiving, Logging & Delivery: Once Gotenberg returns the PDF, n8n splits into parallel branches—archiving the signed PDF to Google Drive, appending a structured 25-column record to Google Sheets, emailing a copy to the client, and returning a branded confirmation screen.
3. Key Engineering Decisions
Private Docker Networking & Zero Exposed Ports
Gotenberg runs on a custom internal Docker bridge network alongside n8n with no host port bindings. Because Docker provides built-in internal DNS on named bridges, n8n sends requests directly to http://gotenberg:3000 while Gotenberg remains completely unreachable from the local LAN or the public internet.
Parallel Branching to Preserve Binary Streams
In n8n, downstream database nodes (like Google Sheets) strip binary file attachments from their output stream. Branching directly off the Gotenberg HTTP Request node hands the exact same binary PDF to both Google Drive and the outbound email node simultaneously.
Solving the Google Sheets “Row 1001” API Quirk
An early iteration used a column-wide ARRAYFORMULA in Row 1 to auto-generate sequential Intake IDs (AC-1001, AC-1002). Because an array formula claims ownership of every row in the sheet, the Google Sheets API skipped all 1,000 rows and appended new clients at Row 1001. Passing a lightweight row-level formula directly from n8n restored clean sequential appending without extra read calls.
Zero-Retention Privacy Hardening: Because live submissions include client lockbox and alarm codes, production traffic runs with n8n’s Save successful executions set to Do not save. The homelab VM acts purely as an in-memory pass-through pipe, while still logging failed runs and firing an automated Error Trigger alert if anything breaks.
4. Lessons Learned
- HTML-to-PDF beats document templates: Rendering agreements with standard HTML and CSS inside Gotenberg gave pixel-level layout control and native base64 signature embedding without third-party PDF APIs.
- Treat visual workflows as code: Exporting the n8n workflow as a version-controlled JSON file in a separate private backend repository keeps internal IDs out of public frontend builds.
- Build for future extensions: Because the intake payload is already normalized inside n8n, adding a future parallel branch to upsert client records into a self-hosted CRM requires zero changes to the client-facing form.
