构建您的第一个带有备用模型的电子邮件代理
中级
这是一个Ticket Management, AI Chatbot领域的自动化工作流,包含 11 个节点。主要使用 Gmail, GmailTrigger, Agent, GoogleSheetsTool, LmChatOpenAi 等节点。 构建您的第一个自动化电子邮件支持代理(AI备用方案与日志记录)
前置要求
- •Google 账号和 Gmail API 凭证
- •Google Sheets API 凭证
- •OpenAI API Key
- •Google Gemini API Key
使用的节点 (11)
工作流预览
可视化展示节点连接关系,支持缩放和平移
导出工作流
复制以下 JSON 配置到 n8n 导入,即可使用此工作流
{
"id": "e63GF6KHkhFUFKfz",
"meta": {
"instanceId": "2000c64071c20843606b95c63795bb0797c41036047055a6586498e855b96efc",
"templateCredsSetupCompleted": true
},
"name": "构建您的第一个带有备用模型的电子邮件代理",
"tags": [],
"nodes": [
{
"id": "4a1bcd5c-ac55-4edc-8508-f2921dcc1b68",
"name": "AI Agent",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
288,
0
],
"parameters": {
"text": "={{ $json.Subject }} {{ $json.snippet }}",
"options": {
"systemMessage": "\n## Primary Role\nYou are a professional customer support AI agent that processes incoming Gmail messages, provides helpful responses to customers, and logs all support requests for tracking purposes.\n\n## Core Responsibilities\n\n### 1. Email Analysis & Response\n- **Read and analyze** each incoming email carefully\n- **Identify the type of request**: technical issue, billing question, feature request, complaint, general inquiry, etc.\n- **Determine urgency level**: Low, Medium, High, Critical\n- **Extract key information**: customer details, issue description, requested action, timeline expectations\n\n### 2. Customer Reply Generation\nGenerate professional, helpful, and empathetic email responses that:\n- **Acknowledge** the customer's concern promptly\n- **Provide clear solutions** or next steps when possible\n- **Set appropriate expectations** for resolution timeline\n- **Maintain a friendly, professional tone**\n- **Include relevant resources** (links, documentation, FAQs) when helpful\n- **Ask clarifying questions** if more information is needed\n- **Escalate to human support** when issues are complex or sensitive\n\n### 3. Google Sheets Logging\nFor every email processed, log the following information:\n- **Date/Time**: When the email was received\n- **Customer Email**: Sender's email address\n- **Customer Name**: If available\n- **Subject Line**: Email subject\n- **Request Type**: Category (Technical, Billing, Feature Request, etc.)\n- **Priority Level**: Low/Medium/High/Critical\n- **Issue Summary**: Brief description (2-3 sentences max)\n- **Status**: New/In Progress/Resolved/Escalated\n- **Response Sent**: Yes/No\n- **Follow-up Required**: Yes/No/Date\n- **Agent Notes**: Any additional context or actions taken\n\n## Response Templates & Guidelines\n\n### Standard Greeting\n\"Hi [Customer Name],\n\nThank you for reaching out to us. I've received your message regarding [brief issue summary].\"\n\n### Common Scenarios\n\n**Technical Issues:**\n- Acknowledge the frustration\n- Provide step-by-step troubleshooting\n- Offer alternative solutions\n- Set expectations for resolution\n\n**Billing Questions:**\n- Confirm account details (without exposing sensitive info)\n- Explain charges clearly\n- Provide next steps for disputes\n- Include relevant billing resources\n\n**Feature Requests:**\n- Thank them for the suggestion\n- Explain current roadmap (if applicable)\n- Suggest workarounds if available\n- Confirm request has been logged for product team\n\n**Complaints:**\n- Acknowledge their concern with empathy\n- Take responsibility where appropriate\n- Outline steps to resolve\n- Offer compensation if warranted\n\n### Escalation Criteria\nEscalate to human support when:\n- Customer is extremely upset or threatening\n- Issue involves sensitive account information\n- Technical problem requires developer intervention\n- Billing dispute over significant amount\n- Legal or compliance matters\n- Multiple failed resolution attempts\n\n### Tone Guidelines\n- **Professional** yet conversational\n- **Empathetic** and understanding\n- **Clear** and concise\n- **Proactive** in offering solutions\n- **Apologetic** when appropriate (without admitting fault unnecessarily)\n\n## Memory & Context Management\n- **Remember** previous interactions with the same customer\n- **Reference** past solutions or conversations when relevant\n- **Track** ongoing issues to ensure continuity\n- **Note** customer preferences or special circumstances\n\n## Quality Standards\n- **Response time**: Aim for acknowledgment within 1 hour during business hours\n- **Accuracy**: Ensure all information provided is correct and up-to-date\n- **Completeness**: Address all questions/concerns in the customer's email\n- **Follow-up**: Set reminders for promised callbacks or updates\n\n## Example Response Format\n\nSubject: Re: [Original Subject] - We're here to help!\n\nHi [Customer Name],\n\nThank you for contacting us about [issue]. I understand [acknowledge their concern/situation].\n\n[Provide solution/next steps/information requested]\n\n[If applicable: set expectations, provide timeline, or explain next steps]\n\nIs there anything else I can help you with today? We're always here to support you.\n\nBest regards,\n[Your Name]\nCustomer Support Team\n\n---\n\n**Note**: Always maintain customer privacy and confidentiality. Never share sensitive information inappropriately, and ensure all logging complies with data protection standards."
},
"promptType": "define",
"needsFallback": true
},
"typeVersion": 2.1
},
{
"id": "a2a87327-902b-4f95-b819-25221793fb77",
"name": "Gmail 触发器",
"type": "n8n-nodes-base.gmailTrigger",
"position": [
-32,
0
],
"parameters": {
"filters": {},
"pollTimes": {
"item": [
{
"mode": "everyMinute"
}
]
}
},
"credentials": {
"gmailOAuth2": {
"id": "LVRUgE95PAvkE1Mc",
"name": "Gmail account 2"
}
},
"typeVersion": 1.2
},
{
"id": "06d647bb-b03d-42bf-8462-204546d3b427",
"name": "简单记忆",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
384,
256
],
"parameters": {
"sessionKey": "={{ $('Gmail Trigger').item.json.id }}",
"sessionIdType": "customKey"
},
"typeVersion": 1.3
},
{
"id": "4ce6dbd6-e68a-4e86-92db-4ed5c9b362b4",
"name": "在 Google Sheets 中追加或更新行",
"type": "n8n-nodes-base.googleSheetsTool",
"position": [
528,
256
],
"parameters": {
"columns": {
"value": {
"email address ": "={{ $('Gmail Trigger').item.json.To }}"
},
"schema": [
{
"id": "customer_name",
"type": "string",
"display": true,
"removed": false,
"required": false,
"displayName": "customer_name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "email address ",
"type": "string",
"display": true,
"required": false,
"displayName": "email address ",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "Service type",
"type": "string",
"display": true,
"required": false,
"displayName": "Service type",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "appointment date",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "appointment date",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "estimated duration",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "estimated duration",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "estimated price",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "estimated price",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "stylist name",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "stylist name",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "hair length",
"type": "string",
"display": true,
"removed": true,
"required": false,
"displayName": "hair length",
"defaultMatch": false,
"canBeUsedToMatch": true
},
{
"id": "phone number ",
"type": "string",
"display": true,
"required": false,
"displayName": "phone number ",
"defaultMatch": false,
"canBeUsedToMatch": true
}
],
"mappingMode": "defineBelow",
"matchingColumns": [
"customer_name"
],
"attemptToConvertTypes": false,
"convertFieldsToString": false
},
"options": {},
"operation": "appendOrUpdate",
"sheetName": {
"__rl": true,
"mode": "list",
"value": "gid=0",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1KFjFpYS9akNv_I-JcQKMQVBT-rXYfK2sC4dP6QYpcp4/edit#gid=0",
"cachedResultName": "Sheet1"
},
"documentId": {
"__rl": true,
"mode": "list",
"value": "1KFjFpYS9akNv_I-JcQKMQVBT-rXYfK2sC4dP6QYpcp4",
"cachedResultUrl": "https://docs.google.com/spreadsheets/d/1KFjFpYS9akNv_I-JcQKMQVBT-rXYfK2sC4dP6QYpcp4/edit?usp=drivesdk",
"cachedResultName": "SUPPORT LOG "
}
},
"credentials": {
"googleSheetsOAuth2Api": {
"id": "vL25dYTf9oT1CSvl",
"name": "Google Sheets account 2"
}
},
"typeVersion": 4.6
},
{
"id": "4310966d-894d-490b-9d52-49c1aa03b9ae",
"name": "便签",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1104,
-352
],
"parameters": {
"width": 768,
"height": 848,
"content": "# 🤖 您的第一个带有备用模型的电子邮件代理"
},
"typeVersion": 1
},
{
"id": "ddc5d69b-8386-45e1-9b7f-139e5b42c15f",
"name": "便签1",
"type": "n8n-nodes-base.stickyNote",
"position": [
1072,
-512
],
"parameters": {
"width": 640,
"height": 1360,
"content": ""
},
"typeVersion": 1
},
{
"id": "08ff7ff4-4c41-43e9-a71d-43e07f0c75e4",
"name": "便签2",
"type": "n8n-nodes-base.stickyNote",
"position": [
-192,
-448
],
"parameters": {
"width": 464,
"height": 448,
"content": "## 🎯 非常适合初学者的原因:"
},
"typeVersion": 1
},
{
"id": "99dd9b98-5384-498e-b3e5-2552bb7016b0",
"name": "OpenAI 模型",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-96,
288
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-4.1-mini"
},
"options": {}
},
"credentials": {
"openAiApi": {
"id": "BXMUxnyGzjtZQOK4",
"name": "OpenAi account Dave"
}
},
"typeVersion": 1.2
},
{
"id": "b91e9199-c9cd-4dc6-bd8e-9a97aad2f9c4",
"name": "Gemini Chat 模型",
"type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
"position": [
-192,
272
],
"parameters": {
"options": {}
},
"credentials": {
"googlePalmApi": {
"id": "OCsJdRrt1Xxv1ZGe",
"name": "paid google console"
}
},
"typeVersion": 1
},
{
"id": "b56d1d13-8b88-4a69-b0d9-c2c35e6f95da",
"name": "便签3",
"type": "n8n-nodes-base.stickyNote",
"position": [
-208,
176
],
"parameters": {
"height": 224,
"content": "## AI 模型"
},
"typeVersion": 1
},
{
"id": "9ecaa23a-40af-4d5f-80ef-a6df1dc9acf9",
"name": "回复消息(线程)",
"type": "n8n-nodes-base.gmail",
"position": [
784,
0
],
"webhookId": "c3d3ef78-4b9a-4392-8b21-497aa09e33af",
"parameters": {
"message": "={{ $json.output }}",
"options": {},
"resource": "thread",
"threadId": "={{ $('Gmail Trigger').item.json.id }}",
"messageId": "={{ $('Gmail Trigger').item.json.id }}",
"operation": "reply"
},
"credentials": {
"gmailOAuth2": {
"id": "LVRUgE95PAvkE1Mc",
"name": "Gmail account 2"
}
},
"typeVersion": 2.1
}
],
"active": false,
"pinData": {},
"settings": {
"executionOrder": "v1"
},
"versionId": "51d6850a-e062-4209-b0d3-e6f4d5f0eb05",
"connections": {
"AI Agent": {
"main": [
[
{
"node": "Reply to a message(Thread)",
"type": "main",
"index": 0
}
]
]
},
"Gmail Trigger": {
"main": [
[
{
"node": "AI Agent",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 1
}
]
]
},
"Simple Memory": {
"ai_memory": [
[
{
"node": "AI Agent",
"type": "ai_memory",
"index": 0
}
]
]
},
"Gemini Chat Model": {
"ai_languageModel": [
[
{
"node": "AI Agent",
"type": "ai_languageModel",
"index": 0
}
]
]
},
"Append or update row in sheet in Google Sheets": {
"ai_tool": [
[
{
"node": "AI Agent",
"type": "ai_tool",
"index": 0
}
]
]
}
}
}常见问题
如何使用这个工作流?
复制上方的 JSON 配置代码,在您的 n8n 实例中创建新工作流并选择「从 JSON 导入」,粘贴配置后根据需要修改凭证设置即可。
这个工作流适合什么场景?
中级 - 工单管理, AI 聊天机器人
需要付费吗?
本工作流完全免费,您可以直接导入使用。但请注意,工作流中使用的第三方服务(如 OpenAI API)可能需要您自行付费。
相关工作流推荐
AI驱动的客户支持:邮件、知识库与人工升级自动化
AI邮件支持系统:集成Gmail、Gemini、GPT-4、Slack和Google Sheets的工作流程
Set
Gmail
Slack
+13
26 节点David Olusola
工单管理
使用 Airtable、Gmail 和 OpenAI 自动回复客户邮件
使用 Airtable、Gmail 和 GPT-4.1 Mini 自动回复客户邮件
Gmail
Airtable
Gmail Trigger
+4
12 节点Baptiste Fort
工单管理
基于 Gemini 2.0 Flash AI 和 Google Sheets 的对话式线索捕获
基于 Gemini 2.0 Flash AI 和 Google Sheets 的对话式线索捕获
Webhook
Agent
Google Sheets Tool
+4
10 节点David Olusola
潜在客户开发
WhatsApp/Telegram WooCommerce订单支持
通过Telegram和Gmail使用Gemini和GPT自动化WooCommerce客户支持
Set
Gmail
Merge
+10
25 节点AppStoneLab Technologies LLP
客服机器人
我的工作流2
使用多个GPT-4o AI代理管理个人数据:Telegram上的Gmail、任务和财务
Set
Code
Gmail
+14
62 节点Mahmoud Shrouf
AI 聊天机器人
使用GPT-4整理Gmail并通过Telegram和WhatsApp发送紧急通知
通过GPT-4整理Gmail,并使用Telegram和WhatsApp发送紧急通知
If
Code
Wait
+14
28 节点Iniyavan JC
工单管理
工作流信息
难度等级
中级
节点数量11
分类2
节点类型8
作者
David Olusola
@dae221I help ambitious businesses eliminate operational bottlenecks and scale faster with AI automation. My clients typically see 40-60% efficiency gains within 90 days. Currently accepting 3 new projects this quarter - david@daexai.com
外部链接
在 n8n.io 查看 →
分享此工作流