Automate Employee Data Tracking & Reminders for HR with JavaScript
# HR Date Management Automation - Complete Setup Guide
## **How It Works**
This n8n workflow transforms your HR department from reactive to proactive by automatically monitoring 5 critical employee timelines and generating smart alerts before deadlines hit.
### **Core Components**
1. **Data Input** – Employee information (hire dates, contracts, certifications)
2. **Date Analysis Engine** – Calculates days until critical events
3. **Smart Categorization** – Sorts employees by urgency level
4. **Reminder Scheduler** – Creates proactive notifications
5. **Multi-Format Export** – Sends alerts to your preferred systems
### **Business Value**
- **Prevents compliance violations** ($5K-50K+ in fines)
- **Reduces HR workload** (15-20 hours/month saved)
- **Improves employee experience** (no missed reviews/renewals)
- **Provides management visibility** (dashboard reporting)
-----
## **Quick Start Guide**
### **1. Import the Workflow**
1. Download the `Javascript_Hr.json` file
2. Open n8n and click "Import from file"
3. Select the downloaded JSON file
4. Click "Import"
### **2. Test with Sample Data**
1. Click the "Execute Workflow" button
2. Review the sample output in each node
3. Check the final export data format
**What you'll see:**
- 5 sample employees with different scenarios
- Calculated days until contract/certification expiry
- Priority levels (high/medium/low)
- Scheduled reminders with recipient emails
- Export data in multiple formats
-----
## **Real-World Integration Setup**
### **Option 1: Google Sheets Integration (Most Popular)**
#### **Step 1: Prepare Your Employee Data**
Create a Google Sheet with these columns:
```
| Employee ID | Name | Email | Department | Hire Date | Contract End | Certification Expiry | Last Review | Probation End | Vacation Days | Status |
```
**Sample data format:**
```
| 1 | John Smith | john@company.com | IT | 2024-01-15 | 2025-12-31 | 2025-03-20 | 2024-06-15 | 2024-07-15 | 20 | active |
```
#### **Step 2: Replace Sample Data Generator**
1. Delete the "Sample Data Generator" node
2. Add "Google Sheets" node
3. Connect to your Google account
4. Configure these settings:
- **Operation**: Read
- **Document**: Your employee spreadsheet
- **Sheet**: Employee data sheet
- **Range**: A1:K100 (adjust for your data size)
- **Options**: Include RAW data, Include Header row
#### **Step 3: Map Your Data**
Add a "Set" node after Google Sheets to standardize field names:
```javascript
// Map your sheet columns to workflow format
{ id: {{ $json["Employee ID"] }}, name: {{ $json["Name"] }}, email: {{ $json["Email"] }}, department: {{ $json["Department"] }}, hiredOn: {{ $json["Hire Date"] }}, contractEndDate: {{ $json["Contract End"] }}, certificationExpiry: {{ $json["Certification Expiry"] }}, lastReviewDate: {{ $json["Last Review"] }}, probationEndDate: {{ $json["Probation End"] }}, vacationDays: {{ $json["Vacation Days"] }}, status: {{ $json["Status"] }}
}
```
### **Option 2: HRIS Integration (BambooHR Example)**
#### **Step 1: BambooHR API Setup**
1. Get your BambooHR API key from Settings > API Keys
2. Note your company subdomain (e.g., `yourcompany.bamboohr.com`)
#### **Step 2: Replace Sample Data Generator**
1. Delete the "Sample Data Generator" node
2. Add "HTTP Request" node
3. Configure these settings:
- **Method**: GET
- **URL**: `https://api.bamboohr.com/api/gateway.php/[SUBDOMAIN]/v1/employees/directory`
- **Authentication**: Basic Auth
- **Username**: Your API key
- **Password**: x (leave as "x")
- **Headers**: `Accept: application/json`
#### **Step 3: Transform BambooHR Data**
Add a "Code" node to transform the API response:
```javascript
// Transform BambooHR response to workflow format
const employees = [];
for (const employee of $input.all()) { const emp = employee.json; employees.push({ id: emp.id, name: `${emp.firstName} ${emp.lastName}`, email: emp.workEmail, department: emp.department, hiredOn: emp.hireDate, contractEndDate: emp.terminationDate || "2025-12-31", // Default if not set certificationExpiry: emp.customCertDate || "2025-12-31", lastReviewDate: emp.customReviewDate || null, probationEndDate: emp.customProbationDate || null, vacationDays: emp.paidTimeOff || 20, status: emp.employeeStatus || "active" });
}
return employees.map(emp => ({ json: emp }));
```
### **Option 3: CSV File Upload**
#### **Step 1: Prepare CSV File**
Create a CSV with the same structure as the Google Sheets format.
#### **Step 2: Use CSV Parser**
1. Replace "Sample Data Generator" with "Read Binary File" node
2. Add "CSV Parser" node
3. Configure settings:
- **Include Headers**: Yes
- **Delimiter**: Comma
- **Skip Empty Lines**: Yes
-----
## **Output Integration Setup**
### **Email Notifications**
#### **Step 1: Add Email Node**
1. Add "Email" node after "Reminder Scheduler"
2. Connect to your email provider (Gmail/Outlook)
- Platform
- n8n
- Category
- HR & Operations
- Price
- Free
- Creator
- David Olusola
- hr-alerts
- set
- code
- gmail
- slack
- stickyNote
- googleSheets
- manualTrigger
- googleCalendar