Quick overview
This workflow builds weekly client report emails from Google Sheets data, generates a short narrative with Google Gemini, routes the draft through a Gmail approval step, and logs each report’s status back to Google Sheets before sending the final email via Gmail.
How it works
- Starts manually (demo) or on a weekly schedule and loads the report configuration such as the Google Sheets spreadsheet ID and sender name.
- Reads active clients from a Google Sheets “Clients” tab, calculates each client’s reporting and comparison date ranges, builds a unique report key, and skips clients whose report is already in a terminal status in the “Reports” tab.
- Pulls the matching weekly context and current/previous metrics from Google Sheets (“Weekly Context” and “Ads Data”), normalizes the dataset, and validates that required fields and metric consistency checks pass.
- Calculates week-over-week KPI changes, compiles verified facts, and uses Google Gemini to draft a short summary which is then validated to ensure it is strict JSON and contains no numbers.
- Builds the final HTML email (including a deterministic metrics table), logs the report as PENDING_APPROVAL in the Google Sheets “Reports” tab, and sends a Gmail approval request to the reviewer with a 24-hour decision window.
- If approved, logs SENDING, sends the client email via Gmail, verifies the Gmail message ID, and writes a final SENT status to Google Sheets; if rejected or timed out (or data/AI validation fails), it writes REJECTED, APPROVAL_TIMEOUT, or DATA_ERROR without emailing the client.
Setup
- Create a Google Sheets workbook with tabs named “Clients”, “Weekly Context”, “Ads Data”, and “Reports”, and ensure the columns used for matching include client_id, period_start, period_end, period_type, and report_key.
- Add Google Sheets OAuth2 credentials in n8n and set your spreadsheet ID and sender name in the workflow configuration fields.
- Add Google Gemini credentials for the Gemini model used to generate the summary.
- Add Gmail OAuth2 credentials for both the reviewer approval email and the outbound client email, and populate each client’s reviewer_email and recipient_email in the “Clients” sheet.
- Run the workflow in test/demo mode first with mailboxes you control, then disable test mode and enable the schedule trigger when you are ready for live weekly sending.