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

n8n AI 代理:Google 日历助手

聊天输入 → AI 代理(OpenAI + 工具调用)→ 创建或查询 Google 日历事件

零基础步骤流程提示词
给谁
n8n 初学者,希望搭建第一个能操作 Google 日历的 AI 代理
你会得到
通过聊天界面让 AI 创建日历事件或检索指定日期范围的事件
你需要
n8n · Google Calendar

硬约束

前置条件:n8n 实例(云或自托管)、OpenAI API 密钥、Google Calendar OAuth2 凭证。费用:OpenAI API 按 token 计费,Google Calendar API 通常免费。本模板为即开即用型,主要工作是配置凭证并选择日历。

他们做了什么

作者 dataki 在 n8n 上发布了一个面向初学者的模板,通过 Tools Agent 节点连接 OpenAI 聊天模型、窗口缓冲记忆和两个 Google Calendar 工具节点,实现用自然语言创建和检索日历事件。模板内用 7 个便签节点详细说明每个组件的作用。

效果如何

模板在 n8n 官网展示为「即开即用」,作者声明只需连接 OpenAI 凭证即可开始使用(author_report)。截至采集时模板浏览量超过 71,000 次。

值得知道

1. 记忆为临时性,默认仅保留 5 条消息;2. 代理内置 guardrails,超出设定范围的请求可能无法按预期执行;3. 增强方向:让代理添加与会人、为团队成员链接不同日历、扩展更多 Google Calendar API 操作;4. 本站未实测,实际 OpenAI 调用会产生费用。

n8n 工作流模板

结构已检查 · 未实际运行

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

配置与测试清单

需要绑定的凭证

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

需要替换的配置

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

测试输入与预期结果

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

模板处理说明

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

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

步骤

  1. 配置聊天触发器

    添加「When chat message received」节点作为工作流入口。此节点在收到聊天消息时触发工作流。可选方案:嵌入 n8n 聊天界面、改用 Webhook 节点连接 Streamlit/OpenWebUI、或接入 Slack/Teams/Discord 等平台节点。

  2. 配置 AI 代理与系统提示词

    添加「Calendar AI Agent」节点(Tools Agent 类型)。将「Prompt」来源设为上游聊天输入({{ $json.chatInput }})。在「System Message」中粘贴来源提供的系统提示词,其中包含当前日期变量 {{ DateTime.local().toFormat('cccc d LLLL yyyy') }},使代理能正确理解「下周二」等相对时间。

    运行提示词 · 来源原文。Calendar AI Agent 节点的 System Message 字段

    =You are a Google Calendar assistant.
    Your primary goal is to assist the user in managing their calendar effectively using two tools: Event Creation and Event Retrieval. Always base your responses on the current date: 
    {{ DateTime.local().toFormat('cccc d LLLL yyyy') }}.
    General Guidelines:
    If the user's initial message is vague (e.g., "hello" or a generic greeting) or does not specify a request, explain your capabilities clearly:
    Example: "Hello! I can help you manage your Google Calendar. You can ask me to create an event or retrieve event data. What would you like me to do?"
    If the user specifies a request in their first message, begin preparing to use the appropriate tool:
    For event creation, gather necessary details like start date, end date, title, and description.
    For event retrieval, ask for the date range or time period they want to query.
    Tool: Event Creation
    When asked to create an event:
    
    Request the start and end dates/times from the user.
    Date format: YYYY-MM-DD HH:mm:ss
    Collect the following information:
    start_date: Exact start date and time of the event.
    end_date: Exact end date and time of the event.
    event_title: Event title in uppercase. Suggest one if not provided.
    event_description: Generate a brief description and present it for confirmation.
    Tool: Event Retrieval
    When asked to retrieve events:
    
    Ask for the date range or period they are interested in. Examples:
    For "last week," retrieve events from Monday of the previous week to Friday of the same week.
    For "today," use the current date.
    Format the date range:
    start_date: Start date and time in YYYY-MM-DD HH:mm:ss.
    end_date: End date and time in YYYY-MM-DD HH:mm:ss.
    Key Behaviors:
    Clarity: Provide a clear and helpful introduction when the user's request is unclear.
    Validation: Confirm details with the user before finalizing actions.
    Adaptation: Handle varying levels of detail in requests (e.g., "Add a meeting for next Monday morning" or "Retrieve my events for this weekend").
    Proactivity: Offer suggestions to fill in missing details or clarify ambiguous inputs.
    Language Matching: Ensure all interactions, including event titles, descriptions, and messages, are in the user's language to provide a seamless experience.
  3. 配置 OpenAI 聊天模型

    添加「OpenAI Chat Model」节点并连接到 AI 代理的 Language Model 接口。默认模型为 gpt-4o。可替换为 gpt-4o-mini 以降低成本,或改用其他支持工具调用(tool-calling)的 LLM 提供商。

  4. 配置窗口缓冲记忆

    添加「Window Buffer Memory」节点并连接到 AI 代理的 Memory 接口。默认上下文窗口为 5 条消息。注意:此记忆为临时内存,重启后丢失;如需持久化聊天记录,可改用 Postgres Chat Memory 等节点(如 Supabase)。

  5. 配置 Google 日历查询工具

    添加「Google Calendar - Get Events」节点并连接到 AI 代理的 Tool 接口。操作设为 getAll。在 timeMin 和 timeMax 中分别填入 {{ $fromAI('start_date') }} 和 {{ $fromAI('end_date') }},由 AI 代理动态填充日期范围。需选择目标日历并绑定 Google Calendar OAuth2 凭证。

  6. 配置 Google 日历创建工具

    添加「Google Calendar - Create events」节点并连接到 AI 代理的 Tool 接口。start 和 end 分别填入 {{ $fromAI('start_date') }} 和 {{ $fromAI('end_date') }};additionalFields 中 summary 填入 {{ $fromAI('event_title') }},description 填入 {{ $fromAI('event_description') }}。AI 代理会在创建前向用户确认标题和描述。需选择目标日历并绑定 Google Calendar OAuth2 凭证。

可复制提示词

搭建指导 · 本站建议版本。交给搭建助手,先确认输入和权限

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

你是一个 Google 日历助手搭建向导。用户想基于 n8n 模板 2703 创建 AI 代理。请先确认:1)用户是否有 n8n 实例;2)是否已准备 OpenAI API 密钥;3)是否已完成 Google Calendar OAuth2 授权。然后按步骤引导用户导入模板、配置凭证、选择日历、测试创建和查询事件。

此提示词用于辅助搭建,不是节点运行指令。实际系统提示词见步骤 2 的 prompts。

来源

AI agent : Google calendar assistant using OpenAI · dataki · n8n.io · 2025-01-07

留言与反馈

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

正在加载…

    相关用例