Quick Overview
This workflow runs monthly to compare current vs. previous payroll data in Google Sheets, detect pay anomalies, alert Finance in Slack, email HR via Gmail, and log discrepancies back to a Google Sheets audit tab.
How it works
- Runs on a monthly schedule (cron: 0 9 25 * *) to start a pre-payroll review.
- Reads the current pay run and the previous pay run from two Google Sheets tabs.
- Compares both periods per employee to flag duplicates, unmatched employees, pay without hours, and large net pay swings based on percentage thresholds.
- If no anomalies are found, posts an all-clear message to a Slack channel.
- For each flagged anomaly, classifies severity and posts an immediate Slack “payroll hold” alert for Critical items.
- Appends each flagged anomaly to an AnomalyLog tab in Google Sheets and emails HR a per-employee review message via Gmail.
- Aggregates all flagged items into a run-level digest and posts the summary and recommendation to Slack for Finance.
Setup
- Add Google Sheets credentials and set your spreadsheet ID, ensuring it contains the CurrentPayRun, PreviousPayRun, and AnomalyLog tabs.
- Ensure your payroll sheets include the expected columns (employee_id, name, net_pay, hours, status, and email) so the discrepancy checks work correctly.
- Add Slack credentials and replace the Slack channel ID(s) used for critical holds, digests, and all-clear messages.
- Add Gmail credentials and set the HR recipient email address for anomaly review notifications.
- Adjust the schedule cron expression and the discrepancy thresholds in the detection code (for example, 15%, 40%, and 80%) to match your payroll policies.