👥 Manage employee leave requests with Google Forms, Sheets, Gmail and Gemini

⚡ 14 views · 👥 HR & Recruitment

Description

Quick overview

This workflow collects employee leave requests via an n8n Form, checks leave balances stored in Google Sheets, emails managers for approval through Gmail (with a Google Gemini-generated message), and updates request status and balances in Google Sheets based on the manager’s email reply.

How it works

  1. Receives a leave request submission from an n8n Form with employee, manager, date range, leave type, and reason.
  2. Looks up the employee in a Google Sheets “Employee Data” spreadsheet and calculates requested days and whether sufficient leave balance exists.
  3. If the balance is insufficient, sends a rejection email to the employee via Gmail.
  4. If the balance is sufficient, uses Google Gemini to draft a manager approval email and sends it to the manager via Gmail.
  5. Stores or updates the leave request in a Google Sheets “Leave Requests” spreadsheet with a generated request ID, status “Pending”, and the Gmail thread ID.
  6. Polls Gmail for the manager’s reply, extracts APPROVED/REJECTED, and finds the matching request in Google Sheets using the Gmail thread ID.
  7. Updates the request status in the “Leave Requests” sheet and, when approved, deducts the requested days from the corresponding leave balance in the “Employee Data” sheet based on leave type.

Setup

  1. Connect Gmail credentials for sending the employee/manager emails and for the Gmail Trigger that reads manager replies.
  2. Connect Google Sheets credentials and replace the document IDs/sheet tabs for both the “Employee Data” spreadsheet and the “Leave Requests” spreadsheet.
  3. Ensure the “Employee Data” sheet includes columns for Employee ID and leave balances (Casual/Causal Leave, Sick Leave, Earned Leave) plus Manager Name and Manager Email.
  4. Ensure the “Leave Requests” sheet includes columns matching the workflow mapping (Request ID, Employee ID, dates, Requested Days, Reason, Status, Gmail Thread ID, Manager Reply, Approval Date).
  5. Add a Google Gemini (PaLM) API credential and select the desired Gemini model in the AI message step.
  6. Publish the n8n Form and share it with employees so submissions reach this workflow.

Additional info

Troubleshooting Guide

IssuePossible CauseSolution
Leave balance is not deductedWrong leave column mappingCheck Casual Leave, Sick Leave, and Earned Leave mappings
7-2 appears instead of 5Values are treated as textUse Number() in the n8n expression
Manager reply is emptyGmail output uses different field namesUse the Gmail snippet field when required
Manager email is emptyGmail field is From instead of fromUse email.From
Subject is emptyGmail field is Subject instead of subjectUse email.Subject
Leave request cannot be foundThread ID was not savedSave the Gmail Thread ID in Leave Requests
Wrong leave request is updatedIncorrect Employee ID or Thread ID mappingVerify the lookup field and value
Employee notification not sentInvalid email addressCheck Employee Email in Employee Data
Manager approval not detectedReply does not start with APPROVED/REJECTEDAsk manager to reply exactly with APPROVED or REJECTED
Balance becomes negativeIncorrect balance checkEnsure approval is allowed only when available balance is greater than or equal to requested days

Need Help?

If you need help customizing or extending this workflow, adding multi-level approvals, reminders, escalation, leave reports, dashboards, holiday calculations or additional leave types, then WeblineIndia’s n8n team can assist you with advanced automation.

đź”— Nodes Used

Google Sheets, Gmail, Gmail Trigger, n8n Form Trigger, Google Gemini

📥 Import

Download workflow.json and import into n8n: Workflow menu → Import from File

📖 Importing guide · 🔑 Credential setup