# Memory Email Ingest

> Ingest emails from calendar contacts using Gmail MCP tools — calendar-gated to prevent spam/noise

- Skill: `lotfb86/memory-email-ingest` (Agent Skill)
- Install (CLI): `npx skillmds@latest add lotfb86/memory-email-ingest`
- Raw SKILL.md: https://api.skillmd.com/api/skills/lotfb86/memory-email-ingest/raw
- Safety review: pending
- Works with: Claude Code, Claude.ai, OpenAI Codex
- Category: AI & ML
- Author: lotfb86 (https://skillmd.com/u/lotfb86)
- Updated: 2026-09-17
- Page: https://skillmd.com/skills/lotfb86/memory-email-ingest

---


# Calendar-Gated Email Ingest for Memory Knowledge Base

Ingest emails ONLY from people Jesse has meetings with. Uses Gmail MCP tools (not Chrome).

## Prerequisites

The calendar contacts file must exist at `/Users/jesseanglen/Documents/RandomStuff/memory-kb/state/calendar-contacts.json`.
If it doesn't exist or has zero contacts, report "No calendar contacts found. Run /memory-calendar-ingest first." and exit.

## Process

### 1. Load State & Contacts

Read calendar contacts from `/Users/jesseanglen/Documents/RandomStuff/memory-kb/state/calendar-contacts.json`.
Read email state from `/Users/jesseanglen/Documents/RandomStuff/memory-kb/state/email-state.json` (create if missing).

Extract the list of known contact email addresses.

### 2. Search Gmail via MCP

Use `gmail_search_messages` to find emails from known contacts.

Build the query: `after:YYYY/MM/DD from:({email1 OR email2 OR email3 ...})`

The `after:` date should be the `last_checked_timestamp` from email state, or 3 days ago if first run.

If there are many contacts (50+), split into multiple `gmail_search_messages` calls with batches of ~25 emails each.

Set `maxResults` to 50.

### 3. Read Each Matching Email

For each message returned by the search, use `gmail_read_message` with the `messageId` to get full content.

Extract:
- **Subject**
- **Sender** (name and email)
- **Date/time**
- **Body content** — focus on decisions, action items, requests, important context

**Skip trivial emails:**
- One-liners like "OK", "Thanks", "Got it", "Sounds good"
- Calendar confirmations/invitations (auto-generated)
- Auto-replies and out-of-office messages
- Marketing/newsletter content

### 4. Look Up Related Calendar Event

For each sender email, check `calendar-contacts.json` for their `last_seen` date.
Use this to populate the `related_event` field — connects the email to the meeting context.

### 5. Append to Daily Log

For each substantive email, append to `/Users/jesseanglen/Documents/RandomStuff/memory-kb/daily/YYYY-MM-DD.md`:

```markdown
## Email from sender@example.com @ HH:MM PT
**source:** email
**subject:** [Subject line]
**from:** Name <email>
**related_event:** [Most recent event with this contact, from calendar-contacts.json]

### Key Content
- [Summary of important information, decisions, or requests]
- [Action items mentioned]
- [Important context or commitments]

### Action Items
- [ ] [Any follow-up tasks identified]
```

If the daily log doesn't exist, create it with header `# Daily Log: YYYY-MM-DD`.

### 6. Deduplication

Track processed email message IDs in `email-state.json` (keep last 500).
Before appending, check for duplicate entries in the daily log (same subject + sender + date).

### 7. Update State

Write to `/Users/jesseanglen/Documents/RandomStuff/memory-kb/state/email-state.json`:

```json
{
  "last_checked_timestamp": "ISO timestamp",
  "total_runs": N,
  "last_run": {
    "timestamp": "ISO",
    "emails_found": N,
    "emails_ingested": N,
    "contacts_matched": N,
    "status": "success"
  },
  "processed_message_ids": ["id1", "id2"]
}
```

### 8. Report

"Email ingest complete. Found X emails from calendar contacts, ingested Y substantive entries."

## Important Notes

- Uses `gmail_search_messages` and `gmail_read_message` MCP tools — NO Chrome browser needed
- ONLY ingest emails from addresses in `calendar-contacts.json` — this is the core spam filter
- Skip trivial emails (one-liners, calendar confirmations, auto-replies)
- Focus extraction on decisions, commitments, action items, important context
- If zero emails match, that's fine — log it and exit normally

