Sistema de clasificación de correos y respuestas automáticas impulsado por IA basado en Gmail y GPT
Este es unTicket Management, Multimodal AIflujo de automatización del dominio deautomatización que contiene 24 nodos.Utiliza principalmente nodos como If, Set, Gmail, Merge, GmailTrigger. Automatización de clasificación de correos con respuestas automáticas de Gmail usando GPT-4.1-mini
- •Cuenta de Google y credenciales de API de Gmail
- •Credenciales de API de Google Sheets
- •Clave de API de OpenAI
Nodos utilizados (24)
Categoría
{
"id": "Nj73lhp3xoOM5vJR",
"meta": {
"instanceId": "465f4422bb16aa276130544b590fd34d3a02b10a5aa0e96f6c6adc306e3e8296",
"templateCredsSetupCompleted": true
},
"name": "AI-Powered Email Classification and Auto-Reply System with Gmail and GPT",
"tags": [],
"nodes": [
{
"id": "1c25bce1-dce3-408f-8c17-f4e2cde60f26",
"name": "Disparador de Gmail",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
0,
80
],
"parameters": {
"simple": false,
"filters": {
"readStatus": "unread"
},
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "SWlhbg6fDyvBn2oz",
"name": "giobeggiato@gmail.com"
}
},
"typeVersion": 1.2
},
{
"id": "e39fd2c4-76b2-4cb9-816e-b0e146b81be3",
"name": "If",
"type": "n8n-nodes-base.if",
"position": [
600,
100
],
"parameters": {
"options": {},
"conditions": {
"options": {
"version": 2,
"leftValue": "",
"caseSensitive": true,
"typeValidation": "strict"
},
"combinator": "and",
"conditions": [
{
"id": "2d7cba78-1e46-4563-9683-2151f4bc3cc6",
"operator": {
"type": "string",
"operation": "notEmpty",
"singleValue": true
},
"leftValue": "={{ $json.output.sender_name }}",
"rightValue": ""
}
]
}
},
"typeVersion": 2.2
},
{
"id": "1f9d175e-dd19-4a5e-b4cf-68c67769514e",
"name": "Modelo de chat OpenAI",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
220,
240
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "x61T2jyBPZhaqKVW",
"name": "n8n free OpenAI API credits"
}
},
"typeVersion": 1.2
},
{
"id": "7547e456-d72e-4bd7-a483-e600026132a1",
"name": "Name Found",
"type": "n8n-nodes-base.set",
"position": [
820,
0
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "0064bc2e-17b5-4d55-945e-ad61c4a7e796",
"name": "intro_line",
"type": "string",
"value": "=Dear {{ $json.output.sender_name }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "f5335b2d-2732-47fc-a916-17bd9d40e0da",
"name": "Name Not Found",
"type": "n8n-nodes-base.set",
"position": [
820,
200
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "0064bc2e-17b5-4d55-945e-ad61c4a7e796",
"name": "intro_line",
"type": "string",
"value": "=Hey,"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "53f97b56-7bc6-4f25-b3c7-761fb38d7174",
"name": "Modelo de chat OpenAI1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
200,
960
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "jJNoHsAQMgxbuAcB",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "2cc7a078-016e-4205-897d-a6c20f23dd52",
"name": "Label - Agency Lead",
"type": "n8n-nodes-base.gmail",
"position": [
560,
420
],
"webhookId": "b9cae76f-27ae-41e6-a806-61de5db8b020",
"parameters": {
"labelIds": [
"Label_2779457653887615300"
],
"messageId": "={{ $json.message_id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "SWlhbg6fDyvBn2oz",
"name": "giobeggiato@gmail.com"
}
},
"typeVersion": 2.1
},
{
"id": "af773077-758f-4f64-94b2-658784b8689d",
"name": "Label - Course Request",
"type": "n8n-nodes-base.gmail",
"position": [
560,
620
],
"webhookId": "b9cae76f-27ae-41e6-a806-61de5db8b020",
"parameters": {
"labelIds": [
"Label_6090976944524934821"
],
"messageId": "={{ $json.message_id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "SWlhbg6fDyvBn2oz",
"name": "giobeggiato@gmail.com"
}
},
"typeVersion": 2.1
},
{
"id": "a93709f4-15a0-4333-b9e1-aff10ff6c693",
"name": "Label - Paid Collaborations",
"type": "n8n-nodes-base.gmail",
"position": [
560,
820
],
"webhookId": "b9cae76f-27ae-41e6-a806-61de5db8b020",
"parameters": {
"labelIds": [
"Label_2508736995105587525"
],
"messageId": "={{ $json.message_id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "SWlhbg6fDyvBn2oz",
"name": "giobeggiato@gmail.com"
}
},
"typeVersion": 2.1
},
{
"id": "7994e586-a28c-47d6-902f-9389516d13f7",
"name": "Label - Miscellaneous",
"type": "n8n-nodes-base.gmail",
"position": [
560,
1020
],
"webhookId": "b9cae76f-27ae-41e6-a806-61de5db8b020",
"parameters": {
"labelIds": [
"Label_5123095855127638673"
],
"messageId": "={{ $json.message_id }}",
"operation": "addLabels"
},
"credentials": {
"gmailOAuth2": {
"id": "SWlhbg6fDyvBn2oz",
"name": "giobeggiato@gmail.com"
}
},
"typeVersion": 2.1
},
{
"id": "f7c8cc18-f017-4a5d-92e9-c80d16a1269a",
"name": "Message a model",
"type": "@n8n/n8n-nodes-langchain.openAi",
"position": [
780,
420
],
"parameters": {
"modelId": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini",
"cachedResultName": "GPT-4.1-MINI"
},
"options": {},
"messages": {
"values": [
{
"role": "system",
"content": "You are an intelligent and useful personal assistant that replies to my emails"
},
{
"content": "=Here's the email to reply to:\n\nIntro line for the sender:{{ $('Single Intro Line').item.json.intro_line }}\nEmail Body: {{ $('Gmail Trigger').item.json.text }}\nEmail Subject:{{ $('Gmail Trigger').item.json.subject }}"
},
{
"content": "=Please format the data in this format:\n\n{\n\n\"subject\": \"The subject line fo the email you drafted\"\n\"body\": \"The body of the email you drafted\"\n\n}"
}
]
},
"jsonOutput": true
},
"credentials": {
"openAiApi": {
"id": "jJNoHsAQMgxbuAcB",
"name": "OpenAi account"
}
},
"typeVersion": 1.8
},
{
"id": "5c4ae3ba-5ab9-46c3-aa20-b43d8c62a1a3",
"name": "Create a draft",
"type": "n8n-nodes-base.gmail",
"position": [
1140,
420
],
"webhookId": "0c43d685-5746-44ff-ae3a-6b5b356801f1",
"parameters": {
"message": "={{ $json.message.content.body }}",
"options": {
"threadId": "={{ $('Label - Agency Lead').item.json.threadId }}"
},
"subject": "={{ $json.message.content.subject }}",
"resource": "draft"
},
"credentials": {
"gmailOAuth2": {
"id": "SWlhbg6fDyvBn2oz",
"name": "giobeggiato@gmail.com"
}
},
"typeVersion": 2.1
},
{
"id": "51f46e0e-4280-414d-9f1f-545027c6965a",
"name": "Nota adhesiva",
"type": "n8n-nodes-base.stickyNote",
"position": [
180,
0
],
"parameters": {
"width": 300,
"height": 360,
"content": "## Name Extractor"
},
"typeVersion": 1
},
{
"id": "ee1210c5-62c0-41f5-be0a-0ca4b90879b6",
"name": "Nota adhesiva1",
"type": "n8n-nodes-base.stickyNote",
"position": [
560,
-40
],
"parameters": {
"color": 5,
"width": 600,
"height": 400,
"content": "## Personalised Intro"
},
"typeVersion": 1
},
{
"id": "3097cff4-606a-46ab-9982-a79ff30ed097",
"name": "Nota adhesiva2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-80,
540
],
"parameters": {
"color": 4,
"width": 560,
"height": 600,
"content": "## Sentiment Analysis"
},
"typeVersion": 1
},
{
"id": "956a90c8-0752-41a3-8496-bf3c5e9eb94f",
"name": "Nota adhesiva3",
"type": "n8n-nodes-base.stickyNote",
"position": [
520,
380
],
"parameters": {
"color": 6,
"width": 860,
"height": 800,
"content": "## Personalised Intro"
},
"typeVersion": 1
},
{
"id": "24ce2fe3-e674-4d47-b7b3-6dc8eb94a328",
"name": "Nota adhesiva4",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1120,
-100
],
"parameters": {
"color": 3,
"width": 960,
"height": 1240,
"content": "# Overview\n\nThis template triages incoming Gmail in real time using GPT. It extracts the sender’s name, classifies the message into four categories (Agency Lead, Course Request, Paid Collaborations, Miscellaneous), applies the appropriate Gmail label, and either sends an immediate courtesy reply (for Course Requests and Paid Collaborations) or creates a structured Gmail draft for you to review (for Agency Leads). It also upserts Paid Collaboration contacts into Google Sheets for follow-up.\n\n# Who it’s for\n\nSolo operators and small teams that get mixed inbound and want consistent, fast triage without living in the inbox. These classification specifically is good for Agencies and Coaches\n\n## How it works / What it does\n\n- Trigger: New unread Gmail message/s\n- Name extraction (AI): Pulls the sender name from the email body or signature to personalise replies\n- Topic classification (AI): Routes to Agency Lead, Course Request, Paid Collaborations, or Miscellaneous\n\n## Actions:\n1. Agency Lead → add label and create GPT-draft\n2. Course Request → add label and auto-reply\n3. Paid Collaborations → add label, auto-reply, and upsert to Google Sheets\n4. Miscellaneous → add label only\n\n## Requirements\n- Gmail account connected in n8n\n- OpenAI credentials\n- Google Sheet for Paid Collaborations with columns: Name, email, subject\n\n## Setup\n1. Connect Gmail, OpenAI, and (optionally) Google Sheets credentials in n8n\n2. Create four Gmail labels - in my case I created:\n - Agency lead: This includes people/companies interested in inquiries regarding AI solutions, may it be asking info on what they can do, or me building a solution for them.\n - Course Request: This includes inquiries from people regarding which courses they should choose in order to understand/study AI or AI Agents \n - Paid Collaborations: Inquiries regarding sponsorship of books or tools on my channels. There are also situations in which they don't specifically say that they will pay, but they ask me to share their material with my audience\n - Miscellaneous: the remaining part --> mandatory category to make this work properly.\n3. Create a Google Sheet with 3 columns: email, name, email \n\n## How to customize\n- Edit the four categories and their descriptions in the Classify Email Topic (AI) node\n- Tweak auto-reply copy in the auto-reply nodes; adjust the GPT draft prompt if needed\n- Change the model or temperature in the LLM nodes; extend the Google Sheets schema over time"
},
"typeVersion": 1
},
{
"id": "88e31730-9014-4076-bc2a-71d1dab5ef78",
"name": "Name Extractor",
"type": "@n8n/n8n-nodes-langchain.informationExtractor",
"position": [
220,
80
],
"parameters": {
"text": "={{ $json.text }}",
"options": {
"systemPromptTemplate": "=You are an expert extraction algorithm.\nOnly extract relevant information from the text.\nIf you do not know the value of an attribute asked to extract, you may omit the attribute's value."
},
"attributes": {
"attributes": [
{
"name": "sender_name",
"required": true,
"description": "=This is the sender name, which corresponds to the signature of the sender at the end of the body of the email. If the name is not available, return an empty string."
}
]
}
},
"typeVersion": 1.2
},
{
"id": "e97c25b3-84f0-4602-86cc-45652f9a6bf8",
"name": "Single Intro Line",
"type": "n8n-nodes-base.merge",
"position": [
1040,
100
],
"parameters": {
"mode": "combine",
"options": {},
"joinMode": "keepNonMatches",
"fieldsToMatchString": "=intro_line"
},
"typeVersion": 3.2
},
{
"id": "0568b7a5-017a-4db1-94f1-bf80057db779",
"name": "Reducing content before LLM",
"type": "n8n-nodes-base.set",
"position": [
-40,
720
],
"parameters": {
"options": {},
"assignments": {
"assignments": [
{
"id": "a5357d59-3a7a-4197-b005-a8fa4acea9c0",
"name": "intro_line",
"type": "string",
"value": "={{ $json.intro_line }}"
},
{
"id": "17c5b46b-77e6-43ab-a314-6a36a21651f8",
"name": "email_body",
"type": "string",
"value": "={{ $('Gmail Trigger').item.json.text }}"
},
{
"id": "e534b113-0a05-4312-b577-b1918f03b361",
"name": "message_id",
"type": "string",
"value": "={{ $('Gmail Trigger').item.json.id }}"
},
{
"id": "21ab6542-a5b6-4ca0-9605-4f1c9b27e70d",
"name": "thread_id",
"type": "string",
"value": "={{ $('Gmail Trigger').item.json.threadId }}"
}
]
}
},
"typeVersion": 3.4
},
{
"id": "9434fc19-bbb8-4778-8e9b-49b7777cac77",
"name": "AI-Classification & Análisis de sentimiento",
"type": "@n8n/n8n-nodes-langchain.textClassifier",
"position": [
200,
720
],
"parameters": {
"options": {},
"inputText": "={{ $json.email_body }}",
"categories": {
"categories": [
{
"category": "Agency Lead",
"description": "This includes people/companies interested in inquiries regarding AI solutions, may it be asking info on what they can do, or me building a solution for them."
},
{
"category": "Course Request",
"description": "This includes inquiries from people regarding which courses they should choose in order to understand/study AI or AI Agents "
},
{
"category": "Paid Collaborations",
"description": "Inquiries regarding sponsorship of books or tools on my channels. There are also situations in which they don't specifically say that they will pay, but they ask me to share their material with my audience"
},
{
"category": "Miscellaneous",
"description": "All the remaining messages"
}
]
}
},
"typeVersion": 1.1
},
{
"id": "680a89f0-148f-4b91-a63f-a428744ba177",
"name": "Standard Answer",
"type": "n8n-nodes-base.gmail",
"position": [
840,
620
],
"webhookId": "fd82eb8a-6d1c-4509-ab21-1674cb6328d2",
"parameters": {
"message": "={{ $('AI-Classification & Sentiment Analysis').item.json.intro_line }},\n\nThanks for reaching out.\n\nThis email goes out as soon as I receive a request of a course recommendation.\n\nThis is my phone number: XXXX\n\nPlease reach out to me there!\n\nThanks,\nGiovanni",
"options": {},
"emailType": "text",
"messageId": "={{ $json.id }}",
"operation": "reply"
},
"credentials": {
"gmailOAuth2": {
"id": "SWlhbg6fDyvBn2oz",
"name": "giobeggiato@gmail.com"
}
},
"typeVersion": 2.1
},
{
"id": "bcd48315-4957-4cd1-81e2-97ea4ea1431e",
"name": "Standard Answer 2",
"type": "n8n-nodes-base.gmail",
"position": [
840,
820
],
"webhookId": "fd82eb8a-6d1c-4509-ab21-1674cb6328d2",
"parameters": {
"message": "={{ $('AI-Classification & Sentiment Analysis').item.json.intro_line }},\n\nThanks for reaching out.\n\nThis email goes out as soon as I receive a request of a paid collab.\n\nThis is my phone number: XXXX\n\nPlease reach out to me there!\n\nThanks,\nGiovanni",
"options": {},
"emailType": "text",
"messageId": "={{ $json.id }}",
"operation": "reply"
},
"credentials": {
"gmailOAuth2": {
"id": "SWlhbg6fDyvBn2oz",
"name": "giobeggiato@gmail.com"
}
},
"typeVersion": 2.1
},
{
"id": "39a258ef-64a3-45df-b048-0de048a4825c",
"name": "Update DB",
"type": "n8n-nodes-base.googleSheets",
"position": [
1140,
820
],
"parameters": {
"columns": {
"value": {
"Name": "={{ $('Single Intro Line').item.json.intro_line.replace('Dear ', '') }}",
"email": "={{ $('Gmail Trigger').item.json.from.value[0].address }}",
"subject": "={{ $('Gmail Trigger').item.json.subject }}"
},
"schema": [
{
"id": "Name",
"type": "string",
"display": true,
"required": false,
"displayName": "Name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "email",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "subject",
"type": "string",
"display": true,
"required": false,
"displayName": "subject",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"email"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mW0vLLwJXdWBEe5_JxT9HfK1U8ECygmu-zNnfOf93Xo/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1mW0vLLwJXdWBEe5_JxT9HfK1U8ECygmu-zNnfOf93Xo",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1mW0vLLwJXdWBEe5_JxT9HfK1U8ECygmu-zNnfOf93Xo/edit?usp=drivesdk",
"cachedResultName": "Paid Collaborations"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "Urd6OjD5xri8sIO1",
"name": "Working_Sheets_bli"
}
},
"typeVersion": 4.6
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "030afcdb-4da5-4947-aafe-042dae86a937",
"connections": {
"e39fd2c4-76b2-4cb9-816e-b0e146b81be3": {
"main": [
[
{
"node": "7547e456-d72e-4bd7-a483-e600026132a1",
"type": "main",
"index": 0
}
],
[
{
"node": "f5335b2d-2732-47fc-a916-17bd9d40e0da",
"type": "main",
"index": 0
}
]
]
},
"7547e456-d72e-4bd7-a483-e600026132a1": {
"main": [
[
{
"node": "e97c25b3-84f0-4602-86cc-45652f9a6bf8",
"type": "main",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "88e31730-9014-4076-bc2a-71d1dab5ef78",
"type": "main",
"index": 0
}
]
]
},
"88e31730-9014-4076-bc2a-71d1dab5ef78": {
"main": [
[
{
"node": "e39fd2c4-76b2-4cb9-816e-b0e146b81be3",
"type": "main",
"index": 0
}
]
]
},
"f5335b2d-2732-47fc-a916-17bd9d40e0da": {
"main": [
[
{
"node": "e97c25b3-84f0-4602-86cc-45652f9a6bf8",
"type": "main",
"index": 1
}
]
]
},
"f7c8cc18-f017-4a5d-92e9-c80d16a1269a": {
"main": [
[
{
"node": "5c4ae3ba-5ab9-46c3-aa20-b43d8c62a1a3",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "88e31730-9014-4076-bc2a-71d1dab5ef78",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"e97c25b3-84f0-4602-86cc-45652f9a6bf8": {
"main": [
[
{
"node": "0568b7a5-017a-4db1-94f1-bf80057db779",
"type": "main",
"index": 0
}
]
]
},
"bcd48315-4957-4cd1-81e2-97ea4ea1431e": {
"main": [
[
{
"node": "39a258ef-64a3-45df-b048-0de048a4825c",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model1": {
"ai_languageModel": [
[
{
"node": "AI-Classification & Sentiment Analysis",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"2cc7a078-016e-4205-897d-a6c20f23dd52": {
"main": [
[
{
"node": "f7c8cc18-f017-4a5d-92e9-c80d16a1269a",
"type": "main",
"index": 0
}
]
]
},
"af773077-758f-4f64-94b2-658784b8689d": {
"main": [
[
{
"node": "680a89f0-148f-4b91-a63f-a428744ba177",
"type": "main",
"index": 0
}
]
]
},
"a93709f4-15a0-4333-b9e1-aff10ff6c693": {
"main": [
[
{
"node": "bcd48315-4957-4cd1-81e2-97ea4ea1431e",
"type": "main",
"index": 0
}
]
]
},
"0568b7a5-017a-4db1-94f1-bf80057db779": {
"main": [
[
{
"node": "AI-Classification & Sentiment Analysis",
"type": "main",
"index": 0
}
]
]
},
"AI-Classification & Sentiment Analysis": {
"main": [
[
{
"node": "2cc7a078-016e-4205-897d-a6c20f23dd52",
"type": "main",
"index": 0
}
],
[
{
"node": "af773077-758f-4f64-94b2-658784b8689d",
"type": "main",
"index": 0
}
],
[
{
"node": "a93709f4-15a0-4333-b9e1-aff10ff6c693",
"type": "main",
"index": 0
}
],
[
{
"node": "7994e586-a28c-47d6-902f-9389516d13f7",
"type": "main",
"index": 0
}
]
]
}
}
}¿Cómo usar este flujo de trabajo?
Copie el código de configuración JSON de arriba, cree un nuevo flujo de trabajo en su instancia de n8n y seleccione "Importar desde JSON", pegue la configuración y luego modifique la configuración de credenciales según sea necesario.
¿En qué escenarios es adecuado este flujo de trabajo?
Avanzado - Gestión de tickets, IA Multimodal
¿Es de pago?
Este flujo de trabajo es completamente gratuito, puede importarlo y usarlo directamente. Sin embargo, tenga en cuenta que los servicios de terceros utilizados en el flujo de trabajo (como la API de OpenAI) pueden requerir un pago por su cuenta.
Flujos de trabajo relacionados recomendados
Giovanni Beggiato
@giovannibeggiatoHi 👋 I’m Gio. I make money with AI automation & teach others how they can too. If you have any questions about my templates or n8n builds, drop them in the comments and I’ll be happy to help.
Compartir este flujo de trabajo