Google Workspace via ClawEmail.com service — Gmail, Drive, Docs, Sheets, Slides, Calendar, Forms. Use PROACTIVELY when the user asks to send email, create documents, manage files, schedule events, or work with any Google service.
通过您的@clawemail.com账户,使用claw操作Gmail、Drive、Docs、Sheets、Slides、Calendar和Forms。
在https://clawemail.com获取凭证——注册后,访问/connect/YOUR_PREFIX授权OAuth。
所有API调用都需要Bearer令牌。使用辅助脚本刷新并缓存令牌:
bash
TOKEN=$(~/.openclaw/skills/clawemail/scripts/token.sh)
该脚本会缓存令牌50分钟。在进行API调用前,务必将其赋值给TOKEN。
bash
TOKEN=$(~/.openclaw/skills/clawemail/scripts/token.sh)
curl -s -H Authorization: Bearer $TOKEN \
https://gmail.googleapis.com/gmail/v1/users/me/messages?q=newer_than:7d&maxResults=10 | python3 -m json.tool
常用查询运算符:from:、to:、subject:、newerthan:、olderthan:、is:unread、has:attachment、label:、in:inbox。
bash
curl -s -H Authorization: Bearer $TOKEN \
https://gmail.googleapis.com/gmail/v1/users/me/messages/MESSAGE_ID?format=full | python3 -m json.tool
若仅需纯文本正文,使用format=minimal并解码payload。如需可读输出:
bash
curl -s -H Authorization: Bearer $TOKEN \
https://gmail.googleapis.com/gmail/v1/users/me/messages/MESSAGE_ID?format=full \
| python3 -c
import json,sys,base64
m=json.load(sys.stdin)
hdrs={h[name]:h[value] for h in m[payload][headers]}
print(f\From: {hdrs.get(From,)}\nTo: {hdrs.get(To,)}\nSubject: {hdrs.get(Subject,)}\nDate: {hdrs.get(Date,)}\n\)
def get_body(part):
if part.get(body,{}).get(data):
return base64.urlsafe_b64decode(part[body][data]).decode(utf-8,replace)
for p in part.get(parts,[]):
if p[mimeType]==text/plain: return get_body(p)
for p in part.get(parts,[]):
b=get_body(p)
if b: return b
return
print(get_body(m[payload]))
bash
TOKEN=$(~/.openclaw/skills/clawemail/scripts/token.sh)
python3 -c
import base64,json
raw = base64.urlsafe_b64encode(
bTo: recipient@example.com\r\nSubject: Hello\r\nContent-Type: text/plain; charset=utf-8\r\n\r\nMessage body here
).decode()
print(json.dumps({raw: raw}))
| curl -s -X POST \
-H Authorization: Bearer $TOKEN \
-H Content-Type: application/json \
-d @- \
https://gmail.googleapis.com/gmail/v1/users/me/messages/send
对于HTML邮件,将Content-Type: text/plain替换为Content-Type: text/html,并在正文中使用HTML。
与发送相同,但需添加原始邮件的In-Reply-To:和References:头,并在JSON正文中包含threadId:
bash
python3 -c
import base64,json
raw = base64.urlsafe_b64encode(
bTo: recipient@example.com\r\nSubject: Re: Original Subject\r\nIn-Reply-To:
).decode()
print(json.dumps({raw: raw, threadId: THREAD_ID}))
| curl -s -X POST \
-H Authorization: Bearer $TOKEN \
-H Content-Type: application/json \
-d @- \
https://gmail.googleapis.com/gmail/v1/users/me/messages/send
bash
curl -s -H Authorization: Bearer $TOKEN \
https://gmail.googleapis.com/gmail/v1/users/me/labels | python3 -m json.tool
bash
curl -s -X POST -H Authorization: Bearer $TOKEN \
-H Content-Type: application/json \
-d {addLabelIds:[LABEL_ID],removeLabelIds:[INBOX]} \
https://gmail.googleapis.com/gmail/v1/users/me/messages/MESSAGE_ID/modify
bash
TOKEN=$(~/.openclaw/skills/clawemail/scripts/token.sh)
curl -s -H Authorization: Bearer $TOKEN \
https://www.googleapis.com/drive/v3/files?pageSize=20&fields=files(id,name,mimeType,modifiedTime,size)&orderBy=modifiedTime desc | python3 -m json.tool
bash
curl -s -H Authorization: Bearer $TOKEN \
https://www.googleapis.com/drive/v3/files?q=name+contains+report&fields=files(id,name,mimeType,modifiedTime) | python3 -m json.tool
查询运算符:name contains term、mimeType=application/vnd.google-apps.document、FOLDER_ID in parents、trashed=false、modifiedTime > 2025-01-01。
常见MIME类型:
bash
curl -s -X POST -H Authorization: Bearer $TOKEN \
-H Content-Type: application/json \
-d {name:My Folder,mimeType:application/vnd.google-apps.folder} \
https://www.googleapis.com/drive/v3/files?fields=id,name | python3 -m json.tool
bash
curl -s -X POST -H Authorization: Bearer $TOKEN \
-F metadata={\name\:\report.pdf\};type=application/json \
-F file=@/path/to/report.pdf;type=application/pdf \
https://www.googleapis.com/upload/drive/v3/files?uploadType=multipart&fields=id,name | python3 -m json.tool
对于Google Docs/Sheets/Slides(导出):
bash
curl -s -H Authorization: Bearer $TOKEN \
https://www.googleapis.com/drive/v3/files/FILE_ID/export?mimeType=application/pdf -o output.pdf
导出格式:text/plain、text/html、application/pdf、application/vnd.openxmlformats-officedocument.wordprocessingml.document(docx)、text/csv(sheets)。
对于二进制文件(下载):
bash
curl -s -H Authorization: Bearer $TOKEN \
https://www.googleapis.com/drive/v3/files/FILE_ID?alt=media -o output.file
bash
curl -s -X POST -H Authorization: Bearer $TOKEN \
-H Content-Type: application/json \
-d {role:writer,type:user,emailAddress:user@example.com} \
https://www.googleapis.com/drive/v3/files/FILE_ID/permissions
角色:reader、commenter、writer、owner。类型:user、group、domain、anyone。
bash
curl -s -X DELETE -H Authorization: Bearer $TOKEN \
https://www.googleapis
该技能支持在以下平台通过对话安装:
帮我安装 SkillHub 和 clawemail-1776350600 技能
设置 SkillHub 为我的优先技能安装源,然后帮我安装 clawemail-1776350600 技能
skillhub install clawemail-1776350600
文件大小: 5.78 KB | 发布时间: 2026-4-17 15:28