Tools
Mail Feishu
OpenClaw plugin: Gmail real-time notifications to Feishu/Lark via Google Pub/Sub
Install
npm install &&
README
# openclaw-mail-feishu
OpenClaw plugin for real-time Gmail notifications to Feishu/Lark.
Uses Google Pub/Sub for instant delivery โ no polling, no delay.
## For AI Agents
Copy the prompt below and send it to your AI agent to set up this plugin automatically.
```
Set up the openclaw-mail-feishu plugin. This plugin delivers real-time Gmail notifications to Feishu/Lark via Google Pub/Sub.
Before starting, ask me for: (1) my Gmail address, (2) my Feishu/Lark webhook URL โ if I don't have one, guide me to create it: Feishu group โ Settings โ Bots โ Add Bot โ Custom Bot โ copy webhook URL, (3) my Google Cloud project ID โ if I don't have one, guide me to create one at https://console.cloud.google.com, (4) optionally an LLM API key for smart email filtering.
Then follow these steps in order:
Step 1 โ Check prerequisites:
- gog CLI installed: run "which gog && gog --version". If missing, download from https://github.com/openclaw/gogcli/releases for the correct platform.
- gog Gmail auth: run "gog auth list". If no account, guide me through OAuth: I need a Google Cloud project with OAuth credentials (Desktop app type), then run "gog auth credentials /path/to/client_secret.json" and "gog auth add [email protected] --services gmail".
- OpenClaw running: run "openclaw status".
Step 2 โ Enable Google Cloud APIs. Send me these two links to open in browser and click Enable:
- Gmail API: https://console.cloud.google.com/apis/library/gmail.googleapis.com?project=PROJECT_ID
- Pub/Sub API: https://console.cloud.google.com/apis/library/pubsub.googleapis.com?project=PROJECT_ID
Wait for me to confirm before proceeding.
Step 3 โ Create Pub/Sub topic and subscription. If gcloud is available, run:
gcloud pubsub topics create gmail-notifications
gcloud pubsub subscriptions create gmail-notifications-sub --topic=gmail-notifications
gcloud pubsub topics add-iam-policy-binding gmail-notifications --member="serviceAccount:[email protected]" --role="roles/pubsub.publisher"
If gcloud is NOT available, use REST API with an OAuth token that has pubsub scope:
curl -X PUT "https://pubsub.googleapis.com/v1/projects/PROJECT_ID/topics/gmail-notifications" -H "Authorization: Bearer ACCESS_TOKEN" -H "Content-Type: application/json"
curl -X PUT "https://pubsub.googleapis.com/v1/projects/PROJECT_ID/subscriptions/gmail-notifications-sub" -H "Authorization: Bearer ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"topic":"projects/PROJECT_ID/topics/gmail-notifications","ackDeadlineSeconds":60}'
curl -X POST "https://pubsub.googleapis.com/v1/projects/PROJECT_ID/topics/gmail-notifications:setIamPolicy" -H "Authorization: Bearer ACCESS_TOKEN" -H "Content-Type: application/json" -d '{"policy":{"bindings":[{"role":"roles/pubsub.publisher","members":["serviceAccount:[email protected]"]}]}}'
Step 4 โ Install and configure the plugin:
git clone https://github.com/larry-xue/openclaw-mail-feishu.git /tmp/openclaw-mail-feishu
cd /tmp/openclaw-mail-feishu && npm install && npm run build
openclaw plugins install /tmp/openclaw-mail-feishu
openclaw plugins config mail-feishu --set gcpProject=PROJECT_ID
openclaw plugins config mail-feishu --set pubsubSubscription=gmail-notifications-sub
openclaw plugins config mail-feishu --set pubsubTopic=gmail-notifications
openclaw plugins config mail-feishu --set feishuWebhook=WEBHOOK_URL
If LLM key was provided, also run:
openclaw plugins config mail-feishu --set llmApiKey=KEY
openclaw plugins config mail-feishu --set llmModel=gpt-4o-mini
Step 5 โ Restart and verify:
openclaw gateway restart
sleep 3
openclaw gateway logs | grep mail-feishu
Expected: "mail-feishu: watch registered" and "mail-feishu: watching inbox โ feishu"
Step 6 โ Test: ask me to send myself a test email. Within 30 seconds a Feishu card notification should appear.
Troubleshooting:
- "watch registration failed" โ Gmail API not enabled or wrong project ID
- "subscription error" โ Pub/Sub API not enabled or subscription name mismatch
- "feishu send failed" โ webhook URL incorrect or bot removed from group
- No logs at all โ plugin not loaded, check "openclaw plugins list"
```
---
## For Humans
[ไธญๆๆๆกฃ](README_CN.md)
## How It Works
```
Gmail inbox โ Google Pub/Sub โ OpenClaw plugin โ LLM classification โ Feishu/Lark webhook
```
1. Gmail pushes new email events to a Pub/Sub topic in real time
2. The plugin listens on the subscription and fetches email details
3. (Optional) LLM classifies urgency: ๐ด Critical / ๐ Important / ๐ก Normal / ๐ข Low
4. Important emails are sent to Feishu/Lark as interactive card messages
## Features
- **Real-time** โ Pub/Sub push, not IMAP polling
- **Feishu + Lark** โ supports both `open.feishu.cn` and `open.larksuite.com` webhooks
- **Smart filtering** โ optional LLM classification skips newsletters and spam
- **Rich cards** โ sender, subject, summary, urgency tag in one card
- **Auto-renew** โ Gmail watch is re-registered every 6 days automatically
- **Multilingual** โ zh / en / ja notification and classification
## Prerequisites
- [OpenClaw](https://openclaw.ai) installed and running
- [gog CLI](https://github.com/openclaw/gogcli) with Gmail OAuth configured
- Google Cloud project with **Gmail API** and **Pub/Sub API** enabled
- Feishu/Lark group with a webhook bot
## Quick Start
### 1. Set up Google Cloud
```bash
# Create Pub/Sub topic and subscription
gcloud pubsub topics create gmail-notifications
gcloud pubsub subscriptions create gmail-notifications-sub \
--topic=gmail-notifications
# Grant Gmail permission to publish
gcloud pubsub topics add-iam-policy-binding gmail-notifications \
--member="serviceAccount:[email protected]" \
--role="roles/pubsub.publisher"
```
Or do it via REST API / Google Cloud Console โ see [Setup Guide](docs/setup.md).
### 2. Create Feishu Webhook
1. Open a Feishu group โ Settings โ Bots โ Add Bot โ Custom Bot
2. Copy the webhook URL (`https://open.feishu.cn/open-apis/bot/v2/hook/xxx`)
3. (Optional) Enable signature verification, note the secret
### 3. Install Plugin
```bash
# From source
git clone https://github.com/larry-xue/openclaw-mail-feishu.git
cd openclaw-mail-feishu
npm install && npm run build
openclaw plugins install .
# Or run the setup script
./scripts/setup.sh
```
### 4. Configure
```bash
openclaw plugins config mail-feishu --set gcpProject=YOUR_PROJECT_ID
openclaw plugins config mail-feishu --set pubsubSubscription=gmail-notifications-sub
openclaw plugins config mail-feishu --set feishuWebhook=https://open.feishu.cn/open-apis/bot/v2/hook/xxx
# Optional: webhook signature
openclaw plugins config mail-feishu --set feishuWebhookSecret=YOUR_SECRET
# Optional: LLM classification (without this, all inbox emails are forwarded)
openclaw plugins config mail-feishu --set llmApiKey=sk-xxx
openclaw plugins config mail-feishu --set llmModel=gpt-4o-mini
```
### 5. Restart & Verify
```bash
openclaw gateway restart
openclaw gateway logs | grep mail-feishu
# Expected: mail-feishu: watch registered, historyId=...
# Expected: mail-feishu: watching inbox โ feishu
```
Send yourself a test email and wait a few seconds โ you should see a Feishu card.
## Configuration Reference
| Key | Required | Default | Description |
|-----|----------|---------|-------------|
| `feishuWebhook` | โ
| โ | Feishu/Lark webhook URL |
| `feishuWebhookSecret` | โ | โ | Webhook signature secret |
| `gcpProject` | โ
| โ | Google Cloud project ID |
| `pubsubSubscription` | โ
| `gmail-notifications-sub` | Pub/Sub subscription name |
| `pubsubTopic` | โ | `gmail-notifications` | Pub/Sub topic name |
| `gogAccount` | โ | gog default | Gmail account to watch |
| `credentialsPath` | โ | ADC | Path to Google credentials JSON |
| `llmApiKey` | โ | โ | API key for classification LLM |
| `llmBaseUrl` | โ | `https://api.openai.com/v1` | LLM API base URL |
| `llmModel` | โ | `gpt-4o-mini` | LLM model name |
| `locale` | โ | `zh` | Notification language (zh/en/ja) |
## Notification Card Preview
```
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ ๐ฌ ๆฐ้ฎไปถ โ ๐ ้่ฆ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
โ ๅไปถไบบ ๆถ้ด โ
โ Alice Chen 2026-05-29 14:30 โ
โ โ
โ ไธป้ข โ
โ Q3 ้ข็ฎๅฎกๆน้่ฆไฝ ็ญพๅญ โ
โ โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ โ
โ ๆ่ฆ โ
โ Alice ่ฏทไฝ ๅจๅจไบๅๅฎกๆน Q3 ้ข็ฎ โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
```
## License
MIT
tools
Comments
Sign in to leave a comment