LocalLLMMailScreener
Node.js (ESM) service that polls Gmail, sends each new email to a local OpenAI-compatible LLM, and optionally forwards summarized mobile notifications based on the LLMs assessment of importance via Twilio SMS or Pushover (emergency mode). Includes a lightweight dashboard and JSON status API.
Install / Use
/learn @IngeniousIdiocy/LocalLLMMailScreenerREADME
Local LLM Mail Screener
Node.js (ESM) service that polls Gmail, sends each new email to a local OpenAI-compatible LLM, and optionally forwards summarized notifications based on the LLM's assessment of importance via Twilio SMS or Pushover (emergency mode). Includes a lightweight dashboard and JSON status API.

Architecture
┌────────────────────────────────────────────────────────────────────────────┐
│ LOCAL LLM MAIL SCREENER │
├────────────────────────────────────────────────────────────────────────────┤
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ EXPRESS SERVER (:3000) │ │
│ │ ┌──────────────────────┐ ┌──────────────────────────────────┐ │ │
│ │ │ Dashboard (HTML) │ │ API Endpoint │ │ │
│ │ │ GET / │ │ GET /api/status │ │ │
│ │ │ │ │ │ │ │
│ │ │ • Health indicators │ │ • Health/stats JSON │ │ │
│ │ │ • Token estimates │ │ • Recent sends & decisions │ │ │
│ │ │ • Recent SMS sends │ │ • Config (sanitized) │ │ │
│ │ └──────────────────────┘ └──────────────────────────────────┘ │ │
│ └─────────────────────────────────────────────────────────────────────┘ │
│ │
│ ┌─────────────────────────────────────────────────────────────────────┐ │
│ │ CORE SERVICES │ │
│ │ │ │
│ │ ┌─────────────┐ ┌─────────────┐ ┌─────────────────────┐ │ │
│ │ │ gmail.js │ │ llm.js │ │ Notification Svc │ │ │
│ │ │ │ │ │ │ ┌─────────────────┐ │ │ │
│ │ │ • OAuth2 │ │ • OpenAI │ │ │ twilio.js │ │ │ │
│ │ │ • List msgs │ │ compat │ │ │ • SMS sending │ │ │ │
│ │ │ • Fetch raw │ │ • JSON mode │ │ ├─────────────────┤ │ │ │
│ │ │ • Parse │ │ • Timeouts │ │ │ pushover.js │ │ │ │
│ │ │ │ │ │ │ │ • Push notifs │ │ │ │
│ │ │ │ │ │ │ │ • Emergency pri │ │ │ │
│ │ │ │ │ │ │ └─────────────────┘ │ │ │
│ │ │ │ │ │ │ • DRY_RUN support │ │ │
│ │ │ │ │ │ │ • Credential check │ │ │
│ │ └──────┬──────┘ └──────┬──────┘ └──────────┬──────────┘ │ │
│ │ │ │ │ │ │
│ └──────────┼──────────────────┼──────────────────────┼────────────────┘ │
│ │ │ │ │
│ ┌──────────┴──────────────────┴──────────────────────┴───────────────┐ │
│ │ index.js │ │
│ │ (Orchestrator) │ │
│ │ │ │
│ │ • Polling loop with lock • Concurrency limiter │ │
│ │ • Message processing • Health monitoring │ │
│ │ • Decision routing • Error handling │ │
│ └────────────────────────────────────┬───────────────────────────────┘ │
│ │ │
│ ┌────────────────────────────────────┴───────────────────────────────┐ │
│ │ state.js │ │
│ │ (Persistence Layer) │ │
│ │ │ │
│ │ • Processed IDs map • Recent decisions/sends │ │
│ │ • Token usage tracking • Atomic JSON writes │ │
│ │ • Stats per service • Auto-pruning │ │
│ └────────────────────────────────────────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ./data/state.json │
│ │
└────────────────────────────────────────────────────────────────────────────┘
EXTERNAL SERVICES
┌───────────────────┐ ┌───────────────────┐ ┌───────────────────┐
│ Gmail API │ │ Local LLM │ │ Notification │
│ (googleapis) │ │ (OpenAI compat) │ │ │
│ │ │ │ │ ┌─────────────┐ │
│ users.messages │ │ /v1/chat/ │ │ │ Twilio SMS │ │
│ .list / .get │ │ completions │ │ └─────────────┘ │
│ │ │ │ │ ┌─────────────┐ │
│ │ │ │ │ │ Pushover │ │
│ │ │ │ │ │ (emergency) │ │
│ │ │ │ │ └─────────────┘ │
└───────────────────┘ └───────────────────┘ └───────────────────┘
Email Processing Flow
┌──────────────────────────────────────────────────────────────────────────────┐
│ │
│ ╔═══════════════╗ │
│ ║ INCOMING ║ │
│ ║ EMAIL ║ │
│ ╚═══════╤═══════╝ │
│ │ │
│ ▼ │
│ ┌───────────────┐ │
│ │ Gmail Inbox │ │
│ └───────┬───────┘ │
│ │ │
│ │ (sits in inbox) │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ POLL INTERVAL TIMER │ │
│ │ (default: every 15 seconds) │ │
│ └───────────────────────────────┬───────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ LIST MESSAGES (Gmail API) │ │
│ │ users.messages.list with GMAIL_QUERY filter │ │
│ │ (e.g., newer_than:7d) │ │
│ └───────────────────────────────┬───────────────────────────────────┘ │
│ │ │
│ ▼ │
│ ┌────────────────────────┐ │
│ │ Already processed? │ │
│ │ (check state.json) │ │
│ └────────────┬───────────┘ │
│ │ │
│ ┌────────────────┴────────────────┐ │
│ │ YES NO │ │
│ ▼ ▼ │
│ ┌──────────────┐ ┌──────────────────────┐ │
│ │ SKIP │ │ FETCH RAW MESSAGE │ │
│ │ (continue) │ │ (format=raw, Base64)│ │
│ └──────────────┘ └──────────┬───────────┘ │
│ │ │
│ ▼ │
│ ┌──────────────────────┐ │
│ │ PARSE EMAIL │ │
│ │ • Decode MIME │ │
│ │ • Extract headers │ │
│ │ • Get body text │ │
│ │ • List attachments │ │
│ └──────────┬───────────┘ │
│ │ │
│ ▼ │
│ ┌───────────────────────────────────────────────────────────────────┐ │
│ │ SEND TO LOCAL LLM
Related Skills
node-connect
343.3kDiagnose OpenClaw node connection and pairing failures for Android, iOS, and macOS companion apps
frontend-design
92.1kCreate distinctive, production-grade frontend interfaces with high design quality. Use this skill when the user asks to build web components, pages, or applications. Generates creative, polished code that avoids generic AI aesthetics.
openai-whisper-api
343.3kTranscribe audio via OpenAI Audio Transcriptions API (Whisper).
qqbot-media
343.3kQQBot 富媒体收发能力。使用 <qqmedia> 标签,系统根据文件扩展名自动识别类型(图片/语音/视频/文件)。
