2026-10-07 · 原文发布日
按人生事件局部刷新财务计划表
季度定时由 Gmail 寄出检查邮件,用户经 Google Form 回填到 Life_Event_CheckIn 表后,工作流校验 Plan ID、邮箱与事件,映射到受影响计划段落;无重大变化只回确认信。否则读取 Financial Plan 对应行,让 OpenAI 只生成这些段落的 JSON 更新,校验通过才写表、记入 Plan Change History 并邮件通知,失败则只发校验提醒。
原文要点
原工作流每季度定时通过 Gmail 寄出检查邮件(含检查 ID、Plan ID、Google Form 链接)。Google Form 回填进 Life_Event_CheckIn 表后触发,校验 Plan ID、邮箱与 Life Event 三必填,把事件映射到受影响的计划段落;无重大变化只回确认信。否则读取 Financial Plan 表对应行,让 OpenAI 只生成这些段落的 JSON 更新,校验通过才写表、追加 Plan Change History 并发汇总邮件;校验失败只发提醒、不动任何表。原文附故障排查表和五个事件示例。模板免费。
这次做成什么
搭建一条事件驱动的局部财务计划刷新流:季度寄信→表单回收→事件映射→AI 只改受影响段落→校验后写表留痕→邮件通知,失败路径零写操作。
准备什么
- n8n 云端或自托管实例
- Google Sheets OAuth2 凭据,及一张含 Life_Event_CheckIn、Financial Plan、Plan Change History 三个工作表的表格
- Gmail OAuth2 发送凭据(测试邮箱)
- OpenAI API Key,并在 OpenAI 节点确认模型选择
- 一个把回复写入 Life_Event_CheckIn 的 Google Form,列名与约定一致
具体怎么做
建三张工作表
Life_Event_CheckIn 列:Plan ID、Email Address、Life Event、Event Date、Income Change、Expense Change、Notes。Financial Plan 列:plan_id、section_key、current_value、recommendation、updated_at、version,并为每个 plan_id 预填各 section_key 行(如 emergency_fund、insurance、savings_goals、retirement、debt_strategy、education_savings、home_purchase)。Plan Change History 列:history_id、plan_id、section_key、previous_value、new_value、previous_recommendation、new_recommendation、changed_at、version。
季度寄信与表单触发
Schedule Trigger 设为每三个月,元数据节点生成 checkInId、planId、收件邮箱和 Form 链接,Gmail 节点寄出检查邮件。另建 Google Sheets Trigger 监听 Life_Event_CheckIn 新行,先校验 Plan ID、Email Address、Life Event 均非空,缺任一项就寄表单校验提醒并终止,不改任何数据。
事件映射与分支
映射节点把 Life Event 映射到 section_key 列表:New Child→emergency_fund/education_savings/insurance/savings_goals;Marriage→emergency_fund/insurance/savings_goals/retirement;New Job→emergency_fund/insurance/savings_goals/retirement;Home Purchase→emergency_fund/home_purchase/debt_strategy/savings_goals;Major Debt→emergency_fund/debt_strategy/savings_goals。No Major Change 映射为空列表,走只发确认邮件的分支并终止。
AI 局部更新与校验写表
按 plan_id 和受影响 section_key 从 Financial Plan 读出现值,连同事件详情发给 OpenAI,要求只输出这些段落的 JSON 更新。校验节点检查 schema 完整、字段属于允许段落,并按本示例设定的边界检查取值(如 emergency_fund 月数限定 1-24,可按需调整;原文仅说明会做 schema 与资格校验)。通过则更新 Financial Plan 对应行、向 Plan Change History 逐段追加记录,Gmail 发汇总更新邮件;失败则只发 AI 校验提醒,Financial Plan 与历史表零写入。
可直接复制的材料
受影响段落 JSON 更新提示词
本站独立编写的练习提示词,花括号替换为节点变量;数值边界是本示例设定,可按需调整。
你是理财计划局部更新助手。用户报告了人生事件,只允许更新下列段落,禁止新增或修改其他段落:{affectedSections}。事件信息:{lifeEvent},发生日期:{eventDate},收入变化:{incomeChange},支出变化:{expenseChange},备注:{notes}。当前计划值:{currentSectionsJson}。严格输出 JSON 数组,每个元素形如:{"section_key": "段落名", "new_value": "数值或简短文本", "recommendation": "不超过80字的中文建议"}。规则:emergency_fund 的 new_value 为可覆盖月数,取值 1-24 之间的数字;建议需结合事件,不得编造未提供的收入数字;不允许的 section_key 一律不输出。三张表的结构配置
列名与映射按原文信息整理;JSON 外壳是本站设计,实际以表格表头为准。
{
"spreadsheet": "你的表格ID",
"tabs": {
"Life_Event_CheckIn": ["Plan ID", "Email Address", "Life Event", "Event Date", "Income Change", "Expense Change", "Notes"],
"Financial Plan": ["plan_id", "section_key", "current_value", "recommendation", "updated_at", "version"],
"Plan Change History": ["history_id", "plan_id", "section_key", "previous_value", "new_value", "previous_recommendation", "new_recommendation", "changed_at", "version"]
},
"eventMapping": {
"New Child": ["emergency_fund", "education_savings", "insurance", "savings_goals"],
"Marriage": ["emergency_fund", "insurance", "savings_goals", "retirement"],
"New Job": ["emergency_fund", "insurance", "savings_goals", "retirement"],
"Home Purchase": ["emergency_fund", "home_purchase", "debt_strategy", "savings_goals"],
"Major Debt": ["emergency_fund", "debt_strategy", "savings_goals"],
"No Major Change": []
}
}Financial Plan 种子数据
本站虚构种子数据,金额为示例参考值,供 P-001 计划测试用。
plan_id,section_key,current_value,recommendation,updated_at,version
P-001,emergency_fund,3,"建议维持3个月支出储备",2026-07-01,1
P-001,education_savings,0,"暂未设立教育储蓄",2026-07-01,1
P-001,insurance,基础医疗,"仅有基本医疗保障",2026-07-01,1
P-001,savings_goals,2000,"每月储蓄2000元",2026-07-01,1输入与输出示例
本站虚构演示,金额与建议均为示例设定,未实际运行。
输入
Life_Event_CheckIn 新行:Plan ID=P-001,Email Address=zhangsan@example-test.com,Life Event=New Child,Event Date=2026-09-20,Income Change=无,Expense Change=每月+3500元,Notes=孩子9月出生。对应输出
映射命中 emergency_fund/education_savings/insurance/savings_goals 四段。AI 输出 [{"section_key":"emergency_fund","new_value":"6","recommendation":"新增育儿支出后建议储备提升至6个月"},{"section_key":"education_savings","new_value":"800","recommendation":"建议每月定投800元教育储蓄"},{"section_key":"insurance","new_value":"医疗+重疾","recommendation":"为孩子补充重疾与医疗险"},{"section_key":"savings_goals","new_value":"1500","recommendation":"支出上升,储蓄目标暂调至1500元"}]。校验通过:四行写回 Financial Plan 且 version 升为 2,Plan Change History 追加 4 条记录,Gmail 发出汇总更新邮件。做完检查这些
- 缺 Plan ID、Email Address 或 Life Event 任一项的提交只触发表单校验提醒邮件,三张表无变化
- No Major Change 提交只收到确认邮件,Financial Plan 与历史表零写入
- AI 输出含不允许的 section_key 或月数超出 1-24 时,校验拦截且只发 AI 校验提醒
- 校验通过后 Financial Plan 只有受影响段落被改写,其他行 current_value 与 version 不变
- Plan Change History 每条记录同时含 previous 与 new 值及 version,可逐段追溯
容易卡住的地方
- Financial Plan 必须预先按 plan_id+section_key 种子化,否则读不到现值会报错
- Google Form 列名要与工作流期望完全一致,至少含 Plan ID、Email Address、Life Event
- AI 输出失败时不要重试无限循环,按原文设计发提醒邮件即可
- 季度邮件没发出时先查 Gmail 凭据与元数据节点的收件人配置
- 无变化提交不更新计划是预期行为,不是故障
本站借助AI整理来源事实,独立编写中文操作指南与示例。示例不代表实际运行结果;来源效果尚未由本站独立复现。付费模板与模型、服务费用分别计算。
- 原文标题
- Refresh financial plans from life events with Google Sheets, OpenAI, and Gmail
- 原作者
- WeblineIndia
- 原始发布日期
- 2026-10-07T04:21:36.909Z
- 来源
- https://n8n.io/workflows/20588