ChatGPT工作计划AI 评分 · 待评分AI 辅助编辑·未发现明显提示词注入风险n8n.io

用 n8n AI Agent 管理 Google 日历事件(查询/创建/删除)

将自然语言指令通过父工作流传给子 Agent,由 LLM 选择调用 Google Calendar 工具完成事件查询、创建或删除

有一点经验步骤流程提示词
给谁
需要在 n8n 中搭建日历助手、让 AI Agent 代理操作 Google Calendar 的自动化用户
你会得到
父工作流发送自然语言指令后,子 Agent 自动选择 Get/Create/Delete 工具操作指定日历并返回结果
你需要
n8n · openai · google-calendar · memory

硬约束

前置条件:n8n 实例(CE 即可)、OpenAI API 密钥、Google Calendar OAuth2 凭证、目标日历 ID。本模板为子工作流(Sub-Agent),需由父工作流通过 Execute Workflow 节点调用。输入参数为 `text`(用户指令)和 `sessionid`(会话标识,用于短期记忆)。费用:n8n CE 免费;OpenAI 与 Google Calendar 按实际用量计费。

他们做了什么

作者 ca7ai 在 n8n 模板库发布了一个子工作流模板,作为父 Agent 的日历工具层。该子工作流通过 Execute Workflow Trigger 接收 `text` 和 `sessionid`,由 AI Agent(gpt-4.1-mini)根据 systemMessage 选择调用 Get、Create 或 Delete 工具操作 Google Calendar,并使用 Simple Memory 按 sessionid 维持短期记忆。

效果如何

模板描述中提供了测试示例:发送 "Schedule 'Team Sync' tomorrow 10:00--11:00" 应触发 Create;"List events next week" 应触发 Get 并使用时间范围;"Delete event 'Team Sync'" 应触发 Delete 并在匹配 eventId 后删除。(来源:作者报告,未实测)

值得知道

1. 本模板是子工作流,不能独立运行,必须由父工作流调用。2. systemMessage 原文中 "If you need to create events in the calendar use the 'Get' tool" 疑似笔误,实际意图应为调用 Create 工具;搭建时建议按节点功能理解。3. workflow.json 中日历占位符为 [email protected],运行前必须替换为真实日历 ID。4. Create 工具需要 start、end、summary;Delete 需要 eventId;Get 支持 timeMin/timeMax 范围查询。5. 记忆按 sessionid 隔离,不同 sessionid 视为不同会话。

n8n 工作流模板

结构已检查 · 未实际运行

下载后在 n8n 选择“Import from File”,或复制 JSON 后粘贴到编辑器。先配置自己的账号,再用测试数据运行;模板默认未启用。

配置与测试清单

需要绑定的凭证

  • OpenAI Chat Model 节点:绑定OpenAI API 凭证。
  • Create 节点:绑定Google Calendar OAuth2 凭证。
  • Get 节点:绑定Google Calendar OAuth2 凭证。
  • Delete 节点:绑定Google Calendar OAuth2 凭证。

需要替换的配置

  • 源模板来自 n8n 公开库 #7787(约 9 个节点)。导入后先保持未启用,核对触发器、表达式与外部 API 端点。
  • Sticky Note 中的说明仅供参考;按自己的账号、表结构或频道 ID 替换占位配置。

测试输入与预期结果

  • 在测试环境手动执行一次主路径,确认每个需凭证的节点已连接且无鉴权错误。
  • 用一条合成/脱敏样例数据跑通,核对输出字段与下游写入目标,再考虑生产启用。

模板处理说明

  • 已移除原作者凭证绑定、webhookId 与执行数据,工作流设为未启用;节点、连线与原文提示词保持原样。未在 n8n 中实际运行。
  • 未改业务逻辑;运行前请自行核对密钥、配额与隐私合规。

模板获取日期: 2026-10-24

步骤

  1. 导入模板并声明输入

    在 n8n 中导入此子工作流模板。打开「When Executed by Another Workflow」触发节点,确认其暴露两个输入字段:`text`(字符串,用户自然语言指令)和 `sessionid`(字符串,用于会话隔离)。

  2. 配置 Google Calendar 凭证与日历

    分别打开三个 Google Calendar 工具节点(Get、Create、Delete)。在每个节点中选择你的 Google Calendar OAuth2 凭证,并将日历占位符(如 `[email protected]`)替换为实际日历 ID。Get 节点 operation 设为 getAll;Create 节点需保证 start、end、summary 字段由 AI 填充;Delete 节点 operation 设为 delete,需 eventId。

  3. 配置 AI Agent 并连接父工作流

    打开 AI Agent 节点,确认其 promptType 为 define,text 表达式为 `={{ $json.text }}`。将 OpenAI Chat Model(gpt-4.1-mini)和 Simple Memory(sessionKey 为 `={{ $json.sessionid }}`)分别连接到 AI Agent 的对应接口。将父工作流的 toolWorkflow 节点连接到本子工作流。

    运行提示词 · 来源原文。AI Agent 节点的 options.systemMessage 字段

    =You are a calendar assistant who can easily manage events in a google calendar. 
    You must provide the start and end date.
    
    If you need to create events in the calendar use the "Get" tool. To delete events in the calendar use "Delete", and to create events use the "Create" tool.
    
    the current date and time is {{ $now}}
    Additionally, you must provide the summary and other details for the calendar which your tool might need.

可复制提示词

搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限,再按步骤执行

这一段是提示词,页面不会在这里插入广告。

你正在搭建一个 n8n 子工作流,用于让 AI Agent 代理操作 Google Calendar。请先确认你已具备:1)OpenAI API 密钥;2)Google Calendar OAuth2 凭证;3)目标日历 ID。然后按步骤导入模板、配置三个工具节点的凭证与日历、设置 AI Agent 的 systemMessage,最后从父工作流发送测试指令验证 Get/Create/Delete 是否正常返回。

systemMessage 中的 "If you need to create events in the calendar use the 'Get' tool" 疑似原文笔误,实际应为 Create 工具;搭建时建议按工具实际用途理解

来源

Manage Google Calendar events with OpenAI Assistant (Get, create, delete) · ca7ai · n8n.io · 2025-08-24

留言与反馈

试过这个方法吗?分享效果、遇到的问题或改进建议。留言审核后公开,请勿填写敏感信息。

正在加载…

    相关用例