This workflow corresponds to n8n.io template #15272 — 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": "jNPXooD6IDD9h7Dgr9vKV",
"name": "Email Automation",
"tags": [],
"nodes": [
{
"id": "86d282ec-7520-4974-b4e9-050f01f0604e",
"name": "Parse & Validate",
"type": "n8n-nodes-base.code",
"position": [
-512,
160
],
"parameters": {},
"typeVersion": 2
},
{
"id": "0551f959-cc10-4c2e-8e95-302c011a8a07",
"name": "IF Valid",
"type": "n8n-nodes-base.if",
"position": [
-288,
160
],
"parameters": {},
"typeVersion": 2.3
},
{
"id": "910782dc-995e-4a9b-ad2a-6b74b5f62d28",
"name": "OpenAI Chat Model",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-32,
432
],
"parameters": {},
"typeVersion": 1.3
},
{
"id": "a65d36a5-0dbb-40e4-851a-ca0f7f34a63a",
"name": "Simple Memory",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
128,
432
],
"parameters": {},
"typeVersion": 1.3
},
{
"id": "dfdc2030-5a88-449b-97cd-c9345219dc34",
"name": "AI Agent - Classify",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
80,
160
],
"parameters": {},
"typeVersion": 3.1
},
{
"id": "d21f44d5-31c9-4ec7-acb8-4746931c3ab3",
"name": "Merge",
"type": "n8n-nodes-base.merge",
"position": [
368,
384
],
"parameters": {},
"typeVersion": 3.2
},
{
"id": "4e375742-67d9-496a-a91c-623c227edc98",
"name": "Parse Classification",
"type": "n8n-nodes-base.code",
"position": [
560,
160
],
"parameters": {},
"typeVersion": 2
},
{
"id": "92f77015-5e9b-471d-863c-7c00308edb51",
"name": "Generate Email Embedding",
"type": "n8n-nodes-base.httpRequest",
"position": [
800,
240
],
"parameters": {},
"typeVersion": 4.4
},
{
"id": "a7cc3cf2-7bda-4518-8211-461b061a150f",
"name": "Extract Embedding",
"type": "n8n-nodes-base.code",
"position": [
1008,
240
],
"parameters": {},
"typeVersion": 2
},
{
"id": "2ebfa9be-b749-416e-b956-97c178cfee10",
"name": "DB - Fetch KB Data",
"type": "n8n-nodes-base.postgres",
"position": [
1232,
0
],
"parameters": {},
"typeVersion": 2.6
},
{
"id": "49494877-c815-40d5-81bf-361ad9f1f7c7",
"name": "DB - Fetch Similar Corrections",
"type": "n8n-nodes-base.postgres",
"position": [
1232,
160
],
"parameters": {},
"typeVersion": 2.6
},
{
"id": "0ab655f7-a176-4164-b68d-f5758d0fbc90",
"name": "DB - Fetch Similar Scenarios",
"type": "n8n-nodes-base.postgres",
"position": [
1232,
320
],
"parameters": {},
"typeVersion": 2.6
},
{
"id": "7ed7e264-4264-4e64-84ab-a1725efb0275",
"name": "DB - Fetch Customer Transactions",
"type": "n8n-nodes-base.postgres",
"position": [
1232,
480
],
"parameters": {},
"typeVersion": 2.6
},
{
"id": "c9c1f902-c94d-4e5b-a443-e21bb07b18ef",
"name": "Resolve Scenario",
"type": "n8n-nodes-base.code",
"position": [
1504,
240
],
"parameters": {},
"typeVersion": 2
},
{
"id": "7c6fffe9-af84-4a28-8987-f4e2aac49d9e",
"name": "Assemble Draft Prompt",
"type": "n8n-nodes-base.code",
"position": [
1680,
240
],
"parameters": {},
"typeVersion": 2
},
{
"id": "90fd6d98-ef78-4a75-a99f-0e641738fc9a",
"name": "Generate Draft",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
1904,
240
],
"parameters": {},
"typeVersion": 2.1
},
{
"id": "54ac1e0f-b552-4114-8689-aa324e91064c",
"name": "Extract Draft Text",
"type": "n8n-nodes-base.code",
"position": [
2192,
368
],
"parameters": {},
"typeVersion": 2
},
{
"id": "fa0efe23-6a99-4737-9db2-495eadc88057",
"name": "Create Gmail Draft",
"type": "n8n-nodes-base.gmail",
"position": [
2352,
240
],
"parameters": {},
"typeVersion": 2.2
},
{
"id": "9c60c8f1-f410-4c1a-a0ae-56adb954c915",
"name": "DB - Save AI Draft",
"type": "n8n-nodes-base.postgres",
"position": [
2576,
240
],
"parameters": {},
"typeVersion": 2.6
},
{
"id": "fc5ed085-40d0-48da-a848-7a92881b37e6",
"name": "DB - Log Success",
"type": "n8n-nodes-base.postgres",
"position": [
2800,
240
],
"parameters": {},
"typeVersion": 2.6
},
{
"id": "7c161257-d763-4d1b-8b69-b4808028f697",
"name": "DB - Log Skipped",
"type": "n8n-nodes-base.postgres",
"position": [
-288,
384
],
"parameters": {},
"typeVersion": 2.6
},
{
"id": "c7c7ff30-982a-401b-a661-8ad5d6eecec5",
"name": "Gmail Trigger",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-720,
160
],
"parameters": {},
"typeVersion": 1.3
},
{
"id": "06a2dbc4-e4d0-4e0a-bf1d-5438d5266b9e",
"name": "Sticky Note",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1440,
-160
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "dc9055bc-d6f8-4c95-b11e-21fd1ed5792c",
"name": "Sticky Note1",
"type": "n8n-nodes-base.stickyNote",
"position": [
-768,
-96
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "7f12be96-54f9-4361-81ac-4dd997797cc6",
"name": "Sticky Note2",
"type": "n8n-nodes-base.stickyNote",
"position": [
736,
-224
],
"parameters": {
"content": ""
},
"typeVersion": 1
},
{
"id": "51fad99f-3d04-4a6c-9a43-b597279d0419",
"name": "Sticky Note3",
"type": "n8n-nodes-base.stickyNote",
"position": [
1440,
-96
],
"parameters": {
"content": ""
},
"typeVersion": 1
}
],
"active": false,
"settings": {
"binaryMode": "separate",
"availableInMCP": false,
"executionOrder": "v1"
},
"versionId": "b1c83789-3ea3-4a5d-b05f-7a805ac8545e",
"connections": {
"Merge": {
"main": [
[
{
"node": "Parse Classification",
"type": "main",
"index": 0
}
]
]
},
"IF Valid": {
"main": [
[
{
"node": "AI Agent - Classify",
"type": "main",
"index": 0
},
{
"node": "Merge",
"type": "main",
"index": 1
}
],
[
{
"node": "DB - Log Skipped",
"type": "main",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "Parse & Validate",
"type": "main",
"index": 0
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent - Classify",
"type": "ai_memory",
"index": 0
}
]
]
},
"Generate Draft": {
"main": [
[
{
"node": "Extract Draft Text",
"type": "main",
"index": 0
}
]
]
},
"Parse & Validate": {
"main": [
[
{
"node": "IF Valid",
"type": "main",
"index": 0
}
]
]
},
"Resolve Scenario": {
"main": [
[
{
"node": "Assemble Draft Prompt",
"type": "main",
"index": 0
}
]
]
},
"Extract Embedding": {
"main": [
[
{
"node": "DB - Fetch KB Data",
"type": "main",
"index": 0
},
{
"node": "DB - Fetch Similar Corrections",
"type": "main",
"index": 0
},
{
"node": "DB - Fetch Similar Scenarios",
"type": "main",
"index": 0
},
{
"node": "DB - Fetch Customer Transactions",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent - Classify",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Create Gmail Draft": {
"main": [
[
{
"node": "DB - Save AI Draft",
"type": "main",
"index": 0
}
]
]
},
"DB - Fetch KB Data": {
"main": [
[
{
"node": "Resolve Scenario",
"type": "main",
"index": 0
}
]
]
},
"DB - Save AI Draft": {
"main": [
[
{
"node": "DB - Log Success",
"type": "main",
"index": 0
}
]
]
},
"Extract Draft Text": {
"main": [
[
{
"node": "Create Gmail Draft",
"type": "main",
"index": 0
}
]
]
},
"AI Agent - Classify": {
"main": [
[
{
"node": "Merge",
"type": "main",
"index": 0
}
]
]
},
"Parse Classification": {
"main": [
[
{
"node": "Generate Email Embedding",
"type": "main",
"index": 0
}
]
]
},
"Assemble Draft Prompt": {
"main": [
[
{
"node": "Generate Draft",
"type": "main",
"index": 0
}
]
]
},
"Generate Email Embedding": {
"main": [
[
{
"node": "Extract Embedding",
"type": "main",
"index": 0
}
]
]
},
"DB - Fetch Similar Scenarios": {
"main": [
[
{
"node": "Resolve Scenario",
"type": "main",
"index": 0
}
]
]
},
"DB - Fetch Similar Corrections": {
"main": [
[
{
"node": "Resolve Scenario",
"type": "main",
"index": 0
}
]
]
},
"DB - Fetch Customer Transactions": {
"main": [
[
{
"node": "Resolve Scenario",
"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 is the core of a three-part email automation system. It monitors your Gmail inbox in real time, classifies every inbound customer email with AI, retrieves contextually relevant data from your Knowledge Base and transaction records, and generates a personalised,…
Source: https://n8n.io/workflows/15272/ — 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.
Automate your personal productivity with this intelligent n8n workflow that integrates Telegram, Google Sheets, and OpenAI (GPT-4o). This system uses multiple AI agents to manage work hours, tasks, fi
Streamline your HR recruitment process with this intelligent automation that reads candidate emails and resumes, analyzes them using GPT-4, and automatically shortlists or rejects applicants based on
This workflow is perfect for: Small to medium businesses looking to automate customer support E-commerce stores handling order inquiries and customer questions SaaS companies providing technical suppo
Multi-Channel Email Intelligence Agent. Uses lmChatOpenAi, outputParserStructured, gmailTrigger, agent. Event-driven trigger; 18 nodes.
This workflow is perfect for content creators, newsletter publishers, digital marketers, and virtual assistants who need a quick way to generate professional newsletters from trending news without man