Google Sheets to Gmail, payroll emails sent clean
Payroll day shouldn’t feel like a scavenger hunt through spreadsheets, attendance logs, and half-finished calculations. But if you’re still copying numbers into emails by hand, one wrong cell can turn into five follow-up threads.
HR managers run into this monthly. Payroll specialists feel it even more. And founders doing HR “for now” get stuck in it fast. This payroll email automation pulls attendance and salary rows from Google Sheets and turns them into clean, employee-ready Gmail messages.
Below, you’ll see exactly what the workflow does, what it replaces, and how to adapt it to your rules for missing hours, absences, and deductions.
How This Automation Works
The full n8n workflow, from trigger to final output:
n8n Workflow Template: Google Sheets to Gmail, payroll emails sent clean
flowchart LR
subgraph sg0["Schedule Flow"]
direction LR
n0@{ icon: "mdi:play-circle", form: "rounded", label: "Schedule Trigger", pos: "b", h: 48 }
n1["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Calculate hours per day"]
n2["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Calculate Salary Deduction"]
n3@{ icon: "mdi:database", form: "rounded", label: "Employees Attendant Sheet", pos: "b", h: 48 }
n4@{ icon: "mdi:database", form: "rounded", label: "Employees Salary Sheet", pos: "b", h: 48 }
n5["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/merge.svg' width='40' height='40' /></div><br/>Merge with Salary"]
n6@{ icon: "mdi:brain", form: "rounded", label: "OpenAI Chat Model", pos: "b", h: 48 }
n7@{ icon: "mdi:database", form: "rounded", label: "Adding the report to new sheet", pos: "b", h: 48 }
n8["<div style='background:#f5f5f5;padding:10px;border-radius:8px;display:inline-block;border:1px solid #e0e0e0'><img src='https://flowpast.com/wp-content/uploads/n8n-workflow-icons/code.svg' width='40' height='40' /></div><br/>Convert the result to JSON f.."]
n9@{ icon: "mdi:database", form: "rounded", label: "Save Email Log to Sheet", pos: "b", h: 48 }
n10@{ icon: "mdi:robot", form: "rounded", label: "Generate AI Summary Report", pos: "b", h: 48 }
n11@{ icon: "mdi:message-outline", form: "rounded", label: "Send Salary Deduction Report..", pos: "b", h: 48 }
n0 --> n3
n5 --> n2
n6 -.-> n10
n4 --> n5
n1 --> n4
n1 --> n5
n3 --> n1
n2 --> n7
n10 --> n8
n7 --> n10
n8 --> n11
n11 --> n9
end
%% Styling
classDef trigger fill:#e8f5e9,stroke:#388e3c,stroke-width:2px
classDef ai fill:#e3f2fd,stroke:#1976d2,stroke-width:2px
classDef aiModel fill:#e8eaf6,stroke:#3f51b5,stroke-width:2px
classDef decision fill:#fff8e1,stroke:#f9a825,stroke-width:2px
classDef database fill:#fce4ec,stroke:#c2185b,stroke-width:2px
classDef api fill:#fff3e0,stroke:#e65100,stroke-width:2px
classDef code fill:#f3e5f5,stroke:#7b1fa2,stroke-width:2px
classDef disabled stroke-dasharray: 5 5,opacity: 0.5
class n0 trigger
class n10 ai
class n6 aiModel
class n3,n4,n7,n9 database
class n1,n2,n8 code
classDef customIcon fill:none,stroke:none
class n1,n2,n5,n8 customIcon
The Problem: Payroll Emails Get Messy, Fast
Payroll communication is one of those processes that looks “fine” until it isn’t. You start with an attendance sheet, then a salary sheet, then you calculate missing hours, absent days, and deductions. Now multiply that by 10, 25, or 50 employees. One small mistake (wrong EmpId match, outdated salary, missed absence) leads to awkward corrections, delayed approvals, and employees losing trust in your numbers. The worst part is the mental load: you’re doing math, formatting, and customer support all at once.
The friction compounds. Here’s where it usually breaks down.
- You spend about 5–10 minutes per employee calculating and double-checking deductions, even when the rules never change.
- Copying numbers into email templates invites errors, and you often only catch them after someone replies.
- There’s no clean audit trail of what was sent, when it was sent, and what the final “official” breakdown was.
- Employees ask the same questions because the message is inconsistent or doesn’t clearly explain missing hours and absences.
The Solution: Google Sheets → Gmail Payroll Emails, Automatically
This n8n workflow turns two Google Sheets into a monthly payroll email system that runs on schedule. It starts by pulling daily attendance logs (EmpId, date, in/out time, hours worked, status). Then it computes worked hours, missing hours, and absent days for the month. Next, it merges that attendance summary with your employee master salary sheet (salary, name, email) so each person has one complete record. From there, the workflow calculates hourly/daily rates, applies your deduction logic, and writes the final payroll report row back to an output sheet for tracking. Finally, GPT-4 generates a professional, HR-friendly summary and n8n emails it out through Gmail/SMTP, then logs the send status for audit.
The workflow starts on a monthly schedule trigger. Calculations happen in the middle (hours, absences, deductions, final salary), with Google Sheets acting as both the data source and the audit destination. Then the AI Agent produces a clear summary paragraph, and Gmail sends personalized messages to each employee without you rewriting the same explanation 30 times.
What You Get: Automation vs. Results
| What This Workflow Automates | Results You’ll Get |
|---|---|
|
|
Example: What This Looks Like
Say you have 25 employees. Manually, you might spend about 8 minutes per person to total attendance issues, calculate deductions, and paste a clean breakdown into an email. That’s roughly 3 hours, and it’s the kind of work that still needs a second pass. With this workflow, you spend about 10 minutes checking the two Google Sheets for completeness, then the scheduled run generates the output rows and emails automatically. You get most of those 3 hours back, and the “did we send it?” question disappears because every send is logged.
What You’ll Need
- n8n instance (try n8n Cloud free)
- Self-hosting option if you prefer (Hostinger works well)
- Google Sheets to store attendance logs and salary data.
- Gmail (or SMTP) to send employee payroll emails.
- OpenAI API key (get it from your OpenAI dashboard under API keys)
Skill level: Intermediate. You’ll connect accounts and may adjust a couple of calculation/code nodes to match your payroll rules.
Don’t want to set this up yourself? Talk to an automation expert (free 15-minute consultation).
How It Works
A monthly schedule kicks things off. n8n runs automatically on the cadence you choose (for example, the last day of the month or the first morning after close).
Attendance data gets cleaned and totaled. The workflow pulls your daily log from Google Sheets, then computes hours worked per day and totals missing hours and absent days for the month.
Salary rules are applied consistently. It fetches the salary master sheet, merges it by EmpId, then calculates hourly/daily rates and applies deductions to output a final salary number per employee.
Employees get a clear email, and you get an audit trail. The workflow appends the final results to an output sheet, generates an HR-friendly summary with GPT-4, sends the email via Gmail/SMTP, and logs the send status back to Google Sheets.
You can easily modify deduction rules to match your policy based on your needs. See the full implementation guide below for customization options.
Step-by-Step Implementation Guide
Step 1: Configure the Schedule Trigger
This workflow runs monthly and starts by pulling attendance data for processing.
- Add the Scheduled Automation Trigger node.
- Set the trigger rule interval field to months.
- Connect Scheduled Automation Trigger to Retrieve Attendance Sheet.
Step 2: Connect Google Sheets
These nodes retrieve attendance and salary data, append payroll results, and log email sends.
- Open Retrieve Attendance Sheet and set Document to
[YOUR_ID]and Sheet toEmp list(gid=0). - Keep Authentication set to
serviceAccountand Combine Filters set toORwith Status filters forPresentandAbsent. - Open Retrieve Salary Sheet and set Document to
[YOUR_ID]and Sheet toEmp Salary(gid=1839371816). - Configure Append Payroll Report with Operation set to
append, Sheet toEmployee Monthly Report(gid=735600063), and keep Use Append enabled. - Configure Log Email Send with Operation set to
appendand Sheet toEmail Send Log(gid=1224577084). - Credential Required: Connect your googleApi credentials in Retrieve Attendance Sheet, Retrieve Salary Sheet, Append Payroll Report, and Log Email Send.
EmpId, Name, Salary, Status), or the merge and calculations will fail.Step 3: Set Up Attendance Processing and Salary Merge
This stage calculates hours, runs a parallel branch to retrieve salaries, and combines datasets before calculating final salary deductions.
- Open Compute Daily Hours and keep the JavaScript as provided to calculate totals, missing hours, and attendance status.
- Ensure Compute Daily Hours outputs to both Retrieve Salary Sheet and Combine Salary Data in parallel.
- Open Combine Salary Data and set Mode to
combineand Fields to Match toEmpId. - Open Compute Salary Adjustment and keep the provided JavaScript that calculates
DeductionandFinalSalary.
Step 4: Configure AI Summary Generation
This step uses an AI model to create a professional summary per employee and then formats it for email sending.
- In Produce AI Summary, set Text to
=Employee ID : {{ $json.EmpId }} Name : {{ $json.Name }} Original Salary :{{ $json.OriginalSalary }} Total Missing Hours:{{ $json.TotalMissingHours }} Total Absent Days {{ $json.TotalAbsentDays }} Deduction: {{ $json.Deduction }} Final Salary: {{ $json.FinalSalary }} EmpEmail: {{ $json.EmpEmail }}. - In Produce AI Summary, set System Message to the provided HR assistant prompt so it returns an array of objects with
SummaryText. - Open OpenAI Chat Engine and set Model to
gpt-4.1-mini. - Credential Required: Connect your openAiApi credentials in OpenAI Chat Engine.
- Open Format Summary JSON and keep the provided JavaScript to parse the model output into individual employee objects.
Step 5: Configure Email Output and Logging
Send the AI-generated summary email and record the result in a Google Sheet.
- Open Dispatch Salary Email and set Text to
={{ $json.SummaryText }}. - Set Subject to
={{ $json.EmpEmail }}and To Email to=Monthly Salary Summary – {{ $json.Name }} (Emp ID: {{ $json.EmpId }}). - Set From Email to
[YOUR_EMAIL]and keep Email Format astext. - Credential Required: Connect your smtp credentials in Dispatch Salary Email.
- Connect Dispatch Salary Email to Log Email Send to append delivery results.
Step 6: Test and Activate Your Workflow
Run a manual test to confirm data flow, AI summaries, and email delivery before activating the monthly schedule.
- Click Execute Workflow to run a manual test from Scheduled Automation Trigger.
- Confirm Retrieve Attendance Sheet and Retrieve Salary Sheet return data, and that Combine Salary Data matches on
EmpId. - Verify Append Payroll Report added rows to the
Employee Monthly Reportsheet. - Check that Dispatch Salary Email sends messages and Log Email Send writes results to
Email Send Log. - Once validated, toggle the workflow to Active so it runs monthly.
Common Gotchas
- Google Sheets credentials can expire or need specific permissions. If things break, check the n8n Credentials screen and the connected Google account’s access to the exact spreadsheets first.
- If your attendance sheet has inconsistent date formats or missing InTime/OutTime values, the “Compute Daily Hours” logic can miscount hours. Clean the sheet or add a fallback rule before month-end close.
- OpenAI summaries can sound generic if you leave the default prompt untouched. Add your tone and required details early (policy wording, who to contact, how disputes work) or you’ll be editing outputs forever.
Frequently Asked Questions
About 45 minutes if your Google Sheets are already structured.
No, not for the setup basics. You may want light edits in the calculation nodes if your deduction rules are unique.
Yes. n8n has a free self-hosted option and a free trial on n8n Cloud. Cloud plans start at $20/month for higher volume. You’ll also need to factor in OpenAI API costs (usually a few dollars a month for small teams).
Two options: n8n Cloud (managed, easiest setup) or self-hosting on a VPS. For self-hosting, Hostinger VPS is affordable and handles n8n well. Self-hosting gives you unlimited executions but requires basic server management.
Yes. You can adjust the “Compute Daily Hours” and “Compute Salary Adjustment” code nodes to match your policy, then tweak the AI Agent prompt to reflect your wording. Common customizations include rounding rules for late arrivals, different absent-day penalties, and excluding certain statuses (like approved leave) from deductions.
Usually it’s expired OAuth permission or the wrong sender account selected in n8n. Reconnect the Gmail credential, confirm the correct Google Workspace user has access, and double-check that the “Dispatch Salary Email” node is pointing at that credential. If you’re sending a lot at once, Gmail can also throttle briefly, so spacing sends or batching by department helps.
Dozens to hundreds, assuming your Google Sheet is clean and your n8n instance has enough memory.
Often, yes, because payroll logic is messy in real life. n8n handles multi-step calculations, merging datasets by EmpId, and writing an audit trail back to Google Sheets without forcing you into expensive “task” pricing for every row. It also plays nicely with AI Agent + GPT-4, which is where your email summaries get that professional polish. Zapier or Make can still work if you only need a simple “new row → send email” flow. If you want a sanity check for your setup, Talk to an automation expert.
Once this is running, payroll emails stop being a monthly fire drill. The workflow handles the repetitive checks and formatting so you can focus on exceptions, not copy-paste.
Need Help Setting This Up?
Our automation experts can build and customize this workflow for your specific needs. Free 15-minute consultation—no commitment required.