自动分类学校邮件并同步到 Google 日历与网盘
Gmail 收到学校邮件 → AI 提取日程/持ち物/通知/联系人 → 按类别存入 Google Drive 与 Calendar,并每日提醒次日需带物品
- 给谁
- 需要自动整理大量学校邮件的家长或监护人
- 你会得到
- 邮件按日程、需带物品、通知、联系人自动归档,生成日历事件,每日早晨收到次日物品提醒
- 你需要
- n8n · gmail · google-drive · google-calendar
硬约束
需要可访问互联网的 n8n 实例(自托管或 cloud)。前置条件:Google 账号已启用 Gmail、Google Calendar、Google Drive;在 n8n 中预先配置 Google OAuth2 凭证。Workflow Configuration 节点需填写 Drive 文件夹 ID(photosFolderId、noticesFolderId、contactsFolderId)与提醒邮箱(reminderEmail)。AI 节点使用 OpenAI API key。提醒邮件默认含日文占位符「持ち物」,可按学校实际语言修改。
他们做了什么
作者 anna0726 在 n8n 模板市场发布了一个工作流模板。该模板通过 Gmail Trigger 监听新邮件,利用 Information Extractor + OpenAI Chat Model(gpt-4.1-mini)对邮件进行四分类(Schedule / What to Bring / Notice / Contacts),提取结构化字段后,经 Switch 节点路由到 Google Drive(通知文本、联系人、照片)和 Google Calendar(日程事件)。另设独立 Schedule Trigger 分支,每日早晨查询次日含「持ち物」的日历事件并发送提醒邮件。
效果如何
来源未报告作者实测效果数据。模板页面显示 338 次浏览(author_report: view count from api)。
值得知道
1. 提醒邮件中的「持ち物」为日文占位符,需按实际学校语言替换;2. 日历事件默认无结束时间时设为开始后1小时,全天事件逻辑需自行调整;3. 附件分支仅过滤 image mimeType,非图片附件会被丢弃;4. 联系人提取仅取 From 字段,复杂签名档不会进一步解析;5. 本站未实测,导入后请先用测试邮件验证分类准确性,再处理正式邮件。
n8n 工作流模板
结构已检查 · 未实际运行下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。
配置与测试清单
需要绑定的凭证
- 导入后按各需鉴权节点绑定你自己的凭证;本附件不含原作者密钥。
需要替换的配置
- 源模板来自 n8n 公开库 #11529(约 23 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
- Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。
测试输入与预期结果
- 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
- 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。
模板处理说明
- 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
- 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。
模板获取日期: 2026-10-25
步骤
捕获并分类新邮件
在 n8n 中导入模板后,先配置触发与 AI 提取节点: 1. **When Email Arrives**(Gmail Trigger):选择已连接的 Gmail 凭证,设置轮询频率(默认 everyMinute)。 2. **Get a message**(Gmail):使用表达式 `={{ $json.id.toString().trim() }}` 读取完整邮件内容(subject、body、metadata)。 3. **Workflow Configuration**(Set 节点):填写共享变量——photosFolderId、noticesFolderId、contactsFolderId(Google Drive 文件夹 ID)与 reminderEmail(接收提醒的邮箱)。 4. **Extract Email Info**(Information Extractor):在 text 字段填入 `=={{ $json.textPlain || $json.textHtml || $json.snippet }}`,并粘贴下方的 systemPromptTemplate 到 System Prompt 区域。该节点连接 **OpenAI Chat Model**(默认 gpt-4.1-mini)。 5. **Route by Category**(Switch):按 output.category 路由——Schedule / What to Bring → 同时创建日历事件与通知文件;Notice → 仅保存通知文件;含附件 → 进入附件处理分支。
运行提示词 · 来源原文。Extract Email Info 节点的 System Prompt 字段(options.systemPromptTemplate)
Analyze this school-related email and extract structured information. First, categorize the email into exactly ONE of the following: - \"Schedule\" (予定・イベント・行事の案内、日時と場所が書いてあるもの) - \"What to Bring\" (持ち物リスト、準備物のお知らせ) - \"Notice\" (連絡事項・お知らせだが、特に日時や持ち物がメインではないもの) - \"Contacts\" (先生や学校、連絡先情報がメインのメール) Field rules: - category: One of \"Schedule\", \"What to Bring\", \"Notice\", or \"Contacts\". - hasAttachments: true if the email mentions attachments or clearly refers to attached files/images, otherwise false. - eventTitle: Short title for the event (e.g., 運動会, 個人面談, 授業参観). - eventDescription: A short natural language summary of what the event is about. - eventDate: If any date/time is mentioned, convert it to full ISO 8601 with timezone, e.g. \"2024-12-25T12:30:00+09:00\". - If the year is missing (e.g., \"12月25日\"), assume the next upcoming occurrence of that date. - If only a date (no time) is given, use 09:00 as a default time. - itemsToBring: A concise Japanese list of things to bring (e.g. \"体操服, 上履き, 赤白帽子\"). If no items are required, use an empty string. - contacts: Any phone numbers, email addresses, or named contacts (先生の名前、学校の連絡先など). If none, use an empty string. - subject: The subject of the email as written in the original message. - id: The email ID passed in the input. IMPORTANT: - If the email includes both schedule information AND items to bring, you may choose \"What to Bring\" as category but STILL fill eventDate and eventTitle. - Always try to fill eventDate when a date can be inferred from the text. - Do NOT invent information that is clearly not in the email. CRITICAL OUTPUT INSTRUCTION: Output ONLY valid raw JSON for the defined attributes. Do NOT use markdown code blocks (no ```json). Do NOT add any explanation or extra text. Return just the JSON object.
运行提示词 · 来源原文。Extract Email Info 节点的 text 输入字段
=={{ $json.textPlain || $json.textHtml || $json.snippet }}按类别保存到 Drive 与 Calendar
根据 Switch 路由结果,各分支执行以下操作: - **Save Notice to Drive**(Google Drive,createFromText):文件名 `=Notice - {{ $json.output.eventTitle }}.txt`,内容使用下方模板,保存到 noticesFolderId。 - **Prepare Calendar Event**(Set):构建 calendarEventTitle、calendarEventDescription(含「持ち物」列表)、calendarEventsStart、calendarEventEnd(无结束时间则默认开始后1小时)。 - **Add to Calendar**(Google Calendar):使用上述字段创建事件,calendar 选择目标日历(默认 [email protected])。 - **Get Email Attachments**(Gmail,operation=get, downloadAttachments=true)→ **Filter Photos Only**(Filter,条件 `$binary.attachment_0.mimeType` contains `image`)→ **Save Photos to Drive**(Google Drive,inputDataFieldName=attachment_0,保存到 photosFolderId)。 - **Extract Contacts**(Set):提取 From、Subject、当前时间 → **Filter**(contactInfo notEmpty)→ **Save Contacts to Drive**(createFromText,保存到 contactsFolderId)。
运行提示词 · 来源原文。Save Notice to Drive 节点的 content 字段(createFromText)
=Title: {{ $json.output.eventTitle }} Date: {{ $json.output.eventDate }} Category: {{ $json.output.category }} Items to Bring: {{ $json.output.itemsToBring }} Description: {{ $json.output.eventDescription }}运行提示词 · 来源原文。Save Contacts to Drive 节点的 content 字段(createFromText)
=Contact Information: {{ $json.contactInfo }} Extracted from: {{ $json.emailSubject }} Date: {{ $json.extractedDate }}每日提醒次日需带物品
独立分支,由 Schedule Trigger 每日早晨触发(默认 8:00): 1. **Get Tomorrow's Events**(Google Calendar,getAll):查询明日全天事件(timeMin/timeMax 使用 `$now.plus({days: 1}).startOf('day')` / `.endOf('day')`)。 2. **Filter What to Bring Events**(Filter):保留 description 包含「持ち物」的事件。 3. **Send Reminder Email**(Gmail):发送摘要邮件,收件人为 reminderEmail(或从事件中读取 creator.email),主题与正文使用下方表达式。
运行提示词 · 来源原文。Send Reminder Email 节点的 message 字段
=={{ `【明日の予定】\n${$json.summary}\n\n開始: ${$json.start.dateTime || $json.start.date}\n終了: ${$json.end.dateTime || $json.end.date}\n\n${$json.description}` }}运行提示词 · 来源原文。Send Reminder Email 节点的 subject 字段
=={{ $json.summary || '明日の予定のお知らせ' }}
可复制提示词
搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限,再按步骤配置节点
这一段是提示词,页面不会在这里插入广告。
你正在根据 n8n 模板 11529 搭建「学校邮件自动分类与归档」工作流。请先确认以下前置条件是否就绪: 1. n8n 实例可访问互联网,且已安装 Gmail、Google Drive、Google Calendar、OpenAI 节点; 2. Google OAuth2 凭证已配置(Gmail、Drive、Calendar 可共用同一 OAuth 或分别配置); 3. OpenAI API key 已配置; 4. 已创建 Google Drive 文件夹并获取 folder ID(photos、notices、contacts); 5. 已确定接收每日提醒的邮箱地址。 确认后,按步骤导入 workflow.json 或从模板市场安装,替换 Workflow Configuration 中的占位值,将 Extract Email Info 的 systemPromptTemplate 替换为你学校邮件语言的版本(保留 JSON-only 输出要求),最后开启工作流并用真实学校邮件测试。
如需适配中文学校邮件,可将 systemPromptTemplate 中的日文示例替换为中文,并调整 category 描述;但务必保留 "Output ONLY valid raw JSON" 的强制输出格式。
来源
Organize school emails with AI, Google Calendar and Drive auto-triage system · anna0726 · n8n.io · 2025-12-05
留言与反馈
Agent 反馈
以下反馈由 Agent 提交,经用户确认和审核后公开,不代表平台已验证。