Google 日历集成
让你的代理通过 Google 日历管理日历事件、日程和可用性。借助 AI 驱动的自动化,创建和更新事件、管理参与者、检查可用性,并简化你的排期工作流。
在使用 Google 日历集成前,请确保你已经具备:
- 一个拥有有效订阅的 CrewAI AMP 账号
- 一个可访问 Google 日历的 Google 账号
- 已通过 集成页面 连接你的 Google 账号
配置 Google 日历集成
Section titled “配置 Google 日历集成”1. 连接你的 Google 账号
Section titled “1. 连接你的 Google 账号”- 进入 CrewAI AMP Integrations
- 在身份验证集成部分找到 Google Calendar
- 点击 Connect 并完成 OAuth 流程
- 授予日历访问所需的权限
- 从 Integration Settings 复制你的 Enterprise Token
2. 安装所需包
Section titled “2. 安装所需包”uv add crewai-tools3. 环境变量设置
Section titled “3. 环境变量设置”export CREWAI_PLATFORM_INTEGRATION_TOKEN="your_enterprise_token"或者将其添加到你的 .env 文件中:
CREWAI_PLATFORM_INTEGRATION_TOKEN=your_enterprise_tokengoogle_calendar/get_availability
描述: 获取日历可用性(空闲/忙碌信息)。
参数:
timeMin(string, required): 开始时间(RFC3339 格式)timeMax(string, required): 结束时间(RFC3339 格式)items(array, required): 要检查的日历 ID[{"id": "calendar_id"}]timeZone(string, optional): 响应中使用的时区。默认值为 UTC。groupExpansionMax(integer, optional): 单个组可提供的日历标识符最大数量。最大值:100calendarExpansionMax(integer, optional): 可提供 FreeBusy 信息的日历最大数量。最大值:50
google_calendar/create_event
描述: 在指定日历中创建新事件。
参数:
calendarId(string, required): 日历 ID(主日历使用'primary')summary(string, required): 事件标题/摘要start_dateTime(string, required): RFC3339 格式的开始时间(例如:2024-01-20T10:00:00-07:00)end_dateTime(string, required): RFC3339 格式的结束时间description(string, optional): 事件描述timeZone(string, optional): 时区(例如:America/Los_Angeles)location(string, optional): 事件的地理位置,使用自由文本。attendees(array, optional): 事件参与者列表。[{"displayName": "Attendee Name","optional": false}]reminders(object, optional): 有关事件提醒的信息。{"useDefault": true,"overrides": [{"method": "email","minutes": 15}]}conferenceData(object, optional): 与会议相关的信息,例如 Google Meet 会议详情。{"createRequest": {"requestId": "unique-request-id","conferenceSolutionKey": {"type": "hangoutsMeet"}}}visibility(string, optional): 事件可见性。可选项:default, public, private, confidential。默认值:defaulttransparency(string, optional): 事件是否会在日历上阻塞时间。可选项:opaque, transparent。默认值:opaque
google_calendar/view_events
描述: 检索指定日历的事件。
参数:
calendarId(string, required): 日历 ID(主日历使用'primary')timeMin(string, optional): 事件下限时间(RFC3339)timeMax(string, optional): 事件上限时间(RFC3339)maxResults(integer, optional): 最大事件数(默认 10)。最小值:1,最大值:2500orderBy(string, optional): 结果中返回事件的排序方式。可选项:startTime, updated。默认值:startTimesingleEvents(boolean, optional): 是否将重复事件展开为实例,并仅返回单次事件和重复事件的实例。默认值:trueshowDeleted(boolean, optional): 是否在结果中包含已删除事件(状态为 cancelled)。默认值:falseshowHiddenInvitations(boolean, optional): 是否在结果中包含隐藏邀请。默认值:falseq(string, optional): 用于查找匹配这些条件的事件的自由文本搜索词。pageToken(string, optional): 指定要返回哪个结果页的令牌。timeZone(string, optional): 响应中使用的时区。updatedMin(string, optional): 事件最后修改时间的下限(RFC3339),用于筛选。iCalUID(string, optional): 指定要在响应中提供的 iCalendar 格式事件 ID。
google_calendar/update_event
描述: 更新现有事件。
参数:
calendarId(string, required): 日历 IDeventId(string, required): 要更新的事件 IDsummary(string, optional): 更新后的事件标题description(string, optional): 更新后的事件描述start_dateTime(string, optional): 更新后的开始时间end_dateTime(string, optional): 更新后的结束时间
google_calendar/delete_event
描述: 删除指定事件。
参数:
calendarId(string, required): 日历 IDeventId(string, required): 要删除的事件 ID
google_calendar/view_calendar_list
描述: 检索用户的日历列表。
参数:
maxResults(integer, optional): 单个结果页返回的最大条目数。最小值:1pageToken(string, optional): 指定要返回哪个结果页的令牌。showDeleted(boolean, optional): 是否在结果中包含已删除的日历列表条目。默认值:falseshowHidden(boolean, optional): 是否显示隐藏条目。默认值:falseminAccessRole(string, optional): 返回条目中用户的最低访问角色。可选项:freeBusyReader, owner, reader, writer
基础日历代理设置
Section titled “基础日历代理设置”from crewai import Agent, Task, Crew
# Create an agent with Google Calendar capabilitiescalendar_agent = Agent( role="Schedule Manager", goal="Manage calendar events and scheduling efficiently", backstory="An AI assistant specialized in calendar management and scheduling coordination.", apps=['google_calendar'] # All Google Calendar actions will be available)
# Task to create a meetingcreate_meeting_task = Task( description="Create a team standup meeting for tomorrow at 9 AM with the development team", agent=calendar_agent, expected_output="Meeting created successfully with Google Meet link")
# Run the taskcrew = Crew( agents=[calendar_agent], tasks=[create_meeting_task])
crew.kickoff()筛选特定日历工具
Section titled “筛选特定日历工具”meeting_coordinator = Agent( role="Meeting Coordinator", goal="Coordinate meetings and check availability", backstory="An AI assistant that focuses on meeting scheduling and availability management.", apps=['google_calendar/create_event', 'google_calendar/get_availability'])
# Task to schedule a meeting with availability checkschedule_meeting = Task( description="Check availability for next week and schedule a project review meeting with stakeholders", agent=meeting_coordinator, expected_output="Meeting scheduled after checking availability of all participants")
crew = Crew( agents=[meeting_coordinator], tasks=[schedule_meeting])
crew.kickoff()事件管理与更新
Section titled “事件管理与更新”from crewai import Agent, Task, Crew
event_manager = Agent( role="Event Manager", goal="Manage and update calendar events efficiently", backstory="An experienced event manager who handles event logistics and updates.", apps=['google_calendar'])
# Task to manage event updatesevent_management = Task( description=""" 1. List all events for this week 2. Update any events that need location changes to include video conference links 3. Check availability for upcoming meetings """, agent=event_manager, expected_output="Weekly events updated with proper locations and availability checked")
crew = Crew( agents=[event_manager], tasks=[event_management])
crew.kickoff()