使用OpenAI、Google表格和AI代理自动回复Gmail咨询
这是一个Support, AI领域的自动化工作流,包含 14 个节点。主要使用 Gmail, GmailTrigger, GoogleSheets, Agent, GoogleSheetsTool 等节点,结合人工智能技术实现智能自动化。 使用OpenAI、Google表格和AI代理自动回复Gmail咨询
- •Google 账号和 Gmail API 凭证
- •Google Sheets API 凭证
- •OpenAI API Key
使用的节点 (14)
{
"meta": {
"instanceId": "d1786ab0d745a7498abf13a9c2cdabb1374c006e889b79eef64ce0386b8f8a41",
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "e0d9ee42-e519-41ef-b11a-0c45f7e7a78e",
"name": "OpenAI 聊天模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
280,
180
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "MGwGMKEkdcjzlYCw",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "a0d9e3a0-52d9-4edc-9806-991c1aeb14a3",
"name": "OpenAI 聊天模型1",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
620,
200
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4o-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "MGwGMKEkdcjzlYCw",
"name": "OpenAi account"
}
},
"typeVersion": 1.2
},
{
"id": "40ba7c6e-5854-4313-b695-9ed86c4c8e80",
"name": "结构化输出解析器",
"type": "@n8n/n8n-nodes-langchain.outputParserStructured",
"position": [
820,
200
],
"parameters": {
"jsonSchemaExample": "{\n \"respond\": \"Hi!\\nThank you for reaching out.\\nRefunds can be requested within 30 days of purchase.\\nOur pricing starts at $99/month.\\nIf you have more questions, feel free to reply to this email.\"\n}"
},
"typeVersion": 1.2
},
{
"id": "f7dc1cd8-8c69-450a-b3c9-f7fed3f6ffe1",
"name": "Google Sheets 上下文检索工具",
"type": "n8n-nodes-base.googleSheetsTool",
"position": [
720,
200
],
"parameters": {
"options": {},
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bZ7DTp_6-Qs6S7McyIrlMnuCvHbCrgUI-GBjz_eMpHc/edit#gid=0",
"cachedResultName": "FAQ_Context"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1bZ7DTp_6-Qs6S7McyIrlMnuCvHbCrgUI-GBjz_eMpHc",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bZ7DTp_6-Qs6S7McyIrlMnuCvHbCrgUI-GBjz_eMpHc/edit?usp=drivesdk",
"cachedResultName": "Gmail Auto-Responder – Context & Logs"
},
"descriptionType": "manual",
"toolDescription": "Google Sheet Context Retrieval Tool\nGet Context from Gooogle Sheet"
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "ypmzFxQFfAacuVVC",
"name": "Google Sheets account"
}
},
"typeVersion": 4.5
},
{
"id": "325816aa-d11a-4d73-80f6-b824423e73ae",
"name": "向用户发送回复",
"type": "n8n-nodes-base.gmail",
"position": [
1000,
-20
],
"webhookId": "e676b1f3-9342-4ad0-ac8f-71ec08a27fbc",
"parameters": {
"sendTo": "={{ $('Watch Gmail for New Incoming Emails').item.json.to.value[0].address }}",
"message": "={{ $('Reply Generator AI Agent').item.json.output.respond }}",
"options": {
"appendAttribution": false
},
"subject": "Thanks for Reaching Out – Here’s a Response from Our Team",
"emailType": "text"
},
"credentials": {
"gmailOAuth2": {
"id": "sWl7FFMkEUYBj0zM",
"name": "Gmail account"
}
},
"typeVersion": 2.1
},
{
"id": "cc2247c3-2cc6-4c38-9302-555ba124d3e9",
"name": "回复生成器 AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
660,
-20
],
"parameters": {
"text": "=You are an AI email assistant that helps respond to customer enquiries.\n\nYou are given:\n- A user enquiry (email content)\n- A list of known FAQ context entries from a Google Sheet\n\nYour job is to:\n1. Carefully read the user’s enquiry and identify all individual questions asked.\n2. Check if any of the context entries from the \"Google Sheet Context Retrieval Tool\" to match any of the questions.\n3. Compose ONE complete, friendly, and professional reply that:\n - Answers all the questions that have matching context entries using ONLY the information provided in the context.\n - Politely informs the user that for any unanswered questions, the support team will follow up shortly.\n4. DO NOT make up answers or assume information.\n5. Always include a friendly closing sentence: \n \"If you have more questions, feel free to reply to this email.\"\n\nImportant:\n- Only use information from the FAQ context.\n- Keep your tone professional, friendly, and clear.\n- Make sure the reply is consolidated into a SINGLE email covering all matched and unmatched questions.\n\n---\n\n### INPUTS\n**User Full Name**\n{{ $json.from.value[0].name }}\n\n**User Enquiry (email content):** \n{{ $json.text }}\n\n---\n\n### EXAMPLES\n\n**Example Context:** \n- \"Our pricing starts at $99/month.\" \n- \"We offer a 14-day free trial.\" \n- \"Refunds can be requested within 30 days of purchase.\"\n\n**Example Enquiry:** \n\"Hi **User Full Name**, I want to know if I can get a refund for my purchase and what your pricing is?\"\n\n**Expected Output (in JSON format):**\n\n```json\n{\n \"respond\": \"Hi!\\nThank you for reaching out.\\nRefunds can be requested within 30 days of purchase.\\nOur pricing starts at $99/month.\\nIf you have more questions, feel free to reply to this email.\"\n}\n",
"options": {},
"promptType": "define",
"hasOutputParser": true
},
"typeVersion": 1.9
},
{
"id": "02a2e4bd-05e6-4b3b-b2a4-fa02623c5b25",
"name": "监控 Gmail 新收邮件",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
40,
-20
],
"parameters": {
"simple": false,
"filters": {},
"options": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "sWl7FFMkEUYBj0zM",
"name": "Gmail account"
}
},
"typeVersion": 1.2
},
{
"id": "cfa9d0a9-5e38-43ef-9ce7-ddd86c266ec2",
"name": "记录查询与回复到 Google Sheet",
"type": "n8n-nodes-base.googleSheets",
"position": [
1200,
-20
],
"parameters": {
"columns": {
"value": {
"Timestamp": "={{ $now }}",
"AI Response": "={{ $('Reply Generator AI Agent').item.json.output.reply }}",
"Sender Email": "={{ $('Watch Gmail for New Incoming Emails').item.json.to.value[0].address }}",
"Original Message": "={{ $('Watch Gmail for New Incoming Emails').item.json.text }}"
},
"schema": [
{
"id": "Timestamp",
"type": "string",
"display": true,
"required": false,
"displayName": "Timestamp",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Sender Email",
"type": "string",
"display": true,
"required": false,
"displayName": "Sender Email",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Subject",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "Subject",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Original Message",
"type": "string",
"display": true,
"required": false,
"displayName": "Original Message",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "AI Response",
"type": "string",
"display": true,
"required": false,
"displayName": "AI Response",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "append",
"sheetName": {
"__rl": true,
"mode": "list",
"value": 419912118,
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bZ7DTp_6-Qs6S7McyIrlMnuCvHbCrgUI-GBjz_eMpHc/edit#gid=419912118",
"cachedResultName": "Enquiry_Log"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1bZ7DTp_6-Qs6S7McyIrlMnuCvHbCrgUI-GBjz_eMpHc",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bZ7DTp_6-Qs6S7McyIrlMnuCvHbCrgUI-GBjz_eMpHc/edit?usp=drivesdk",
"cachedResultName": "Gmail Auto-Responder – Context & Logs"
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "ypmzFxQFfAacuVVC",
"name": "Google Sheets account"
}
},
"typeVersion": 4.5
},
{
"id": "47816515-d96d-412c-9ff8-4cb9e3aff9ae",
"name": "查询过滤器",
"type": "@n8n/n8n-nodes-langchain.textClassifier",
"position": [
260,
-20
],
"parameters": {
"options": {},
"inputText": "={{ $json.text }}",
"categories": {
"categories": [
{
"category": "Inquiry",
"description": "The message is asking a question, requesting information, or seeking help — such as product details, pricing, support, or usage instructions."
},
{
"category": "Not Inquiry",
"description": "\tThe message is not asking for anything. It could be a newsletter, promotion, auto-reply, confirmation, or unrelated content with no actionable question."
}
]
}
},
"typeVersion": 1
},
{
"id": "fca2b9cf-2427-4482-a1d8-8788b2b26507",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-280,
-140
],
"parameters": {
"color": 4,
"width": 260,
"height": 380,
"content": "## 需要设置"
},
"typeVersion": 1
},
{
"id": "7326118b-b01e-466e-92ec-b4ea5e77af0d",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
580,
-80
],
"parameters": {
"color": 4,
"width": 380,
"height": 520,
"content": "🤖 读取邮件并创建智能回复"
},
"typeVersion": 1
},
{
"id": "5b256ec0-2b8b-4f24-bf76-8bb489087a25",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
1140,
-100
],
"parameters": {
"color": 4,
"width": 260,
"height": 280,
"content": "✏️ 记录每个查询和回复"
},
"typeVersion": 1
},
{
"id": "27a368f2-abe2-4f3d-ac3e-c433a5512c61",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-320,
300
],
"parameters": {
"color": 5,
"width": 460,
"height": 420,
"content": "## 📧 智能 Gmail 自动回复器 - AI 驱动的客户支持"
},
"typeVersion": 1
},
{
"id": "3795025b-4daf-439d-82e4-a4f872fe0ea0",
"name": "便签4",
"type": "n8n-nodes-base.stickyNote",
"position": [
160,
300
],
"parameters": {
"color": 5,
"width": 400,
"height": 340,
"content": "## 📋 工作流程概览"
},
"typeVersion": 1
}
],
"pinData": {
"Watch Gmail for New Incoming Emails": [
{
"id": "1970bbabb2a1b16a",
"to": {
"html": "<span class=\"mp_address_group\"><span class=\"mp_address_name\">Billy Christi Hartanto</span> <<a href=\"mailto:billychartanto@gmail.com\" class=\"mp_address_email\">billychartanto@gmail.com</a>></span>",
"text": "\"Billy Christi Hartanto\" <billychartanto@gmail.com>",
"value": [
{
"name": "Billy Christi Hartanto",
"address": "billychartanto@gmail.com"
}
]
},
"date": "2025-05-26T08:34:35.000Z",
"from": {
"html": "<span class=\"mp_address_group\"><span class=\"mp_address_name\">Billy Christi Hartanto</span> <<a href=\"mailto:billychartanto@gmail.com\" class=\"mp_address_email\">billychartanto@gmail.com</a>></span>",
"text": "\"Billy Christi Hartanto\" <billychartanto@gmail.com>",
"value": [
{
"name": "Billy Christi Hartanto",
"address": "billychartanto@gmail.com"
}
]
},
"html": "<div dir=\"ltr\">What is your pricing?<br><br>what is your uptime<br><br>what will happen for new user?</div>\n",
"text": "1. Can I try your service before paying? 2. How do I cancel my subscription? 3. I need a refund. How does that work? 4. Where can I download my invoice? 5. What’s included in the Basic Plan? 6. Do you integrate with Google Sheets and Airtable? 7. Is your platform GDPR-compliant? 8. I’m locked out of my account—what should I do? 9. How can I upgrade my current plan? 10. Do you offer support in Indonesian?",
"headers": {
"to": "To: Billy Christi Hartanto <billychartanto@gmail.com>",
"date": "Date: Mon, 26 May 2025 16:34:35 +0800",
"from": "From: Billy Christi Hartanto <billychartanto@gmail.com>",
"subject": "Subject: I want to ask something",
"message-id": "Message-ID: <CAMAvGrJjGkxgDQU+yLWckOVW7JvYGWvQQEDOoXZk6WYoGESVgQ@mail.gmail.com>",
"content-type": "Content-Type: multipart/alternative; boundary=\"0000000000006cd8ca063605d1a4\"",
"mime-version": "MIME-Version: 1.0"
},
"subject": "I want to ask something",
"labelIds": [
"UNREAD",
"IMPORTANT",
"SENT",
"INBOX"
],
"threadId": "1970bba4c2e53c91",
"messageId": "<CAMAvGrJjGkxgDQU+yLWckOVW7JvYGWvQQEDOoXZk6WYoGESVgQ@mail.gmail.com>",
"textAsHtml": "<p>What is your pricing?</p><p>what is your uptime</p><p>what will happen for new user?</p>",
"sizeEstimate": 744
}
]
},
"connections": {
"Inquiry Filter": {
"main": [
[
{
"node": "Reply Generator AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Chat Model": {
"ai_languageModel": [
[
{
"node": "Inquiry Filter",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"OpenAI Chat Model1": {
"ai_languageModel": [
[
{
"node": "Reply Generator AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Send Reply to User": {
"main": [
[
{
"node": "Log Inquiries + Response to Google Sheet",
"type": "main",
"index": 0
}
]
]
},
"Reply Generator AI Agent": {
"main": [
[
{
"node": "Send Reply to User",
"type": "main",
"index": 0
}
]
]
},
"Structured Output Parser": {
"ai_outputParser": [
[
{
"node": "Reply Generator AI Agent",
"type": "ai_outputParser",
"index": 0
}
]
]
},
"Watch Gmail for New Incoming Emails": {
"main": [
[
{
"node": "Inquiry Filter",
"type": "main",
"index": 0
}
]
]
},
"Google Sheets Context Retrieval Tool": {
"ai_tool": [
[
{
"node": "Reply Generator AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
}
}如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 客户支持, 人工智能
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
Billy Christi
@billyI'm a professional software engineer and n8n expert with a passion for building scalable, no-code and low-code automation workflows. I specialize in creating seamless integrations between APIs, CRMs, and everyday tools to help businesses save time, reduce manual work, and operate smarter. Whether it's automating marketing pipelines, backend systems, or approval processes, I turn complex logic into simple, powerful workflows with n8n.
分享此工作流