Google 幻灯片集成
让你的代理创建、编辑和管理 Google 幻灯片演示文稿。创建演示文稿、更新内容、从 Google 表格导入数据、管理页面和缩略图,并借助 AI 驱动的自动化简化你的演示工作流。
在使用 Google 幻灯片集成前,请确保你已经具备:
- 一个拥有有效订阅的 CrewAI AMP 账号
- 一个可访问 Google 幻灯片的 Google 账号
- 已通过 集成页面 连接你的 Google 账号
配置 Google 幻灯片集成
Section titled “配置 Google 幻灯片集成”1. 连接你的 Google 账号
Section titled “1. 连接你的 Google 账号”- 进入 CrewAI AMP Integrations
- 在身份验证集成部分找到 Google Slides
- 点击 Connect 并完成 OAuth 流程
- 授予演示文稿、电子表格和 Drive 访问所需的权限
- 从 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_slides/create_blank_presentation
描述: 创建一个空白演示文稿,不含任何内容。
参数:
title(string, required): 演示文稿标题。
google_slides/get_presentation_metadata
描述: 获取演示文稿的轻量级元数据(标题、幻灯片数量、幻灯片 ID)。在获取完整内容之前请先使用此操作。
参数:
presentationId(string, required): 要检索的演示文稿 ID。
google_slides/get_presentation_text
描述: 提取演示文稿中的所有文本内容。仅返回来自形状和表格的幻灯片 ID 和文本(不含格式)。
参数:
presentationId(string, required): 演示文稿 ID。
google_slides/get_presentation
描述: 通过 ID 检索演示文稿。
参数:
presentationId(string, required): 要检索的演示文稿 ID。fields(string, optional): 要包含在响应中的字段。使用此项可通过仅返回所需数据来提升性能。
google_slides/batch_update_presentation
描述: 对演示文稿应用更新、添加内容或移除内容。
参数:
presentationId(string, required): 要更新的演示文稿 ID。requests(array, required): 要应用于演示文稿的更新列表。[{"insertText": {"objectId": "slide_id","text": "Your text content here"}}]writeControl(object, optional): 提供对写入请求执行方式的控制。{"requiredRevisionId": "revision_id_string"}
google_slides/get_slide_text
描述: 提取单张幻灯片的文本内容。仅返回来自形状和表格的文本(不含格式或样式)。
参数:
presentationId(string, required): 演示文稿 ID。pageObjectId(string, required): 要获取文本的幻灯片/页面 ID。
google_slides/get_page
描述: 通过 ID 检索特定页面。
参数:
presentationId(string, required): 演示文稿 ID。pageObjectId(string, required): 要检索的页面 ID。
google_slides/get_thumbnail
描述: 生成页面缩略图。
参数:
presentationId(string, required): 演示文稿 ID。pageObjectId(string, required): 用于生成缩略图的页面 ID。
google_slides/create_slide
描述: 向演示文稿中添加一个额外的空白幻灯片。新建演示文稿本身已经有一张空白幻灯片 - 请先检查 get_presentation_metadata。对于带标题/正文区域的幻灯片,请改用 create_slide_with_layout。
参数:
presentationId(string, required): 演示文稿 ID。insertionIndex(integer, optional): 插入幻灯片的位置(从 0 开始)。如果省略,则添加到末尾。
google_slides/create_slide_with_layout
描述: 创建带有预定义布局的幻灯片,其中包含标题、正文等占位区域。这比用于结构化内容的 create_slide 更合适。创建后,使用 get_page 查找占位符 ID,然后将文本插入其中。
参数:
presentationId(string, required): 演示文稿 ID。layout(string, required): 布局类型。可选项:BLANK,TITLE,TITLE_AND_BODY,TITLE_AND_TWO_COLUMNS,TITLE_ONLY,SECTION_HEADER,ONE_COLUMN_TEXT,MAIN_POINT,BIG_NUMBER。TITLE_AND_BODY 最适合标题+描述。TITLE 适用于仅标题幻灯片。SECTION_HEADER 适用于分节页。insertionIndex(integer, optional): 插入位置(从 0 开始)。省略则添加到末尾。
google_slides/create_text_box
描述: 在幻灯片上创建带内容的文本框。适用于标题、描述、段落,不适用于表格。可选择在 EMU 单位中指定位置(x, y)和大小(width, height)(914400 EMU = 1 英寸)。
参数:
presentationId(string, required): 演示文稿 ID。slideId(string, required): 要添加文本框的幻灯片 ID。text(string, required): 文本框内容。x(integer, optional): EMU 单位中的 X 位置(914400 = 1 英寸)。默认值:914400(距左侧 1 英寸)。y(integer, optional): EMU 单位中的 Y 位置(914400 = 1 英寸)。默认值:914400(距顶部 1 英寸)。width(integer, optional): EMU 单位中的宽度。默认值:7315200(约 8 英寸)。height(integer, optional): EMU 单位中的高度。默认值:914400(约 1 英寸)。
google_slides/delete_slide
描述: 从演示文稿中移除一张幻灯片。请先使用 get_presentation 查找幻灯片 ID。
参数:
presentationId(string, required): 演示文稿 ID。slideId(string, required): 要删除的幻灯片对象 ID。从 get_presentation 获取。
google_slides/duplicate_slide
描述: 创建现有幻灯片的副本。副本会紧接在原始幻灯片之后插入。
参数:
presentationId(string, required): 演示文稿 ID。slideId(string, required): 要复制的幻灯片对象 ID。从 get_presentation 获取。
google_slides/move_slides
描述: 通过移动幻灯片到新位置来重新排序。幻灯片 ID 必须按其当前演示文稿顺序排列(不能重复)。
参数:
presentationId(string, required): 演示文稿 ID。slideIds(array of strings, required): 要移动的幻灯片 ID 数组。必须按当前演示文稿顺序排列。insertionIndex(integer, required): 目标位置(从 0 开始)。0 = 开头,幻灯片数量 = 末尾。
google_slides/insert_youtube_video
描述: 在幻灯片上嵌入 YouTube 视频。视频 ID 是 YouTube URL 中 “v=” 后面的值(例如,youtube.com/watch?v=abc123 时使用 "abc123")。
参数:
presentationId(string, required): 演示文稿 ID。slideId(string, required): 要添加视频的幻灯片 ID。从 get_presentation 获取。videoId(string, required): YouTube 视频 ID(URL 中 v= 后面的值)。
google_slides/insert_drive_video
描述: 在幻灯片上嵌入来自 Google Drive 的视频。文件 ID 可在 Drive 文件 URL 中找到。
参数:
presentationId(string, required): 演示文稿 ID。slideId(string, required): 要添加视频的幻灯片 ID。从 get_presentation 获取。fileId(string, required): 视频的 Google Drive 文件 ID。
google_slides/set_slide_background_image
描述: 为幻灯片设置背景图片。图片 URL 必须可公开访问。
参数:
presentationId(string, required): 演示文稿 ID。slideId(string, required): 要设置背景的幻灯片 ID。从 get_presentation 获取。imageUrl(string, required): 用作背景图片的可公开访问 URL。
google_slides/create_table
描述: 在幻灯片上创建一个空表格。若要创建含内容的表格,请改用 create_table_with_content。
参数:
presentationId(string, required): 演示文稿 ID。slideId(string, required): 要添加表格的幻灯片 ID。从 get_presentation 获取。rows(integer, required): 表格行数。columns(integer, required): 表格列数。
google_slides/create_table_with_content
描述: 一次性创建带内容的表格。将内容提供为二维数组,其中每个内部数组是一行。示例:[["Header1", "Header2"], ["Row1Col1", "Row1Col2"]]。
参数:
presentationId(string, required): 演示文稿 ID。slideId(string, required): 要添加表格的幻灯片 ID。从 get_presentation 获取。rows(integer, required): 表格行数。columns(integer, required): 表格列数。content(array, required): 以二维数组形式提供的表格内容。每个内部数组是一行。示例:[["Year", "Revenue"], ["2023", "$10M"]]。
google_slides/import_data_from_sheet
描述: 将 Google 表格中的数据导入到演示文稿。
参数:
presentationId(string, required): 演示文稿 ID。sheetId(string, required): 要导入的 Google 表格 ID。dataRange(string, required): 要从表格中导入的数据范围。
google_slides/upload_file_to_drive
描述: 上传与演示文稿关联到 Google Drive 的文件。
参数:
file(string, required): 要上传的文件数据。presentationId(string, required): 用于关联已上传文件的演示文稿 ID。
google_slides/link_file_to_presentation
描述: 将 Google Drive 中的文件链接到演示文稿。
参数:
presentationId(string, required): 演示文稿 ID。fileId(string, required): 要链接的文件 ID。
google_slides/get_all_presentations
描述: 列出用户可访问的所有演示文稿。
参数:
pageSize(integer, optional): 每页返回的演示文稿数量。pageToken(string, optional): 用于分页的令牌。
google_slides/delete_presentation
描述: 通过 ID 删除演示文稿。
参数:
presentationId(string, required): 要删除的演示文稿 ID。
基础 Google 幻灯片代理设置
Section titled “基础 Google 幻灯片代理设置”from crewai import Agent, Task, Crew
# Create an agent with Google Slides capabilitiesslides_agent = Agent( role="Presentation Manager", goal="Create and manage presentations efficiently", backstory="An AI assistant specialized in presentation creation and content management.", apps=['google_slides'] # All Google Slides actions will be available)
# Task to create a presentationcreate_presentation_task = Task( description="Create a new presentation for the quarterly business review with key slides", agent=slides_agent, expected_output="Quarterly business review presentation created with structured content")
# Run the taskcrew = Crew( agents=[slides_agent], tasks=[create_presentation_task])
crew.kickoff()演示文稿内容管理
Section titled “演示文稿内容管理”from crewai import Agent, Task, Crew
content_manager = Agent( role="Content Manager", goal="Manage presentation content and updates", backstory="An AI assistant that focuses on content creation and presentation updates.", apps=[ 'google_slides/create_blank_presentation', 'google_slides/batch_update_presentation', 'google_slides/get_presentation' ])
# Task to create and update presentationscontent_task = Task( description="Create a new presentation and add content slides with charts and text", agent=content_manager, expected_output="Presentation created with updated content and visual elements")
crew = Crew( agents=[content_manager], tasks=[content_task])
crew.kickoff()数据集成与可视化
Section titled “数据集成与可视化”from crewai import Agent, Task, Crew
data_visualizer = Agent( role="Data Visualizer", goal="Create presentations with data imported from spreadsheets", backstory="An AI assistant that specializes in data visualization and presentation integration.", apps=['google_slides'])
# Task to create data-driven presentationsvisualization_task = Task( description=""" 1. Create a new presentation for monthly sales report 2. Import data from the sales spreadsheet 3. Create charts and visualizations from the imported data 4. Generate thumbnails for slide previews """, agent=data_visualizer, expected_output="Data-driven presentation created with imported spreadsheet data and visualizations")
crew = Crew( agents=[data_visualizer], tasks=[visualization_task])
crew.kickoff()演示文稿库管理
Section titled “演示文稿库管理”from crewai import Agent, Task, Crew
library_manager = Agent( role="Presentation Library Manager", goal="Manage and organize presentation libraries", backstory="An AI assistant that manages presentation collections and file organization.", apps=['google_slides'])
# Task to manage presentation librarylibrary_task = Task( description=""" 1. List all existing presentations 2. Generate thumbnails for presentation previews 3. Upload supporting files to Drive and link to presentations 4. Organize presentations by topic and date """, agent=library_manager, expected_output="Presentation library organized with thumbnails and linked supporting files")
crew = Crew( agents=[library_manager], tasks=[library_task])
crew.kickoff()自动化演示文稿工作流
Section titled “自动化演示文稿工作流”from crewai import Agent, Task, Crew
presentation_automator = Agent( role="Presentation Automator", goal="Automate presentation creation and management workflows", backstory="An AI assistant that automates complex presentation workflows and content generation.", apps=['google_slides'])
# Complex presentation automation taskautomation_task = Task( description=""" 1. Create multiple presentations for different departments 2. Import relevant data from various spreadsheets 3. Update existing presentations with new content 4. Generate thumbnails for all presentations 5. Link supporting documents from Drive 6. Create a master index presentation with links to all others """, agent=presentation_automator, expected_output="Automated presentation workflow completed with multiple presentations and organized structure")
crew = Crew( agents=[presentation_automator], tasks=[automation_task])
crew.kickoff()模板与内容创建
Section titled “模板与内容创建”from crewai import Agent, Task, Crew
template_creator = Agent( role="Template Creator", goal="Create presentation templates and standardized content", backstory="An AI assistant that creates consistent presentation templates and content standards.", apps=['google_slides'])
# Task to create templatestemplate_task = Task( description=""" 1. Create blank presentation templates for different use cases 2. Add standard layouts and content placeholders 3. Create sample presentations with best practices 4. Generate thumbnails for template previews 5. Upload template assets to Drive and link appropriately """, agent=template_creator, expected_output="Presentation templates created with standardized layouts and linked assets")
crew = Crew( agents=[template_creator], tasks=[template_task])
crew.kickoff()权限错误
- 确保你的 Google 账号具有 Google 幻灯片所需的适当权限
- 验证 OAuth 连接是否包含演示文稿、电子表格和 Drive 访问所需的作用域
- 检查演示文稿是否已与你已认证的账号共享
演示文稿 ID 问题
- 验证演示文稿 ID 是否正确且演示文稿确实存在
- 确保你对要修改的演示文稿拥有访问权限
- 检查演示文稿 ID 格式是否正确
内容更新问题
- 确保 batch update 请求按照 Google Slides API 规范正确格式化
- 验证幻灯片和元素的对象 ID 是否存在于演示文稿中
- 如果使用乐观并发,请检查写控制修订 ID 是否为最新
数据导入问题
- 验证 Google 表格 ID 是否正确且可访问
- 确保数据范围使用 A1 表示法正确指定
- 检查你是否对源电子表格具有读取权限
文件上传和链接问题
- 确保文件数据在上传前已正确编码
- 链接文件时验证 Drive 文件 ID 是否正确
- 检查你是否具有文件操作所需的适当 Drive 权限
页面和缩略图操作
- 验证页面对象 ID 是否存在于指定演示文稿中
- 在尝试生成缩略图前确保演示文稿已有内容
- 检查页面结构是否适合缩略图生成
分页和列表问题
- 列出演示文稿时使用合适的 page size
- 对大型结果集使用 page token 正确分页
- 对空结果集进行妥善处理
需要帮助?
如需 Google 幻灯片集成设置或故障排查方面的帮助,请联系我们的支持团队。