Calendar Crab
Google Calendar management via a single Node.js script. No npm install needed.
Prerequisites
- - Node.js 18+
- Google Cloud project with Calendar API enabled
- OAuth credentials + refresh token saved to
~/.openclaw/secrets/ (see Setup below)
Commands
List upcoming events
CODEBLOCK0
Create an event
CODEBLOCK1
Move an event
CODEBLOCK2
Delete an event
CODEBLOCK3
Configuration
| Env var | Default | Description |
|---|
| INLINECODE1 | INLINECODE2 | Directory containing OAuth + token JSON files |
| INLINECODE3 |
System local | Default timezone for events |
|
CALENDAR_CRAB_CALENDAR |
primary | Google Calendar ID |
Timezone can also be set per-command with --tz=America/Los_Angeles.
Execution rules
- 1. Always
list first to verify the target event exists and is unique. - INLINECODE8 and
delete auto-notify all attendees (sendUpdates=all). - On failure, the raw Google API error is returned for debugging.
Setup
- 1. Go to Google Cloud Console and create a project.
- Enable the Google Calendar API.
- Create OAuth 2.0 credentials (Desktop app type).
- Save the credentials as
~/.openclaw/secrets/google-calendar-oauth.json:
{
"client_id": "YOUR_CLIENT_ID",
"client_secret": "YOUR_CLIENT_SECRET"
}
- 5. Obtain a refresh token via the OAuth flow and save as
~/.openclaw/secrets/google-calendar-token.json:
{
"refresh_token": "YOUR_REFRESH_TOKEN",
"access_token": "",
"expires_in": 0,
"obtained_at": ""
}
The script auto-refreshes the access token using the refresh token.
Calendar Crab
通过单个Node.js脚本管理Google日历。无需npm安装。
前置条件
- - Node.js 18+
- 已启用Calendar API的Google Cloud项目
- 保存至~/.openclaw/secrets/的OAuth凭据及刷新令牌(参见下方设置)
命令
列出即将开始的事件
bash
node calendar-crab.js list --days=7 --max=20
创建事件
bash
node calendar-crab.js create \
--title=团队同步 \
--date=2026-03-20 \
--time=10:00 \
--duration=30 \
--location=Zoom \
--attendees=alice@co.com,bob@co.com \
--description=每周同步 \
--tz=America/Los_Angeles
移动事件
bash
按日期+时间
node calendar-crab.js move --date=2026-03-20 --from=10:00 --to=14:00
按事件ID
node calendar-crab.js move --id=EVENT_ID --to=2026-03-20T14:00:00-07:00
删除事件
bash
node calendar-crab.js delete --id=EVENT_ID
node calendar-crab.js delete --date=2026-03-20 --time=10:00
配置
| 环境变量 | 默认值 | 描述 |
|---|
| CALENDARCRABSECRETS | ~/.openclaw/secrets | 包含OAuth及令牌JSON文件的目录 |
| CALENDARCRABTZ |
系统本地时区 | 事件的默认时区 |
| CALENDAR
CRABCALENDAR | primary | Google日历ID |
时区也可通过--tz=America/Los_Angeles在每个命令中单独设置。
执行规则
- 1. 始终先执行list以确认目标事件存在且唯一。
- move和delete会自动通知所有参与者(sendUpdates=all)。
- 失败时,返回原始Google API错误信息以供调试。
设置
- 1. 访问Google Cloud控制台并创建项目。
- 启用Google Calendar API。
- 创建OAuth 2.0凭据(桌面应用类型)。
- 将凭据保存为~/.openclaw/secrets/google-calendar-oauth.json:
json
{
client_id: 您的客户端ID,
client_secret: 您的客户端密钥
}
- 5. 通过OAuth流程获取刷新令牌,并保存为~/.openclaw/secrets/google-calendar-token.json:
json
{
refresh_token: 您的刷新令牌,
access_token: ,
expires_in: 0,
obtained_at:
}
脚本将使用刷新令牌自动刷新访问令牌。