This workflow corresponds to n8n.io template #16592 — we link there as the canonical source.
This workflow follows the Agent → Gmail 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": "dxb9DaPMO4YPEwNw",
"name": "AI Email Auto-Responder \u2014 Smart Categorize + Draft Replies (Gmail + Groq)",
"tags": [],
"nodes": [
{
"id": "ce28bb1d-6a2b-4db5-8881-aa678a5c9336",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-160,
48
],
"parameters": {
"width": 480,
"height": 896,
"content": "## AI Email Auto-Responder \u2014 Smart Categorize + Draft Replies (Gmail + Groq)\n\n### How it works\n\nThis workflow monitors incoming Gmail messages, checks that they contain usable content, and extracts key email fields. It sends the email details to a Groq-powered AI agent for categorization, priority assessment, and reply guidance, then parses and validates the AI output. High-priority messages can trigger an alert, all analyzed messages are logged to Google Sheets, and messages that need a response get a Gmail draft reply created automatically.\n\n### Setup steps\n\n- Connect Gmail credentials for the trigger, alert email, and draft creation nodes.\n- Connect Groq credentials for the AI Email Analyst model sub-node and choose the desired Groq chat model.\n- Connect Google Sheets credentials and configure the target spreadsheet, sheet/tab, and columns for the analysis log.\n- Configure the Gmail Trigger filters, such as inbox label, polling interval, and whether to include message body content.\n- Review the AI agent prompt and the Parse Analysis code so the expected JSON fields match the downstream IF conditions for priority and reply creation.\n\n### Customization\n\nCustomize the AI prompt to change categories, urgency rules, tone, and draft style. You can also adjust the High Priority and Needs Reply conditions, add more alert channels, or expand the Google Sheets log fields."
},
"typeVersion": 1
},
{
"id": "3702fe0f-ff0b-4c6f-9faa-a7675f2c8e3e",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
400,
240
],
"parameters": {
"color": 2,
"width": 432,
"height": 320,
"content": "## Receive valid emails\n\nStarts the workflow when a Gmail message arrives and performs the first content check before continuing."
},
"typeVersion": 1
},
{
"id": "9c7bfc9e-cbe8-4912-af92-09f97158c599",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
880,
144
],
"parameters": {
"color": 3,
"width": 656,
"height": 704,
"content": "## Extract and analyze email\n\nPrepares sender, subject, and body fields, then sends them to the AI agent using the nearby Groq LLM sub-node for email analysis."
},
"typeVersion": 1
},
{
"id": "1a850df6-4c70-4304-9680-e05c810efb1a",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1568,
240
],
"parameters": {
"color": 4,
"width": 432,
"height": 320,
"content": "## Parse AI results\n\nConverts the AI response into structured data and checks whether parsing succeeded before downstream routing."
},
"typeVersion": 1
},
{
"id": "6c3b4541-7f41-4c04-949e-efc43e8fef75",
"name": "Sticky Note4",
"type": "n8n-nodes-base.stickyNote",
"position": [
2032,
48
],
"parameters": {
"color": 6,
"width": 480,
"height": 656,
"content": "## Prioritize and record\n\nDetermines whether the email is high priority, sends a Gmail alert when needed, and records the analyzed message in Google Sheets."
},
"typeVersion": 1
},
{
"id": "a1cd99dd-d684-47b8-8d7c-4b05eef14b1c",
"name": "Sticky Note5",
"type": "n8n-nodes-base.stickyNote",
"position": [
2560,
80
],
"parameters": {
"width": 272,
"height": 624,
"content": "## Create reply drafts\n\nChecks whether the analyzed email requires a response and creates a Gmail draft reply when appropriate."
},
"typeVersion": 1
},
{
"id": "122f18ed-b3ab-4662-9413-df30706b65c9",
"name": "When Gmail Triggered",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
448,
400
],
"parameters": {
"simple": false,
"filters": {},
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "e9b6962f-a701-4b97-b9a0-1d8e639df86d",
"name": "Check Email Content",
"type": "n8n-nodes-base.if",
"position": [
688,
400
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": false,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "has-body",
"operator": {
"type": "string",
"operation": "notEquals"
},
"leftValue": "={{ $json.text || $json.snippet }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2
},
{
"id": "2bb4d391-b648-40f9-82e9-a0001d2faeda",
"name": "Set Email Fields",
"type": "n8n-nodes-base.set",
"position": [
928,
304
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "sender",
"name": "sender",
"type": "string",
"value": "={{ $json.from?.value?.[0]?.address || $json.from || 'Unknown' }}"
},
{
"id": "sender-name",
"name": "sender_name",
"type": "string",
"value": "={{ $json.from?.value?.[0]?.name || 'Unknown' }}"
},
{
"id": "subject",
"name": "subject",
"type": "string",
"value": "={{ $json.subject || '(No Subject)' }}"
},
{
"id": "body",
"name": "body",
"type": "string",
"value": "={{ ($json.text || $json.snippet || '').substring(0, 3000) }}"
},
{
"id": "email-id",
"name": "email_id",
"type": "string",
"value": "={{ $json.id }}"
},
{
"id": "received-date",
"name": "received_date",
"type": "string",
"value": "={{ $json.date }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "f5cfdce8-ba42-4a93-99fd-70407e1e5d5a",
"name": "Email Analysis Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
1232,
400
],
"parameters": {
"text": "=Analyze and categorize this email, then draft an appropriate response.\n\nFROM: {{ $json.sender_name }} <{{ $json.sender }}>\nSUBJECT: {{ $json.subject }}\nBODY:\n{{ $json.body }}\n\nRespond ONLY with valid JSON.",
"options": {
"maxIterations": 5,
"systemMessage": "You are an expert email assistant. Your job is to analyze incoming emails, categorize them by urgency and type, and draft professional responses.\n\nYou MUST respond ONLY with valid JSON. No markdown, no code blocks.\n\nRequired JSON structure:\n{\n \"category\": \"One of: URGENT | ACTION_REQUIRED | FOLLOW_UP | FYI | NEWSLETTER | SPAM | PROMOTION | PERSONAL\",\n \"priority\": \"One of: HIGH | MEDIUM | LOW\",\n \"summary\": \"2-3 sentence summary of what this email is about\",\n \"key_asks\": [\"What the sender wants \u2014 each ask as a separate item\"],\n \"sentiment\": \"One of: positive | neutral | negative | frustrated\",\n \"requires_response\": true,\n \"suggested_response_time\": \"Respond within: 1 hour / 4 hours / 24 hours / 48 hours / No response needed\",\n \"draft_response\": {\n \"subject\": \"Re: original subject or new subject if needed\",\n \"body\": \"Professional, concise draft reply. Match the tone of the original email. If the email is a newsletter or promotion, leave this empty.\",\n \"tone\": \"The tone used: professional / friendly / formal / apologetic / enthusiastic\"\n },\n \"action_items\": [\"Any to-do items this email creates for you\"],\n \"labels_suggested\": [\"Suggested Gmail labels: work, personal, finance, travel, project-X, etc.\"]\n}\n\nRules:\n- SPAM/NEWSLETTER/PROMOTION: set requires_response to false, draft_response body to empty string\n- URGENT: anything with deadlines within 24hrs, payment issues, or critical requests\n- ACTION_REQUIRED: needs you to do something but not time-critical\n- FOLLOW_UP: someone following up on a previous conversation\n- FYI: informational, no action needed\n- Draft responses should be concise (under 150 words)\n- Never be sycophantic in drafts \u2014 be professional and direct\n- If the email is in a non-English language, respond in the same language\n- Extract ALL action items, even implicit ones"
},
"promptType": "define"
},
"typeVersion": 1.7
},
{
"id": "36c7ce59-f64e-42bb-9211-9dbf6e54408a",
"name": "Groq Language Model",
"type": "@n8n/n8n-nodes-langchain.lmChatGroq",
"position": [
1232,
688
],
"parameters": {
"model": "llama-3.3-70b-versatile",
"options": {
"temperature": 0.3,
"maxTokensToSample": 2048
}
},
"typeVersion": 1
},
{
"id": "8f98e4df-d7a6-4ac0-8f99-0a98337699a2",
"name": "Parse AI Analysis",
"type": "n8n-nodes-base.code",
"position": [
1616,
400
],
"parameters": {
"jsCode": "const items = $input.all();\nconst output = items[0].json.output;\n\nlet parsed;\ntry {\n parsed = JSON.parse(output);\n} catch (e) {\n const jsonMatch = output.match(/```(?:json)?\\s*([\\s\\S]*?)```/);\n if (jsonMatch) {\n try { parsed = JSON.parse(jsonMatch[1].trim()); } catch (e2) { parsed = null; }\n }\n if (!parsed) {\n const objMatch = output.match(/\\{[\\s\\S]*\\}/);\n if (objMatch) {\n try { parsed = JSON.parse(objMatch[0]); } catch (e3) { parsed = null; }\n }\n }\n}\n\nif (!parsed) {\n return [{ json: { parse_status: 'failed', error: 'Could not parse AI analysis' } }];\n}\n\nreturn [{\n json: {\n parse_status: 'success',\n timestamp: new Date().toISOString(),\n sender: items[0].json.sender || '',\n sender_name: items[0].json.sender_name || '',\n original_subject: items[0].json.subject || '',\n email_id: items[0].json.email_id || '',\n category: parsed.category || 'FYI',\n priority: parsed.priority || 'LOW',\n summary: parsed.summary || '',\n key_asks: Array.isArray(parsed.key_asks) ? parsed.key_asks.join('; ') : '',\n sentiment: parsed.sentiment || 'neutral',\n requires_response: parsed.requires_response || false,\n suggested_response_time: parsed.suggested_response_time || '',\n draft_subject: parsed.draft_response?.subject || '',\n draft_body: parsed.draft_response?.body || '',\n draft_tone: parsed.draft_response?.tone || '',\n action_items: Array.isArray(parsed.action_items) ? parsed.action_items.join('; ') : '',\n labels: Array.isArray(parsed.labels_suggested) ? parsed.labels_suggested.join(', ') : ''\n }\n}];"
},
"typeVersion": 2
},
{
"id": "621e618f-3509-46fa-90a0-147bb26c698e",
"name": "Check Parse Success",
"type": "n8n-nodes-base.if",
"position": [
1856,
400
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "check-parse",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.parse_status }}",
"rightValue": "success"
}
]
}
},
"typeVersion": 2
},
{
"id": "64192486-70ba-4e95-afb8-e1ebac36c17b",
"name": "Evaluate Priority Level",
"type": "n8n-nodes-base.if",
"position": [
2080,
352
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "or",
"conditions": [
{
"id": "priority-check",
"operator": {
"type": "string",
"operation": "equals"
},
"leftValue": "={{ $json.priority }}",
"rightValue": "HIGH"
}
]
}
},
"typeVersion": 2
},
{
"id": "3ad022af-5aeb-4b68-9d7b-90e54b468361",
"name": "Append to Google Sheets",
"type": "n8n-nodes-base.googleSheets",
"position": [
2368,
512
],
"parameters": {
"columns": {
"mappingMode": "autoMapInputData",
"matchingColumns": []
},
"options": {},
"operation": "append",
"sheetName": {
"mode": "name",
"value": "Email Log"
},
"documentId": {
"mode": "id",
"value": "YOUR_GOOGLE_SHEET_ID"
}
},
"typeVersion": 4.5
},
{
"id": "ccbe83cb-1e27-4c57-9326-d33543514950",
"name": "Send High Priority Alert",
"type": "n8n-nodes-base.gmail",
"position": [
2368,
208
],
"parameters": {
"sendTo": "user@example.com",
"message": "=<b>Priority:</b> {{ $json.priority }}<br><b>Category:</b> {{ $json.category }}<br><b>From:</b> {{ $json.sender_name }} ({{ $json.sender }})<br><b>Subject:</b> {{ $json.original_subject }}<br><br><b>Summary:</b><br>{{ $json.summary }}<br><br><b>Key Asks:</b><br>{{ $json.key_asks }}<br><br><b>Suggested Response Time:</b> {{ $json.suggested_response_time }}<br><br><b>Draft Reply:</b><br>{{ $json.draft_body }}<br><br><b>Action Items:</b><br>{{ $json.action_items }}",
"options": {},
"subject": "=\ud83d\udea8 URGENT EMAIL from {{ $json.sender_name }}: {{ $json.original_subject }}"
},
"typeVersion": 2.1
},
{
"id": "cb153381-ac6f-48b9-98f0-4e1059cc329b",
"name": "Draft Gmail Reply",
"type": "n8n-nodes-base.gmail",
"position": [
2608,
304
],
"parameters": {
"operation": "createDraft"
},
"typeVersion": 2.1
},
{
"id": "218b0b50-9652-4333-b6c9-f31178550e99",
"name": "Assess Reply Necessity",
"type": "n8n-nodes-base.if",
"position": [
2608,
512
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 1,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "needs-reply",
"operator": {
"type": "boolean",
"operation": "equals"
},
"leftValue": "={{ $json.requires_response }}",
"rightValue": "={{ true }}"
}
]
}
},
"typeVersion": 2
},
{
"id": "dd70536c-3da8-41d3-88b6-c13ebf3ee501",
"name": "Sticky Note6",
"type": "n8n-nodes-base.stickyNote",
"position": [
2896,
0
],
"parameters": {
"color": 6,
"width": 436,
"height": 1060,
"content": "## \ud83d\udd11 Setup Guide\n\n### Step 1: Gmail OAuth2 (REQUIRED)\n1. n8n - Credentials - Add - search 'Gmail OAuth2'\n2. Follow the Google OAuth setup flow\n3. Grant permissions for reading and sending emails\n4. Select this credential in:\n - 'Gmail Trigger' node\n - 'Alert: High Priority' node\n - 'Create Draft Reply' node\n\n### Step 2: Groq API Key (REQUIRED)\n1. console.groq.com - API Keys - Create\n2. n8n: Credentials - Add - Groq - paste - Save\n3. Select in 'Groq LLM' node\n\n### Step 3: Configure Alert Email\n1. Open ' Alert: High Priority' node\n2. Change YOUR_EMAIL@gmail.com to your actual email\n3. This is where urgent email alerts get sent\n\n### Step 4: Google Sheets (OPTIONAL)\n1. Create sheet 'Email Auto-Responder'\n2. Headers: timestamp | sender | sender_name | original_subject | category | priority | summary | key_asks | sentiment | requires_response | suggested_response_time | draft_subject | draft_body | draft_tone | action_items | labels\n3. Setup Google Sheets OAuth2 credential\n4. Paste Sheet ID in 'Log to Sheets' node\n\n### Step 5: Activate\nToggle workflow ON - it checks for new emails every minute."
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"binaryMode": "separate",
"availableInMCP": false,
"executionOrder": "v1"
},
"versionId": "27fd1bec-8d70-4619-a1b5-15c0317fe2d2",
"nodeGroups": [],
"connections": {
"Set Email Fields": {
"main": [
[
{
"node": "Email Analysis Agent",
"type": "main",
"index": 0
}
]
]
},
"Parse AI Analysis": {
"main": [
[
{
"node": "Check Parse Success",
"type": "main",
"index": 0
}
]
]
},
"Check Email Content": {
"main": [
[
{
"node": "Set Email Fields",
"type": "main",
"index": 0
}
]
]
},
"Check Parse Success": {
"main": [
[
{
"node": "Evaluate Priority Level",
"type": "main",
"index": 0
}
]
]
},
"Groq Language Model": {
"ai_languageModel": [
[
{
"node": "Email Analysis Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Email Analysis Agent": {
"main": [
[
{
"node": "Parse AI Analysis",
"type": "main",
"index": 0
}
]
]
},
"When Gmail Triggered": {
"main": [
[
{
"node": "Check Email Content",
"type": "main",
"index": 0
}
]
]
},
"Assess Reply Necessity": {
"main": [
[
{
"node": "Draft Gmail Reply",
"type": "main",
"index": 0
}
]
]
},
"Append to Google Sheets": {
"main": [
[
{
"node": "Assess Reply Necessity",
"type": "main",
"index": 0
}
]
]
},
"Evaluate Priority Level": {
"main": [
[
{
"node": "Send High Priority Alert",
"type": "main",
"index": 0
}
],
[
{
"node": "Append to Google Sheets",
"type": "main",
"index": 0
}
]
]
},
"Send High Priority Alert": {
"main": [
[
{
"node": "Append to Google Sheets",
"type": "main",
"index": 0
}
]
]
}
}
}
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow monitors Gmail for new emails, uses Groq (via the LangChain Agent node) to categorize and summarize each message and draft a reply, sends an alert email for high-priority items, and logs the analysis and draft details to Google Sheets. Checks Gmail every minute for…
Source: https://n8n.io/workflows/16592/ — 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 monitors a Gmail inbox for procurement requests, uses Groq (Llama 3.1) to classify and route each ticket with SLA logic, escalates high-risk items to Slack, creates a ticket via HTTP, se
This workflow automatically organizes your Gmail inbox using AI. It reads every incoming email, classifies it into Work, Personal, Financial or Newsletter, applies the correct Gmail label, logs the em
This workflow monitors incoming Gmail messages for refund requests and uses AI to extract the order ID and reason. It then retrieves order details from Shopify to evaluate refund eligibility. Based on
n8n-ai-mail-sender. Uses telegram, agent, lmChatGroq, outputParserStructured. Event-driven trigger; 14 nodes.
hashtag. Uses gmailTrigger, googleSheets, gmail, agent. Event-driven trigger; 8 nodes.