morning-email-rollup
每日早上 8 点汇总重要电子邮件和日历事件,并提供人工智能生成的摘要
安装 / 下载方式
TotalClaw CLI推荐
totalclaw skills install shop:totalclaw:totalclaw~am-will-morning-email-rollupcURL直接下载,无需登录
curl -fsSL https://skills.taituai.com/api/skills/totalclaw%3Atotalclaw~am-will-morning-email-rollup/file -o am-will-morning-email-rollup.md## 概述(中文)
每日早上 8 点汇总重要电子邮件和日历事件,并提供人工智能生成的摘要
## 原文
# Morning Email Rollup
Automatically generates a daily summary of important emails and delivers it to Telegram at 8am Denver time.
## Setup
**Required:** Set your Gmail account email:
```bash
export GOG_ACCOUNT="your-email@gmail.com"
```
Or edit the script directly to set the default.
## What It Does
- Runs every day at 8:00 AM (configurable timezone)
- **Shows today's calendar events** from Google Calendar
- Searches for emails marked as **important** or **starred** from the last 24 hours
- Uses AI (Gemini CLI) to generate natural language summaries of each email
- Shows up to 20 most important emails with:
- 🔴 Unread indicator (red)
- 🟢 Read indicator (green)
- Sender name/email
- Subject line
- **AI-generated 1-sentence summary** (natural language, not scraped content)
- Delivers formatted summary to Telegram
## Usage
### Manual Run
```bash
# Default (10 emails)
bash skills/morning-email-rollup/rollup.sh
# Custom number of emails
MAX_EMAILS=20 bash skills/morning-email-rollup/rollup.sh
MAX_EMAILS=5 bash skills/morning-email-rollup/rollup.sh
```
### View Log
```bash
cat $HOME/clawd/morning-email-rollup-log.md
```
## How It Works
1. **Checks calendar** - Lists today's events from Google Calendar via `gog`
2. **Searches Gmail** - Query: `is:important OR is:starred newer_than:1d`
3. **Fetches details** - Gets sender, subject, date, and body for each email
4. **AI Summarization** - Uses Gemini CLI to generate natural language summaries
5. **Formats output** - Creates readable summary with read/unread markers
6. **Sends to Telegram** - Delivers via Clawdbot's messaging system
## Calendar Integration
The script automatically includes today's calendar events from your Google Calendar using the same `gog` CLI that queries Gmail.
**Graceful Fallback:**
- If `gog` is not installed → Calendar section is silently skipped (no errors)
- If no events today → Calendar section is silently skipped
- If events exist → Shows formatted list with 12-hour times and titles
**Requirements:**
- `gog` must be installed and authenticated
- Uses the same Google account configured for Gmail (set via `GOG_ACCOUNT` environment variable)
## Email Criteria
Emails are included if they match **any** of:
- Marked as **Important** by Gmail (lightning bolt icon)
- Manually **Starred** by you
- Received in the **last 24 hours**
## AI Summarization
Each email is summarized using the Gemini CLI (`gemini`):
- Extracts the email body (cleans HTML/CSS)
- Sends to `gemini --model gemini-2.0-flash` with a prompt to summarize in 1 sentence
- The summary is medium-to-long length natural language (not scraped content)
- Falls back to cleaned body text if Gemini is unavailable
**Important:** The email body is passed as part of the prompt (not via stdin) because the gemini CLI doesn't handle piped input with prompts correctly.
**Example output:**
```
🔴 **William Ryan: Invitation to team meeting**
The email invites you to a team meeting tomorrow at 2pm to discuss the Q1 roadmap and assign tasks for the upcoming sprint.
```
## Read/Unread Indicators
- 🔴 Red dot = Unread email
- 🟢 Green dot = Read email
All emails show one of these markers for visual consistency.
## Formatting Notes
**Subject and Summary Cleanup:**
- Extra quotes are automatically stripped from subject lines (e.g., `""Agent Skills""` → `Agent Skills`)
- Summaries from Gemini are also cleaned of leading/trailing quotes
- This ensures clean, readable output in Telegram/other channels
## Cron Schedule
Set up a daily cron job at your preferred time:
```bash
cron add --name "Morning Email Rollup" \
--schedule "0 8 * * *" \
--tz "America/Denver" \
--session isolated \
--message "GOG_ACCOUNT=your-email@gmail.com bash /path/to/skills/morning-email-rollup/rollup.sh"
```
Adjust the time (8:00 AM) and timezone to your preference.
## Customization
### Change Number of Emails
By default, the rollup shows **10 emails**. To change this:
**Temporary (one-time):**
```bash
MAX_EMAILS=20 bash skills/morning-email-rollup/rollup.sh
```
**Permanent:**
Edit `skills/morning-email-rollup/rollup.sh`:
```bash
MAX_EMAILS="${MAX_EMAILS:-20}" # Change 10 to your preferred number
```
### Change Search Criteria
Edit `skills/morning-email-rollup/rollup.sh`:
```bash
# Current: important or starred from last 24h
IMPORTANT_EMAILS=$(gog gmail search 'is:important OR is:starred newer_than:1d' --max 20 ...)
# Examples of other searches:
# Unread important emails only
IMPORTANT_EMAILS=$(gog gmail search 'is:important is:unread newer_than:1d' --max 20 ...)
# Specific senders
IMPORTANT_EMAILS=$(gog gmail search 'from:boss@company.com OR from:client@example.com newer_than:1d' --max 20 ...)
# By label/category
IMPORTANT_EMAILS=$(gog gmail search 'label:work is:important newer_than:1d' --max 20 ...)
```
### Change Time
Update the cron schedule:
```bash
# List cron jobs to get the ID
cron list
# Update schedule (example: 7am instead of 8am)
cron update <job-id> --schedule "0 7 * * *" --tz "America/Denver"
```
### Change Summary Style
Edit the prompt in the `summarize_email()` function in `rollup.sh`:
```bash
# Current: medium-to-long 1 sentence
"Summarize this email in exactly 1 sentence of natural language. Make it medium to long length. Don't use quotes:"
# Shorter summaries
"Summarize in 1 short sentence:"
# More detail
"Summarize in 2-3 sentences with key details:"
```
### Change AI Model
Edit the gemini command in `summarize_email()`:
```bash
# Current: gemini-2.0-flash (fast)
gemini --model gemini-2.0-flash "Summarize..."
# Use a different model
gemini --model gemini-pro "Summarize..."
```
## Troubleshooting
### Not receiving rollups
```bash
# Check if cron job is enabled
cron list
# Check last run status
cron runs <job-id>
# Test manually
bash skills/morning-email-rollup/rollup.sh
```
### Missing emails
- Gmail's importance markers may filter out expected emails
- Check if emails are actually marked important/starred in Gmail
- Try running manual search: `gog gmail search 'is:important newer_than:1d'`
### Summaries not appearing
- Check if `gemini` CLI is installed: `which gemini`
- Test manually: `echo "test" | gemini "Summarize this:"`
- Verify Gemini is authenticated (it should prompt on first run)
### Wrong timezone
- Cron uses `America/Denver` (MST/MDT)
- Update with: `cron update <job-id> --tz "Your/Timezone"`
## Log History
All rollup runs are logged to:
```
$HOME/clawd/morning-email-rollup-log.md
```
Format:
```markdown
- [2026-01-15 08:00:00] 🔄 Starting morning email rollup
- [2026-01-15 08:00:02] ✅ Rollup complete: 15 emails
```
---
## 中文说明
# Morning Email Rollup
自动生成每日重要邮件摘要,并在丹佛时间早上 8 点发送至 Telegram。
## 设置
**必需:** 设置你的 Gmail 账户邮箱:
```bash
export GOG_ACCOUNT="your-email@gmail.com"
```
或者直接编辑脚本以设置默认值。
## 它的功能
- 每天早上 8:00 运行(时区可配置)
- **显示今日日历事件**,来自 Google Calendar
- 搜索过去 24 小时内被标记为**重要**或**加星标**的邮件
- 使用 AI(Gemini CLI)为每封邮件生成自然语言摘要
- 最多显示 20 封最重要的邮件,包含:
- 🔴 未读指示(红色)
- 🟢 已读指示(绿色)
- 发件人姓名/邮箱
- 主题行
- **AI 生成的一句话摘要**(自然语言,而非抓取的原文内容)
- 将格式化后的摘要发送至 Telegram
## 用法
### 手动运行
```bash
# Default (10 emails)
bash skills/morning-email-rollup/rollup.sh
# Custom number of emails
MAX_EMAILS=20 bash skills/morning-email-rollup/rollup.sh
MAX_EMAILS=5 bash skills/morning-email-rollup/rollup.sh
```
### 查看日志
```bash
cat $HOME/clawd/morning-email-rollup-log.md
```
## 工作原理
1. **检查日历** - 通过 `gog` 列出来自 Google Calendar 的今日事件
2. **搜索 Gmail** - 查询:`is:important OR is:starred newer_than:1d`
3. **获取详情** - 获取每封邮件的发件人、主题、日期和正文
4. **AI 摘要** - 使用 Gemini CLI 生成自然语言摘要
5. **格式化输出** - 创建带有已读/未读标记的可读摘要
6. **发送至 Telegram** - 通过 Clawdbot 的消息系统发送
## 日历集成
脚本使用查询 Gmail 时所用的同一个 `gog` CLI,自动包含来自你 Google Calendar 的今日日历事件。
**优雅降级:**
- 如果未安装 `gog` → 静默跳过日历部分(无报错)
- 如果今日无事件 → 静默跳过日历部分
- 如果存在事件 → 以 12 小时制时间和标题显示格式化列表
**要求:**
- `gog` 必须已安装并完成认证
- 使用为 Gmail 配置的同一个 Google 账户(通过 `GOG_ACCOUNT` 环境变量设置)
## 邮件筛选条件
邮件只要符合以下**任一**条件即被纳入:
- 被 Gmail 标记为