Google Suite 技能:自动化 Gmail、日历和云端硬盘 - Openclaw Skills

作者:互联网

2026-03-31

AI教程

什么是 Google Suite 技能?

Google Suite 技能是 AI 智能体与 Google 生态系统之间的高性能桥梁。通过将此模块集成到 Openclaw Skills 中,开发者可以赋能其智能体直接与 Gmail、Google 日历和 Google 云端硬盘进行交互。这一统一接口简化了 OAuth2 身份验证和多服务 API 调用的复杂性,为构建智能自动化提供了流线型的开发体验。

无论您是构建虚拟助手还是后端自动化流水线,此技能都提供了必要的工具,用于在世界上最受欢迎的生产力平台上读取、写入和管理数据。它旨在保证安全、高效,并且可以轻松扩展到任何 Openclaw Skills 工作流中。

下载入口:https://github.com/openclaw/skills/tree/main/skills/cenralsolution/google-suite

安装与下载

1. ClawHub CLI

从源直接安装技能的最快方式。

npx clawhub@latest install google-suite

2. 手动安装

将技能文件夹复制到以下位置之一

全局模式 ~/.openclaw/skills/ 工作区 /skills/

优先级:工作区 > 本地 > 内置

3. 提示词安装

将此提示词复制到 OpenClaw 即可自动安装。

请帮我使用 Clawhub 安装 google-suite。如果尚未安装 Clawhub,请先安装(npm i -g clawhub)。

Google Suite 技能 应用场景

  • 通过在 Gmail 中读取、搜索和分类邮件,实现电子邮件管理自动化。
  • 直接在 Google 日历中安排和更新专业会议。
  • 通过在 Google 云端硬盘上上传、下载和搜索文件来管理公司资产。
  • 创建自动会议摘要,并在活动结束后立即通过电子邮件发送给与会者。
  • 根据自定义逻辑执行批量文件操作或电子邮件清理任务。
Google Suite 技能 工作原理
  1. 配置您的 Google Cloud 项目并启用 Gmail、日历和云端硬盘 API 以获取 OAuth2 凭据。
  2. 使用您的客户端 ID 和密钥在 Openclaw Skills 环境中初始化该技能。
  3. 执行初始身份验证流程,技能会提示授权访问所需的 Google 作用域。
  4. 将生成的 OAuth2 令牌存储在本地 JSON 文件中,以便在未来的会话中进行持久的非交互式访问。
  5. 向技能的 execute 方法发送结构化的 JSON 请求,以在集成的 Google 服务中执行特定操作。
  6. 处理从 Google API 返回的数据,以驱动进一步的智能体逻辑或响应生成。

Google Suite 技能 配置指南

要在您的 Openclaw Skills 项目中部署此技能,请确保已安装 Python 3.8+ 及必要的依赖项。

pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib

使用您的 Google Cloud OAuth2 凭据配置环境变量:

  • GOOGLE_OAUTH_CLIENT_ID
  • GOOGLE_OAUTH_CLIENT_SECRET
  • GOOGLE_OAUTH_REDIRECT_URI

Google Suite 技能 数据架构与分类体系

该技能通过以下数据结构管理其状态和通信:

组件 详情
令牌存储 令牌保存在 google_suite_tokens.json 中以便持久访问。
服务类型 支持的服务包括 'gmail'、'calendar' 和 'drive'。
操作映射 每个服务都支持如 'list'、'send'、'create'、'upload' 或 'delete' 等操作。
作用域 利用特定的 OAuth2 作用域在 Google 服务中读取和修改用户数据。

Google Suite Skill

Version: 1.0.0 Category: Productivity Description: Unified access to Gmail, Google Calendar, and Google Drive APIs for sending, reading, deleting emails, managing calendar events, and handling files.

Features

Gmail

  • Send emails
  • Read emails (list, search, get details)
  • Delete emails
  • Mark as read/unread

Google Calendar

  • List events
  • Create events
  • Update events
  • Delete events

Google Drive

  • List files
  • Upload files
  • Download files
  • Delete files
  • Search files

Setup

Prerequisites

  • Python 3.8+
  • Google Cloud project with OAuth2 credentials
  • Enable Gmail, Calendar, and Drive APIs in Google Cloud Console

Environment Variables

  • GOOGLE_OAUTH_CLIENT_ID - OAuth2 client ID
  • GOOGLE_OAUTH_CLIENT_SECRET - OAuth2 client secret
  • GOOGLE_OAUTH_REDIRECT_URI - OAuth2 redirect URI (e.g., http://localhost:8080/callback)

Required Scopes

  • https://www.googleapis.com/auth/gmail.readonly
  • https://www.googleapis.com/auth/gmail.send
  • https://www.googleapis.com/auth/gmail.modify
  • https://www.googleapis.com/auth/calendar
  • https://www.googleapis.com/auth/drive

Token Storage

  • Tokens are stored in google_suite_tokens.json (by default)

Installation

pip install --upgrade google-api-python-client google-auth-httplib2 google-auth-oauthlib

Usage

Authentication

  1. On first use, the skill will prompt for OAuth2 authentication.
  2. Visit the provided URL, log in, and paste the authorization code.
  3. Tokens will be saved for future use.

Example Calls

Send Email

skill.execute({
    "service": "gmail",
    "action": "send",
    "to": "user@example.com",
    "subject": "Test Email",
    "body": "Hello from OpenClaw!"
})

List Emails

skill.execute({
    "service": "gmail",
    "action": "list",
    "query": "from:boss@company.com"
})

Delete Email

skill.execute({
    "service": "gmail",
    "action": "delete",
    "message_id": "XYZ123..."
})

List Calendar Events

skill.execute({
    "service": "calendar",
    "action": "list",
    "days": 7
})

Create Calendar Event

skill.execute({
    "service": "calendar",
    "action": "create",
    "summary": "Team Meeting",
    "start": "2024-03-01T10:00:00",
    "end": "2024-03-01T11:00:00"
})

List Drive Files

skill.execute({
    "service": "drive",
    "action": "list",
    "query": "name contains 'report'"
})

Upload File to Drive

skill.execute({
    "service": "drive",
    "action": "upload",
    "file_path": "./myfile.pdf"
})

Security

  • OAuth2 tokens are stored securely and never logged.
  • All credentials are loaded from environment variables.
  • No sensitive data is printed or logged.

Troubleshooting

  • Ensure all required APIs are enabled in Google Cloud Console.
  • Check that OAuth2 credentials are correct and match the redirect URI.
  • Delete google_suite_tokens.json to force re-authentication if needed.

References

  • Google API Python Client
  • Gmail API Docs
  • Calendar API Docs
  • Drive API Docs