Predict employee attrition risk with Google Sheets, OpenAI, Gmail, and Telegram

Go to Workflow
3 views
Built by Rahul Joshi Rahul Joshi
Created on July 28, 2026

Description

Quick overview
This workflow runs weekly to pull HR datasets from Google Sheets, calculate rule-based attrition risk signals, and enrich them with an OpenAI (GPT-4o-mini) risk assessment. It logs results back to Google Sheets, sends high-risk alerts via Telegram, emails an HTML digest via Gmail .

How it works
Runs every week on a schedule trigger.
Reads employee master data, attendance, engagement surveys, performance reviews, and 1:1 notes from Google Sheets and merges them into one profile per employee.
Calculates a rule-based flight-risk score and factors, and builds an anonymized payload for model analysis.
Sends the anonymized employee signals to OpenAI (GPT-4o-mini), parses the returned JSON risk assessment, and falls back to rule-only scoring while notifying an admin in Telegram if parsing fails.
Combines the rule-based and LLM scores into a composite risk score and assigns a risk level.
Sends a Telegram alert and appends a flagged record to the Google Sheets Risk_Dashboard for high-risk employees, while logging standard-risk outcomes to the same sheet.
Reads the day’s Risk_Dashboard entries, builds an HTML summary, and emails the weekly digest to the HR team via Gmail.
If any workflow node errors, posts an execution alert to a Slack channel.

Setup
Add Google Sheets OAuth credentials, set your Google Sheet ID, and ensure the spreadsheet includes tabs named Employees_Master, Attendance, Engagement_Survey, Performance_Reviews, OneOnOne_Notes, and Risk_Dashboard.
Add an OpenAI credential and confirm the model selection (gpt-4o-mini) matches what’s available in your account.
Add Telegram Bot credentials and replace YOUR_TELEGRAM_CHAT_ID for both the high-risk alert and LLM-failure admin notification.
Add Gmail OAuth credentials and set the recipient address for the HR digest email.
Add Slack OAuth credentials and replace YOUR_SLACK_CHANNEL_ID for workflow error alerts.
Review and adjust the high-risk threshold value (default 70) and the weekly cron schedule as needed.

This workflow was created by Rahul Joshi and shared publicly on the n8n community template library. n8nFind indexes it for discovery — the workflow remains the property of its original creator.

Nodes Used (6)

Code
n8n-nodes-base.code
Gmail
n8n-nodes-base.gmail
Google Sheets
n8n-nodes-base.googleSheets
OpenAI
@n8n/n8n-nodes-langchain.openAi
Slack
n8n-nodes-base.slack
Telegram
n8n-nodes-base.telegram