> This is a page from the ElevenLabs documentation. For a complete page index, fetch https://elevenlabs.io/docs/llms.txt. For the full documentation in a single file, fetch https://elevenlabs.io/docs/llms-full.txt.

# Google Calendar

## 概述

将 ElevenLabs AI 智能体连接到 [Google Calendar](https://calendar.google.com)，管理日程和日历预约。通过此集成，智能体可通过自然对话查看可用时间、创建、更新和删除包含参会者及可选 Google Meet 会议的活动，列出即将开始的活动，并发现可访问的日历。

## 功能

| 功能         | 支持情况         |
| ---------- | ------------ |
| 零保留模式（ZRM） | 不支持          |
| 工具中的附件     | 不支持——工具仅处理文本 |

## 安全警告

> **安全警告：`google_calendar_update_event` 和 `google_calendar_delete_event` 是特权工具。** 它们拥有所连接 Google 账户的完整日历访问权限，而不只是智能体创建活动的访问权限。任何可与智能体交谈的人都能更改或取消该日历中的**任何**活动，包括并非其创建的活动，因为智能体可通过 `google_calendar_list_events` 查找活动 ID。系统提示词中的确认只是给模型的提示，并非安全控制措施。
>
> 仅在**已启用身份验证**的智能体上启用这些工具，或仅在活动 ID 来自可信来源时启用。请勿将它们添加到公开智能体。活动更新或删除时，始终会通知参会者。

## 设置

此集成使用 **Google OAuth 2.0** 进行身份验证。你将授权 ElevenLabs 代表你访问 Google Calendar。

#### 在 ElevenLabs 中点击连接

在 ElevenLabs 集成设置中，点击 **连接**。系统会跳转至 Google 以授权访问。

#### 选择 Google 账户

选择智能体应访问其日历数据的 Google 账户。如果浏览器已登录多个 Google 账户，请选择正确的账户。

#### 授权访问日历

查看所请求的权限，然后点击 **允许**。此集成会请求管理你拥有日历中活动的权限、查看日历列表的权限，以及查看忙闲信息的权限。

## OAuth 范围

此集成会请求以下 Google OAuth 2.0 范围：

| 范围                               | 用途                    |
| -------------------------------- | --------------------- |
| `calendar.events.owned`          | 创建、读取、更新和删除你拥有日历中的活动。 |
| `calendar.calendarlist.readonly` | 查看账户可访问的日历列表（名称和 ID）。 |
| `calendar.freebusy`              | 查看跨日历的忙闲情况，不会暴露活动详情。  |

## 工作原理

智能体通过工具调用逐步完成预约流程。下方标签页展示高级概述和详细系统提示词。

#### 高级概述

#### 发现日历

智能体会列出可访问的日历，以确定用于安排日程的正确日历。对大多数用户而言，这就是主日历。

#### 查看可用时间

智能体会通过以下方式查看忙闲情况：

* 使用 `google_calendar_check_availability` 工具查询繁忙时间段。
* 确认请求的时间是否空闲。
* 如果请求时间与现有活动冲突，则建议其他时间。
* 与来电者确认选定时间。

#### 收集参会者信息

确定时间后，智能体会：

* 收集参会者的全名和邮箱地址。
* 向来电者复述邮箱以确认。
* 核实时区信息。

#### 创建活动

智能体会：

* 使用确认的信息调用 `google_calendar_create_event` 工具。
* 如需视频会议，可选择添加 Google Meet 链接。
* 确认活动已创建，并告知参会者将收到日历邀请。

#### 详细系统提示词

```
You are a helpful scheduling assistant responsible for managing calendar bookings using Google Calendar. Be friendly, precise, and concise.

Begin by briefly asking for the purpose of the meeting and the caller's preferred date and time.
Then, ask about the desired meeting duration (15, 30, or 60 minutes), and wait for the user's response before proceeding.

Once you have the meeting details, check calendar availability:
- Call google_calendar_check_availability with the appropriate time range and calendar ID (use 'primary' for the main calendar)
- The tool returns busy time blocks — any time not listed as busy is available
- If the requested time overlaps with a busy block, suggest alternative times
- Continue until a suitable time is agreed upon

After confirming a time slot, gather the following contact details:
- The attendee's full name
- A valid email address. Note that the email address is transcribed from voice, so ensure it is formatted correctly.
- The attendee's time zone (in 'Continent/City' format like 'America/New_York')
- Read the email back to the caller to confirm accuracy

Once all details are confirmed, create the event:
- Call google_calendar_create_event with calendarId set to 'primary'
- Set summary to a descriptive meeting title
- Set start and end times in RFC 3339 format with the attendee's time zone
- Add the attendee's email to the attendees array
- If the caller requests a video call, include conferenceData with conferenceSolutionKey type 'hangoutsMeet' and set the conferenceDataVersion query parameter to 1
- Set sendUpdates to 'all' so attendees receive calendar invitations

Thank the attendee and inform them they will receive a calendar invitation shortly.

Clarifications:
- Do not inform the user that you are formatting the email; do it silently.
- If the caller asks you to proceed with booking, do so with the existing information.
- Use google_calendar_list_calendars if the caller asks to schedule on a specific calendar other than their primary one.
- Use google_calendar_list_events if the caller asks what meetings they have coming up, or to find the event ID before changing or cancelling a meeting.
- Use google_calendar_update_event to reschedule or edit an existing event. Check availability for the new time first, and confirm the change with the caller.
- Use google_calendar_delete_event to cancel an event only after the caller has explicitly confirmed which event to cancel. For recurring events, confirm whether to cancel one occurrence or the whole series: list events with singleEvents=true and use the occurrence's ID for one occurrence, or its recurringEventId for the whole series.

Guardrails:
- Do not share any internal IDs or API details with the caller.
- If event creation fails, check for formatting issues in the email or time conflicts.
```

## 智能体工具

向智能体添加 Google Calendar 工具后，可使用以下内置工具：

| 工具                                   | 说明                                                                                           |
| ------------------------------------ | -------------------------------------------------------------------------------------------- |
| `google_calendar_check_availability` | 查看一个或多个日历在指定时间范围内的忙闲情况。返回繁忙时间段，以便智能体找到空闲时段。创建活动前使用此工具，避免冲突。                                  |
| `google_calendar_create_event`       | 在 Google Calendar 中创建新活动，可选择添加参会者、地点和 Google Meet 会议。会向所有参与者发送邮件通知。                          |
| `google_calendar_list_events`        | 列出日历在指定时间范围内即将开始的活动，并按开始时间排序。支持在活动摘要、描述、地点和参会者详情中进行自由文本搜索。                                   |
| `google_calendar_update_event`       | **特权。** 更新日历中的任何活动，例如重新安排时间，或修改标题、地点或参会者。仅会修改提供的字段。会通知参会者。                                   |
| `google_calendar_delete_event`       | **特权。** 删除日历中的任何活动，并为所有参会者取消该活动。请先列出活动以查找活动 ID。对于定期活动，请使用某次活动的 ID 或其 recurringEventId（整个系列）。 |
| `google_calendar_list_calendars`     | 列出所连接 Google 账户可访问的所有日历。返回日历名称和 ID。请在查看可用时间或创建活动前使用此工具，以确定目标日历。                              |

## 实用链接

* [Google Calendar API 文档](https://developers.google.com/calendar/api/v3/reference)
* [Calendar 的 Google OAuth 2.0 范围](https://developers.google.com/identity/protocols/oauth2/scopes#calendar)
* [Google Calendar API 快速入门](https://developers.google.com/calendar/api/quickstart/python)
* [ElevenLabs 工具概述](/docs/zh/eleven-agents/customization/tools/server-tools)