Invoice Collector
Collect invoices from Gmail and send them as a summary email with all attachments.
Security Considerations
Puppeteer --no-sandbox Flag
This skill uses --no-sandbox when launching Puppeteer/Chromium. This is required in many environments:
- - WSL (Windows Subsystem for Linux): Chrome sandbox requires kernel features not available in WSL1/WSL2
- Docker containers: Unless running with
--privileged or specific seccomp profiles - CI/CD environments: Most runners don't support Chrome's sandbox
Risk: Disabling the sandbox means if a malicious HTML email were rendered, it could potentially execute code outside the browser context.
Mitigation: This skill only renders emails from your own Gmail inbox. The risk is limited to emails you've already received. If you're concerned, review emails before processing or run in an isolated environment.
Installation via curl | tar
The gogcli installation example uses curl -sL ... | tar xz, which is a common pattern but carries supply chain risks if the source were compromised.
Safer alternative (verify checksum):
CODEBLOCK0
macOS users: Use brew install steipete/tap/gogcli which handles verification automatically.
Prerequisites & Setup
1. Install gogcli
CODEBLOCK1
2. Setup Google OAuth
- 1. Go to Google Cloud Console
- Create project → Enable Gmail API
- Create OAuth credentials (Desktop app)
- Download JSON
CODEBLOCK2
3. Install Puppeteer (for email screenshots)
CODEBLOCK3
4. Install Japanese fonts (optional, for JP emails)
CODEBLOCK4
Usage
Generic Invoice Search
Search for any invoice/receipt without specifying specific senders:
CODEBLOCK5
Workflow
- 1. Search - Find invoice emails
- Download - Get PDFs or screenshot emails
- Summarize - Create summary with amounts
- Send - Email to destination with attachments
Step 1: Search Invoices
CODEBLOCK6
Step 2: Process Each Email
CODEBLOCK7
For emails WITH PDF attachments:
CODEBLOCK8
For emails WITHOUT PDF (take screenshot):
CODEBLOCK9
Step 3: Extract Invoice Info
Parse email for sender, date, amount:
CODEBLOCK10
Step 4: Send Summary Email
CODEBLOCK11
Example Prompts
Generic:
- - "先月の請求書を全部集めてまとめて送って"
- "invoiceで検索して今月届いた請求書をkeiri@company.comに転送して"
- "has:attachment receipt で検索して請求書集めて"
Specific:
- - "AnthropicとVercelとAWSの請求書を集めて"
- "from:stripe の請求書を過去3ヶ月分まとめて"
Tips
- - Date format:
YYYY/MM/DD for gog search - PDF priority: Always prefer PDF attachments over screenshots
- Japanese fonts: Required for correct rendering of JP emails
- Cleanup:
rm -rf /tmp/invoices after sending - Cron: Set up monthly cron job for recurring collection
发票收集器
从Gmail收集发票,并将其作为包含所有附件的摘要邮件发送。
安全注意事项
Puppeteer --no-sandbox 标志
此技能在启动Puppeteer/Chromium时使用--no-sandbox。这在许多环境中是必需的:
- - WSL(适用于Linux的Windows子系统):Chrome沙箱需要WSL1/WSL2中不可用的内核功能
- Docker容器:除非使用--privileged或特定的seccomp配置文件运行
- CI/CD环境:大多数运行器不支持Chrome的沙箱
风险:禁用沙箱意味着如果渲染了恶意HTML邮件,它可能在浏览器上下文之外执行代码。
缓解措施:此技能仅渲染来自您自己Gmail收件箱的邮件。风险仅限于您已收到的邮件。如果担心,请在处理前查看邮件或在隔离环境中运行。
通过 curl | tar 安装
gogcli安装示例使用curl -sL ... | tar xz,这是一种常见模式,但如果源被入侵,则存在供应链风险。
更安全的替代方案(验证校验和):
bash
下载并验证
curl -sLO https://github.com/steipete/gogcli/releases/latest/download/gogcli
linuxamd64.tar.gz
curl -sLO https://github.com/steipete/gogcli/releases/latest/download/checksums.txt
sha256sum -c checksums.txt --ignore-missing
tar xzf gogcli
linuxamd64.tar.gz
mv gog ~/.local/bin/
macOS用户:使用brew install steipete/tap/gogcli,它会自动处理验证。
前提条件与设置
1. 安装gogcli
bash
Linux(下载二进制文件)
curl -sL https://github.com/steipete/gogcli/releases/latest/download/gogcli
linuxamd64.tar.gz | tar xz
mv gog ~/.local/bin/
macOS
brew install steipete/tap/gogcli
2. 设置Google OAuth
- 1. 前往Google Cloud Console
- 创建项目 → 启用Gmail API
- 创建OAuth凭据(桌面应用)
- 下载JSON
bash
gog auth credentials ~/path/to/client_secret.json
gog auth add your@gmail.com
3. 安装Puppeteer(用于邮件截图)
bash
cd /tmp && npm install puppeteer
4. 安装日文字体(可选,用于日文邮件)
bash
sudo apt install fonts-noto-cjk
使用方法
通用发票搜索
搜索任何发票/收据,无需指定特定发件人:
bash
export GOG_ACCOUNT=user@gmail.com
export GOGKEYRINGPASSWORD=your-password
搜索日期范围内的所有发票
gog gmail search (invoice OR receipt OR 請求書 OR 領収書 OR billing OR payment) after:2026/01/01 before:2026/02/01
按特定条件搜索
gog gmail search subject:(invoice OR receipt) has:attachment after:2026/01/01
工作流程
- 1. 搜索 - 查找发票邮件
- 下载 - 获取PDF或截图邮件
- 汇总 - 创建包含金额的摘要
- 发送 - 将邮件发送到目标地址并附带附件
步骤1:搜索发票
bash
上个月的所有发票
LAST_MONTH=$(date -d 1 month ago +%Y/%m/01)
THIS_MONTH=$(date +%Y/%m/01)
gog gmail search (invoice OR receipt OR 請求書 OR 領収書) after:$LAST
MONTH before:$THISMONTH --json
步骤2:处理每封邮件
bash
mkdir -p /tmp/invoices
对于带有PDF附件的邮件:
bash
获取邮件详情
MSG
ID=id_here>
EMAILJSON=$(gog gmail read $MSGID --json)
查找PDF附件
ATTACHINFO=$(echo $EMAILJSON | jq -r .thread.messages[0].payload.parts[]? | select(.filename | test(\\.pdf$; i)) | \(.body.attachmentId)|\(.filename) | head -1)
ATTACHID=$(echo $ATTACHINFO | cut -d| -f1)
FILENAME=$(echo $ATTACH_INFO | cut -d| -f2)
下载
gog gmail attachment $MSGID $ATTACHID --out /tmp/invoices/$FILENAME
对于没有PDF的邮件(截图):
bash
MSGID=id_here>
提取HTML
gog gmail read $MSG_ID --json | node -e
const fs = require(fs);
let data = ;
process.stdin.on(data, chunk => data += chunk);
process.stdin.on(end, () => {
const json = JSON.parse(data);
const msg = json.thread.messages[0];
let html = ;
const findHtml = (p) => {
if (p.mimeType === text/html && p.body?.data) {
html = Buffer.from(p.body.data, base64).toString(utf-8);
}
if (p.parts) p.parts.forEach(findHtml);
};
(msg.payload.parts || []).forEach(findHtml);
if (!html && msg.payload.body?.data) {
html = Buffer.from(msg.payload.body.data, base64).toString(utf-8);
}
fs.writeFileSync(/tmp/invoices/email.html, html || No content);
});
截图
node -e
const puppeteer = require(puppeteer);
const fs = require(fs);
(async () => {
const browser = await puppeteer.launch({ headless: new, args: [--no-sandbox] });
const page = await browser.newPage();
await page.setViewport({ width: 800, height: 1200 });
await page.setContent(fs.readFileSync(/tmp/invoices/email.html, utf-8), { waitUntil: networkidle0 });
await page.screenshot({ path: /tmp/invoices/receipt.png, fullPage: true });
await browser.close();
})();
步骤3:提取发票信息
解析邮件以获取发件人、日期、金额:
bash
从邮件获取基本信息
gog gmail read $MSG_ID --json | jq {
from: .thread.messages[0].payload.headers[] | select(.name==From) | .value,
subject: .thread.messages[0].payload.headers[] | select(.name==Subject) | .value,
date: .thread.messages[0].payload.headers[] | select(.name==Date) | .value
}
步骤4:发送摘要邮件
bash
gog gmail send \
--to recipient@example.com \
--subject 【$(date +%Y年%m月)】請求書まとめ \
--body 請求書・領収書を添付します。
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
📊 請求書まとめ
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
【添付ファイル】
- 1. Invoice-001.pdf - Service A
- Receipt.png - Service B (メールスクショ)
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
このメールは自動生成されました。
\
--attach /tmp/invoices/Invoice-001.pdf \
--attach /tmp/invoices/Receipt.png
示例提示
通用:
- - 先月の請求書を全部集めてまとめて送って
- invoiceで検索して今月届いた請求書をkeiri@company.comに転送して
- has:attachment receipt で検索して請求書集めて
特定:
- - AnthropicとVercelとAWSの請求書を集めて
- from:stripe の請求書を過去3ヶ月分まとめて
提示
- - 日期格式:gog搜索使用YYYY/MM/DD
- PDF优先:始终优先选择PDF附件而非截图
- 日文字体:正确渲染日文邮件所需
- 清理:发送后执行rm -rf /tmp/invoices
- 定时任务:设置月度cron作业进行定期收集