This workflow follows the Gmail → Googlegemini recipe pattern — see all workflows that pair these two integrations.
The workflow JSON
Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →
{
"id": "5tV27QR2I6Jk6Fra",
"meta": {
"templateCredsSetupCompleted": true
},
"name": "N-0165 Receiving Behavior Analytics Workflow",
"tags": [],
"nodes": [
{
"id": "3e93e2e3-b9fd-4811-952d-babe48cd3279",
"name": "Schedule: Run Every Hour",
"type": "n8n-nodes-base.scheduleTrigger",
"position": [
-13712,
2256
],
"parameters": {
"rule": {
"interval": [
{
"field": "hours"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "063763ff-99e1-4165-b99d-80dc69bedf97",
"name": "Get Receiving Data",
"type": "n8n-nodes-base.googleSheets",
"position": [
-13488,
2256
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-xi1-tWQgY6NXNyqXE0bFf9WxpwWRfhsWpqmPw3l48E/edit#gid=0",
"cachedResultName": "ReceivingLogs"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1-xi1-tWQgY6NXNyqXE0bFf9WxpwWRfhsWpqmPw3l48E",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-xi1-tWQgY6NXNyqXE0bFf9WxpwWRfhsWpqmPw3l48E/edit?usp=drivesdk",
"cachedResultName": "Receiving behaviour"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 4.4
},
{
"id": "d787847d-f1da-4c54-a463-4b1e98ff0cd9",
"name": "Clean & Normalize Input Data",
"type": "n8n-nodes-base.set",
"position": [
-13264,
2256
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "norm-user_id",
"name": "user_id",
"type": "string",
"value": "={{ $json.user_id }}"
},
{
"id": "norm-duration",
"name": "duration",
"type": "number",
"value": "={{ Number($json.duration) }}"
},
{
"id": "norm-errors",
"name": "errors",
"type": "number",
"value": "={{ Number($json.errors) }}"
},
{
"id": "norm-compliance",
"name": "compliance",
"type": "boolean",
"value": "={{ String($json.compliance).toLowerCase() === 'true' || $json.compliance === true || $json.compliance === 1 || String($json.compliance).toLowerCase() === 'yes' }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "264d706d-3e10-42a2-81c5-faddaa2c9a97",
"name": "Group Data by User",
"type": "n8n-nodes-base.itemLists",
"position": [
-13024,
2256
],
"parameters": {
"options": {
"outputFormat": "separateItems"
},
"operation": "summarize",
"fieldsToSplitBy": "user_id",
"fieldsToSummarize": {
"values": [
{
"field": "duration",
"aggregation": "average"
},
{
"field": "errors",
"aggregation": "sum"
},
{
"field": "compliance",
"aggregation": "concatenate"
}
]
}
},
"typeVersion": 3.1
},
{
"id": "b6464394-61d9-4d35-b004-e22d82763d07",
"name": "Analyze User Performance",
"type": "n8n-nodes-base.code",
"position": [
-12720,
2256
],
"parameters": {
"jsCode": "const items_out = [];\n\nfor (const item of items) {\n const d = item.json;\n\n // \u2500\u2500 1. COMPLIANCE RATE \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n let compliance_rate = 1.0;\n let total_records = 0;\n\n if (d.concatenated_compliance !== undefined && d.concatenated_compliance !== null) {\n const raw = d.concatenated_compliance.toString().trim();\n if (raw.length > 0) {\n const vals = raw.split(',').map(v => v.trim().toLowerCase()).filter(v => v !== '');\n const compliantCount = vals.filter(v => v === 'true' || v === '1' || v === 'yes').length;\n compliance_rate = vals.length > 0 ? compliantCount / vals.length : 1.0;\n total_records = vals.length;\n }\n }\n\n // \u2500\u2500 2. SAFE PARSING \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const avg_duration = isNaN(Number(d.average_duration)) ? 0 : parseFloat(Number(d.average_duration).toFixed(2));\n const total_errors = parseInt(d.sum_errors, 10) || 0;\n\n // \u2500\u2500 3. PERFORMANCE \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n let performance = 'good';\n const issues = [];\n const flags = { slow: false, error_prone: false, non_compliant: false };\n\n if (avg_duration > 15) { flags.slow = true; issues.push(`High processing time (${avg_duration.toFixed(1)} min avg)`); }\n if (total_errors > 5) { flags.error_prone = true; issues.push(`Frequent errors (${total_errors} total)`); }\n if (compliance_rate < 0.9) { flags.non_compliant = true; issues.push(`Low compliance rate (${(compliance_rate * 100).toFixed(1)}%)`); }\n\n if (flags.non_compliant && flags.error_prone) performance = 'critical';\n else if (flags.non_compliant) performance = 'non_compliant';\n else if (flags.error_prone) performance = 'error_prone';\n else if (flags.slow) performance = 'slow';\n\n // \u2500\u2500 4. SEVERITY SCORE \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n const duration_score = avg_duration > 15 ? Math.min(25, Math.round((avg_duration - 15) * 3)) : 0;\n const error_score = total_errors > 5 ? Math.min(40, Math.round((total_errors - 5) * 4)) : 0;\n const compliance_score = compliance_rate < 0.9 ? Math.min(35, Math.round((0.9 - compliance_rate) * 350)) : 0;\n const severity_score = Math.min(100, duration_score + error_score + compliance_score);\n\n // \u2500\u2500 5. ALERT TIER \u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\n let alert_tier = 'none';\n if (severity_score >= 70) alert_tier = 'critical';\n else if (severity_score >= 40) alert_tier = 'warning';\n else if (severity_score >= 10) alert_tier = 'info';\n if (severity_score >= 70) performance = 'critical';\n\n items_out.push({\n json: {\n user_id: d.user_id,\n avg_duration,\n total_errors,\n total_records,\n compliance_rate: parseFloat(compliance_rate.toFixed(3)),\n performance,\n issues: issues.join('; ') || 'No issues',\n issues_count: issues.length,\n severity_score,\n alert_tier,\n analyzed_at: new Date().toISOString()\n }\n });\n}\n\nreturn items_out;"
},
"typeVersion": 2
},
{
"id": "df16319c-7c88-4422-923d-b41413f773a6",
"name": "Fetch Department Details",
"type": "n8n-nodes-base.googleSheets",
"position": [
-12480,
2256
],
"parameters": {
"options": {},
"filtersUI": {
"values": [
{
"lookupValue": "={{ $json.user_id }}",
"lookupColumn": "user_id"
}
]
},
"sheetName": {
"__rl": true,
"mode": "list",
"value": 344897345,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-xi1-tWQgY6NXNyqXE0bFf9WxpwWRfhsWpqmPw3l48E/edit#gid=344897345",
"cachedResultName": "Departments"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1-xi1-tWQgY6NXNyqXE0bFf9WxpwWRfhsWpqmPw3l48E",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-xi1-tWQgY6NXNyqXE0bFf9WxpwWRfhsWpqmPw3l48E/edit?usp=drivesdk",
"cachedResultName": "Receiving behaviour"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 4.4
},
{
"id": "23185c33-c856-4027-a8e0-023cda776873",
"name": "Attach Department Info",
"type": "n8n-nodes-base.set",
"position": [
-12256,
2256
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "enrich-user_id",
"name": "user_id",
"type": "string",
"value": "={{ $('Analyze User Performance').item.json.user_id }}"
},
{
"id": "enrich-department",
"name": "department",
"type": "string",
"value": "={{ $json.department ?? 'Unknown' }}"
},
{
"id": "enrich-manager_email",
"name": "manager_email",
"type": "string",
"value": "={{ $json.manager_email ?? '' }}"
},
{
"id": "enrich-performance",
"name": "performance",
"type": "string",
"value": "={{ $('Analyze User Performance').item.json.performance }}"
},
{
"id": "enrich-alert_tier",
"name": "alert_tier",
"type": "string",
"value": "={{ $('Analyze User Performance').item.json.alert_tier }}"
},
{
"id": "enrich-issues",
"name": "issues",
"type": "string",
"value": "={{ $('Analyze User Performance').item.json.issues }}"
},
{
"id": "enrich-severity_score",
"name": "severity_score",
"type": "number",
"value": "={{ $('Analyze User Performance').item.json.severity_score }}"
},
{
"id": "enrich-avg_duration",
"name": "avg_duration",
"type": "number",
"value": "={{ $('Analyze User Performance').item.json.avg_duration }}"
},
{
"id": "enrich-total_errors",
"name": "total_errors",
"type": "number",
"value": "={{ $('Analyze User Performance').item.json.total_errors }}"
},
{
"id": "enrich-total_records",
"name": "total_records",
"type": "number",
"value": "={{ $('Analyze User Performance').item.json.total_records }}"
},
{
"id": "enrich-compliance_rate",
"name": "compliance_rate",
"type": "number",
"value": "={{ $('Analyze User Performance').item.json.compliance_rate }}"
},
{
"id": "enrich-analyzed_at",
"name": "analyzed_at",
"type": "string",
"value": "={{ $('Analyze User Performance').item.json.analyzed_at }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "4550bbc5-f79f-414c-8919-c4b9109d21f9",
"name": "Check if Performance Needs Action",
"type": "n8n-nodes-base.if",
"position": [
-11984,
2240
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "cond-performance",
"operator": {
"type": "string",
"operation": "notEquals"
},
"leftValue": "={{ $json.performance }}",
"rightValue": "good"
}
]
}
},
"typeVersion": 2
},
{
"id": "53d0a6cb-7304-4b9d-8ad2-d69939fcc3d9",
"name": "Build AI Analysis Prompt",
"type": "n8n-nodes-base.set",
"position": [
-11776,
2064
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "prompt-field",
"name": "prompt",
"type": "string",
"value": "=You are a procurement operations analyst.\n\nAnalyze the following warehouse receiving behavior data and generate structured, actionable recommendations.\n\nDATA:\nUser ID: {{ $json.user_id }}\nDepartment: {{ $json.department }}\nPerformance Status: {{ $json.performance }}\nAlert Tier: {{ $json.alert_tier }}\nIdentified Issues: {{ $json.issues }}\nAverage Task Duration: {{ $json.avg_duration }} minutes\nTotal Errors Recorded: {{ $json.total_errors }}\nTotal Records Analyzed: {{ $json.total_records }}\nCompliance Rate: {{ ($json.compliance_rate * 100).toFixed(1) }}%\nSeverity Score: {{ $json.severity_score }}/100\nAnalyzed At: {{ $json.analyzed_at }}\n\nINSTRUCTIONS:\n- Be precise and operational (warehouse context)\n- Do not repeat input data\n- Do not add assumptions outside given data\n- Keep response concise but actionable\n\nSTRICT OUTPUT FORMAT (DO NOT CHANGE FORMAT):\n\nRoot Cause:\n- <bullet point>\n- <bullet point>\n\nAction Steps:\n1. <step>\n2. <step>\n3. <step>\n4. <optional>\n5. <optional>\n\nExpected Outcome:\n- <bullet point>\n- <bullet point>\n\nPriority:\n- <High / Medium / Low>\n\nRULES:\n- Output ONLY the sections above\n- No markdown formatting (no **, no headings styling)\n- No extra explanation before or after\n- Use plain text only"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "814b780c-693e-4337-9cfb-9ec0dacdbfbb",
"name": "Generate AI Recommendations",
"type": "@n8n/n8n-nodes-langchain.googleGemini",
"position": [
-11552,
2064
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "models/gemini-2.5-flash",
"cachedResultName": "models/gemini-2.5-flash"
},
"options": {
"temperature": 0.3,
"maxOutputTokens": 1024
},
"messages": {
"values": [
{
"content": "={{ $json.prompt }}"
}
]
},
"builtInTools": {}
},
"credentials": {
"googlePalmApi": {
"name": "<your credential>"
}
},
"executeOnce": true,
"typeVersion": 1.1
},
{
"id": "923beec3-b43f-4f5f-a474-34bccb1f605d",
"name": "Format AI Response",
"type": "n8n-nodes-base.set",
"position": [
-11200,
2064
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "ai-out-user_id",
"name": "user_id",
"type": "string",
"value": "={{ $('Check if Performance Needs Action').item.json.user_id }}"
},
{
"id": "ai-out-department",
"name": "department",
"type": "string",
"value": "={{ $('Check if Performance Needs Action').item.json.department }}"
},
{
"id": "ai-out-manager_email",
"name": "manager_email",
"type": "string",
"value": "={{ $('Check if Performance Needs Action').item.json.manager_email }}"
},
{
"id": "ai-out-performance",
"name": "performance",
"type": "string",
"value": "={{ $('Check if Performance Needs Action').item.json.performance }}"
},
{
"id": "ai-out-alert_tier",
"name": "alert_tier",
"type": "string",
"value": "={{ $('Check if Performance Needs Action').item.json.alert_tier }}"
},
{
"id": "ai-out-issues",
"name": "issues",
"type": "string",
"value": "={{ $('Check if Performance Needs Action').item.json.issues }}"
},
{
"id": "ai-out-severity_score",
"name": "severity_score",
"type": "number",
"value": "={{ $('Check if Performance Needs Action').item.json.severity_score }}"
},
{
"id": "ai-out-avg_duration",
"name": "avg_duration",
"type": "number",
"value": "={{ $('Check if Performance Needs Action').item.json.avg_duration }}"
},
{
"id": "ai-out-total_errors",
"name": "total_errors",
"type": "number",
"value": "={{ $('Check if Performance Needs Action').item.json.total_errors }}"
},
{
"id": "ai-out-total_records",
"name": "total_records",
"type": "number",
"value": "={{ $('Check if Performance Needs Action').item.json.total_records }}"
},
{
"id": "ai-out-compliance_rate",
"name": "compliance_rate",
"type": "number",
"value": "={{ $('Check if Performance Needs Action').item.json.compliance_rate }}"
},
{
"id": "ai-out-recommendation",
"name": "recommendation",
"type": "string",
"value": "={{ $json.text ?? $json.content ?? $json.candidates?.[0]?.content?.parts?.[0]?.text ?? 'No recommendation generated' }}"
},
{
"id": "ai-out-analyzed_at",
"name": "analyzed_at",
"type": "string",
"value": "={{ $('Check if Performance Needs Action').item.json.analyzed_at }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "99b1bca8-3e3d-4c55-9264-f539bb6df3bc",
"name": "Check if Escalation Needed",
"type": "n8n-nodes-base.if",
"position": [
-10976,
2064
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "cond-escalate",
"operator": {
"type": "string",
"operation": "notEquals"
},
"leftValue": "={{ $json.alert_tier }}",
"rightValue": "none"
}
]
}
},
"typeVersion": 2
},
{
"id": "db49b319-9a37-4a8d-ac91-b9c92af9a2f0",
"name": "Route Based on Severity Level",
"type": "n8n-nodes-base.if",
"position": [
-10784,
1840
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "cond-critical",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.alert_tier }}",
"rightValue": "critical"
}
]
}
},
"typeVersion": 2
},
{
"id": "f840b6be-1a4c-434c-bbee-c54eeb3cde75",
"name": "Send Warning Email to Manager",
"type": "n8n-nodes-base.gmail",
"position": [
-10560,
1664
],
"parameters": {
"message": "=Hello,\n\nThis is a routine performance notice from the Procurement Monitoring System.\n\nUser ID : {{ $json.user_id }}\nDepartment : {{ $json.department }}\nStatus : {{ $json.performance }}\nSeverity : {{ $json.severity_score }}/100 ({{ $json.alert_tier.toUpperCase() }})\n\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nKey Metrics\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nAvg Duration : {{ $json.avg_duration }} min\nTotal Errors : {{ $json.total_errors }}\nCompliance Rate : {{ ($json.compliance_rate * 100).toFixed(1) }}%\n\nIssues Identified:\n{{ $json.issues }}\n\nAI Recommendations:\n{{ $json.recommendation }}\n\nAnalyzed At: {{ $json.analyzed_at }}\n\nNo immediate action required, but please monitor this user.\n\nRegards,\nProcurement Monitoring System",
"options": {},
"subject": "=[INFO] Receiving Performance Notice \u2014 User {{ $json.user_id }} (Score: {{ $json.severity_score }}/100)",
"emailType": "text"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.2
},
{
"id": "84922747-f711-4503-a46f-d7620d38441b",
"name": "Send Critical Alert Email",
"type": "n8n-nodes-base.gmail",
"position": [
-10544,
2000
],
"parameters": {
"sendTo": "={{ $json.manager_email || 'your@email.com' }}",
"message": "=URGENT \u2014 IMMEDIATE ACTION REQUIRED\n\nA critical compliance failure has been detected in the warehouse receiving process.\n\nUser ID : {{ $json.user_id }}\nDepartment : {{ $json.department }}\n\nStatus : {{ $json.performance.toUpperCase() }}\nAlert Tier : CRITICAL\nSeverity : {{ $json.severity_score }}/100\n\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nKey Metrics\n\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\u2500\nAvg Duration : {{ $json.avg_duration }} min\nTotal Errors : {{ $json.total_errors }}\nCompliance Rate : {{ ($json.compliance_rate * 100).toFixed(1) }}%\n\nIssues Detected:\n{{ $json.issues }}\n\nAI Recommendations:\n{{ $json.recommendation }}\n\nFailure to act may result in operational and regulatory risk.\n\nTimestamp: {{ $json.analyzed_at }}\n\nRegards,\nProcurement Monitoring System",
"options": {},
"subject": "=CRITICAL: Non-Compliant User {{ $json.user_id }} \u2014 Immediate Action Required (Score: {{ $json.severity_score }}/100)",
"emailType": "text"
},
"credentials": {
"gmailOAuth2": {
"name": "<your credential>"
}
},
"typeVersion": 2.2
},
{
"id": "219dad6f-60e1-4ff9-83cc-494e588c6e52",
"name": "Prepare Final Output (Escalated)",
"type": "n8n-nodes-base.set",
"position": [
-10320,
1888
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "final-a-user_id",
"name": "user_id",
"type": "string",
"value": "={{ $('Route Based on Severity Level').item.json.user_id }}"
},
{
"id": "final-a-department",
"name": "department",
"type": "string",
"value": "={{ $('Route Based on Severity Level').item.json.department }}"
},
{
"id": "final-a-performance",
"name": "performance",
"type": "string",
"value": "={{ $('Route Based on Severity Level').item.json.performance }}"
},
{
"id": "final-a-alert_tier",
"name": "alert_tier",
"type": "string",
"value": "={{ $('Route Based on Severity Level').item.json.alert_tier }}"
},
{
"id": "final-a-issues",
"name": "issues",
"type": "string",
"value": "={{ $('Route Based on Severity Level').item.json.issues }}"
},
{
"id": "final-a-severity_score",
"name": "severity_score",
"type": "number",
"value": "={{ $('Route Based on Severity Level').item.json.severity_score }}"
},
{
"id": "final-a-avg_duration",
"name": "avg_duration",
"type": "number",
"value": "={{ $('Route Based on Severity Level').item.json.avg_duration }}"
},
{
"id": "final-a-total_errors",
"name": "total_errors",
"type": "number",
"value": "={{ $('Route Based on Severity Level').item.json.total_errors }}"
},
{
"id": "final-a-total_records",
"name": "total_records",
"type": "number",
"value": "={{ $('Route Based on Severity Level').item.json.total_records }}"
},
{
"id": "final-a-compliance_rate",
"name": "compliance_rate",
"type": "number",
"value": "={{ $('Route Based on Severity Level').item.json.compliance_rate }}"
},
{
"id": "final-a-recommendation",
"name": "recommendation",
"type": "string",
"value": "={{ $('Route Based on Severity Level').item.json.recommendation }}"
},
{
"id": "final-a-email_sent",
"name": "email_sent",
"type": "string",
"value": "=yes"
},
{
"id": "final-a-analyzed_at",
"name": "analyzed_at",
"type": "string",
"value": "={{ $('Route Based on Severity Level').item.json.analyzed_at }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "6281e348-2923-4784-b6dc-6ae167021501",
"name": "Prepare Final Output (No Action)",
"type": "n8n-nodes-base.set",
"position": [
-10304,
2208
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "final-b-user_id",
"name": "user_id",
"type": "string",
"value": "={{ $json.user_id }}"
},
{
"id": "final-b-department",
"name": "department",
"type": "string",
"value": "={{ $json.department }}"
},
{
"id": "final-b-performance",
"name": "performance",
"type": "string",
"value": "={{ $json.performance }}"
},
{
"id": "final-b-alert_tier",
"name": "alert_tier",
"type": "string",
"value": "={{ $json.alert_tier }}"
},
{
"id": "final-b-issues",
"name": "issues",
"type": "string",
"value": "={{ $json.issues }}"
},
{
"id": "final-b-severity_score",
"name": "severity_score",
"type": "number",
"value": "={{ $json.severity_score }}"
},
{
"id": "final-b-avg_duration",
"name": "avg_duration",
"type": "number",
"value": "={{ $json.avg_duration }}"
},
{
"id": "final-b-total_errors",
"name": "total_errors",
"type": "number",
"value": "={{ $json.total_errors }}"
},
{
"id": "final-b-total_records",
"name": "total_records",
"type": "number",
"value": "={{ $json.total_records }}"
},
{
"id": "final-b-compliance_rate",
"name": "compliance_rate",
"type": "number",
"value": "={{ $json.compliance_rate }}"
},
{
"id": "final-b-recommendation",
"name": "recommendation",
"type": "string",
"value": "={{ $json.recommendation }}"
},
{
"id": "final-b-email_sent",
"name": "email_sent",
"type": "string",
"value": "=no"
},
{
"id": "final-b-analyzed_at",
"name": "analyzed_at",
"type": "string",
"value": "={{ $json.analyzed_at }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "7f3fe503-e290-4e0b-ab8e-b29cac4a0fc7",
"name": "Prepare Final Output (All Good)",
"type": "n8n-nodes-base.set",
"position": [
-10288,
2512
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "final-c-user_id",
"name": "user_id",
"type": "string",
"value": "={{ $json.user_id }}"
},
{
"id": "final-c-department",
"name": "department",
"type": "string",
"value": "={{ $json.department }}"
},
{
"id": "final-c-performance",
"name": "performance",
"type": "string",
"value": "={{ $json.performance }}"
},
{
"id": "final-c-alert_tier",
"name": "alert_tier",
"type": "string",
"value": "={{ $json.alert_tier }}"
},
{
"id": "final-c-issues",
"name": "issues",
"type": "string",
"value": "={{ $json.issues }}"
},
{
"id": "final-c-severity_score",
"name": "severity_score",
"type": "number",
"value": "={{ $json.severity_score }}"
},
{
"id": "final-c-avg_duration",
"name": "avg_duration",
"type": "number",
"value": "={{ $json.avg_duration }}"
},
{
"id": "final-c-total_errors",
"name": "total_errors",
"type": "number",
"value": "={{ $json.total_errors }}"
},
{
"id": "final-c-total_records",
"name": "total_records",
"type": "number",
"value": "={{ $json.total_records }}"
},
{
"id": "final-c-compliance_rate",
"name": "compliance_rate",
"type": "number",
"value": "={{ $json.compliance_rate }}"
},
{
"id": "final-c-recommendation",
"name": "recommendation",
"type": "string",
"value": "=No issues detected \u2014 no AI analysis required"
},
{
"id": "final-c-email_sent",
"name": "email_sent",
"type": "string",
"value": "=no"
},
{
"id": "final-c-analyzed_at",
"name": "analyzed_at",
"type": "string",
"value": "={{ $json.analyzed_at }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "1ba2ba54-489c-42be-ab32-4577b88b7378",
"name": "Update Analytics Dashboard",
"type": "n8n-nodes-base.googleSheets",
"position": [
-10000,
2224
],
"parameters": {
"columns": {
"value": {
"issues": "={{ $json.issues }}",
"user_id": "={{ $json.user_id }}",
"timestamp": "={{ $json.analyzed_at }}",
"department": "={{ $json.department }}",
"performance": "={{ $json.performance }}",
"avg_duration": "={{ $json.avg_duration }}",
"recommendation": "={{ $json.recommendation }}",
"severity_score": "={{ $json.severity_score }}",
"compliance_rate": "={{ $json.compliance_rate }}"
},
"schema": [
{
"id": "user_id",
"type": "string",
"display": true,
"required": false,
"displayName": "user_id",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "department",
"type": "string",
"display": true,
"required": false,
"displayName": "department",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "performance",
"type": "string",
"display": true,
"required": false,
"displayName": "performance",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "issues",
"type": "string",
"display": true,
"required": false,
"displayName": "issues",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "avg_duration",
"type": "string",
"display": true,
"required": false,
"displayName": "avg_duration",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "compliance_rate",
"type": "string",
"display": true,
"required": false,
"displayName": "compliance_rate",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "severity_score",
"type": "string",
"display": true,
"required": false,
"displayName": "severity_score",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "recommendation",
"type": "string",
"display": true,
"required": false,
"displayName": "recommendation",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "timestamp",
"type": "string",
"display": true,
"required": false,
"displayName": "timestamp",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"user_id"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 1021039672,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-xi1-tWQgY6NXNyqXE0bFf9WxpwWRfhsWpqmPw3l48E/edit#gid=1021039672",
"cachedResultName": "AnalyticsDashboard"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1-xi1-tWQgY6NXNyqXE0bFf9WxpwWRfhsWpqmPw3l48E",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1-xi1-tWQgY6NXNyqXE0bFf9WxpwWRfhsWpqmPw3l48E/edit?usp=drivesdk",
"cachedResultName": "Receiving behaviour"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"name": "<your credential>"
}
},
"typeVersion": 4.4
},
{
"id": "0e582157-948a-4274-8a8b-93ce1e6ea2bd",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-13712,
1328
],
"parameters": {
"width": 848,
"height": 480,
"content": "## Receiving Behavior Analytics Workflow\n## How it works:\nThis workflow automatically monitors warehouse receiving operations by pulling raw log data from Google Sheets at a scheduled interval. It cleans and aggregates the data per user, then performs a rule-based performance analysis to detect inefficiencies such as high processing time, frequent errors, or low compliance. The system enriches each record with department and manager details, then uses AI to generate precise operational recommendations only for users needing attention. Based on severity levels, it intelligently decides whether to send warning or critical escalation emails. Finally, all processed insights are stored in a centralized dashboard for tracking and reporting.\n\n## Setup steps:\n1. Connect Google Sheets (ReceivingLogs, Departments, AnalyticsDashboard)\n2. Ensure user_id is consistent across all sheets\n3. Add manager_email in Departments sheet\n4. Configure Gemini API credentials\n5. Adjust cron schedule based on business needs\n6. Test with sample data (good + bad cases)\n7. Activate workflow after validation"
},
"typeVersion": 1
},
{
"id": "0a4de0d4-88a7-48ad-9b6b-64bcf5cafc99",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-13728,
2032
],
"parameters": {
"color": 7,
"width": 848,
"height": 480,
"content": "## Data Ingestion & Preparation\nThis section handles the full data ingestion pipeline.\n\nIt triggers the workflow on a defined schedule, fetches raw receiving logs from Google Sheets, and standardizes all fields (duration, errors, compliance). The data is then aggregated per user to create a structured dataset required for performance analysis.\n\nEnsures consistent, clean, and analysis-ready input."
},
"typeVersion": 1
},
{
"id": "1e684a68-1a9d-45d2-b053-aa54f37f8402",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-12848,
2064
],
"parameters": {
"color": 7,
"width": 320,
"height": 432,
"content": "## Core Performance Analysis\nTApplies business rules to evaluate user behavior.\nCalculates compliance rate, errors, processing time, and assigns performance status with severity scoring."
},
"typeVersion": 1
},
{
"id": "7cdf492c-281f-4ce3-8362-0471fa7a1c43",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-12512,
2064
],
"parameters": {
"color": 7,
"width": 448,
"height": 416,
"content": "## Data Enrichment & Context\nEnhances analyzed data with department and manager details using user_id lookup.\nRequired for routing alerts and reporting."
},
"typeVersion": 1
},
{
"id": "a86efb93-513b-4864-a82b-6208c16699f8",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-12048,
1872
],
"parameters": {
"color": 7,
"width": 1024,
"height": 624,
"content": "## AI Processing & Decision Logic\nControls intelligent analysis using AI.\n\nFilters out users with good performance to avoid unnecessary processing. For flagged users, it builds a structured prompt and sends it to the Gemini model to generate actionable recommendations.\n\nThe response is then cleaned and formatted into a consistent structure for downstream use."
},
"typeVersion": 1
},
{
"id": "db4c8697-17b0-4b94-a62f-f2a952c847e3",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
-10992,
1472
],
"parameters": {
"color": 7,
"width": 1168,
"height": 1216,
"content": "## Alerts, Routing & Reporting\nManages final decision-making and outputs.\n\nDetermines whether escalation is required based on alert tier and routes the flow accordingly. Sends warning or critical emails to managers when needed.\n\nFinally, it prepares structured outputs for all scenarios and updates the Analytics Dashboard in Google Sheets for tracking, auditing, and reporting purposes."
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"binaryMode": "separate",
"executionOrder": "v1"
},
"versionId": "24561795-93f9-444f-a57e-78db06fb90e0",
"connections": {
"Format AI Response": {
"main": [
[
{
"node": "Check if Escalation Needed",
"type": "main",
"index": 0
}
]
]
},
"Get Receiving Data": {
"main": [
[
{
"node": "Clean & Normalize Input Data",
"type": "main",
"index": 0
}
]
]
},
"Group Data by User": {
"main": [
[
{
"node": "Analyze User Performance",
"type": "main",
"index": 0
}
]
]
},
"Attach Department Info": {
"main": [
[
{
"node": "Check if Performance Needs Action",
"type": "main",
"index": 0
}
]
]
},
"Analyze User Performance": {
"main": [
[
{
"node": "Fetch Department Details",
"type": "main",
"index": 0
}
]
]
},
"Build AI Analysis Prompt": {
"main": [
[
{
"node": "Generate AI Recommendations",
"type": "main",
"index": 0
}
]
]
},
"Fetch Department Details": {
"main": [
[
{
"node": "Attach Department Info",
"type": "main",
"index": 0
}
]
]
},
"Schedule: Run Every Hour": {
"main": [
[
{
"node": "Get Receiving Data",
"type": "main",
"index": 0
}
]
]
},
"Send Critical Alert Email": {
"main": [
[
{
"node": "Prepare Final Output (Escalated)",
"type": "main",
"index": 0
}
]
]
},
"Check if Escalation Needed": {
"main": [
[
{
"node": "Route Based on Severity Level",
"type": "main",
"index": 0
}
],
[
{
"node": "Prepare Final Output (No Action)",
"type": "main",
"index": 0
}
]
]
},
"Generate AI Recommendations": {
"main": [
[
{
"node": "Format AI Response",
"type": "main",
"index": 0
}
]
]
},
"Clean & Normalize Input Data": {
"main": [
[
{
"node": "Group Data by User",
"type": "main",
"index": 0
}
]
]
},
"Route Based on Severity Level": {
"main": [
[
{
"node": "Send Warning Email to Manager",
"type": "main",
"index": 0
}
],
[
{
"node": "Send Critical Alert Email",
"type": "main",
"index": 0
}
]
]
},
"Send Warning Email to Manager": {
"main": [
[
{
"node": "Prepare Final Output (Escalated)",
"type": "main",
"index": 0
}
]
]
},
"Prepare Final Output (All Good)": {
"main": [
[
{
"node": "Update Analytics Dashboard",
"type": "main",
"index": 0
}
]
]
},
"Prepare Final Output (Escalated)": {
"main": [
[
{
"node": "Update Analytics Dashboard",
"type": "main",
"index": 0
}
]
]
},
"Prepare Final Output (No Action)": {
"main": [
[
{
"node": "Update Analytics Dashboard",
"type": "main",
"index": 0
}
]
]
},
"Check if Performance Needs Action": {
"main": [
[
{
"node": "Build AI Analysis Prompt",
"type": "main",
"index": 0
}
],
[
{
"node": "Prepare Final Output (All Good)",
"type": "main",
"index": 0
}
]
]
}
}
}
Credentials you'll need
Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.
gmailOAuth2googlePalmApigoogleSheetsOAuth2Api
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
N-0165 Receiving Behavior Analytics Workflow. Uses googleSheets, itemLists, googleGemini, gmail. Scheduled trigger; 25 nodes.
Source: https://github.com/weblineindia/n8n-Monitor-warehouse-receiving-performance-with-Google-Sheets-Gemini-and-Gmail/blob/main/workflow-template.json — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
This workflow is a complete outbound automation system that discovers local businesses, extracts contact emails, generates personalized cold emails using AI, and runs a multi-step follow-up sequence —
This workflow automatically fetches the latest business news, analyzes its impact on clients using AI and sends alerts for high-impact articles while logging all processed data in Google Sheets. It en
This workflow automatically monitors a commodity portfolio stored in Google Sheets, compares actual allocation against predefined targets, detects deviations and sends intelligent rebalance alerts via
> n8n, NSE RSS, Google Sheets, Gemini AI and Gmail
This workflow runs daily to compare procurement transactions in Google Sheets against an approved supplier list, flags unapproved (maverick) spend, uses Google Gemini to generate compliant alternative