# Memory Gdocs Ingest

> Ingest recently modified Google Docs into the memory knowledge base with email correlation

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

---


# Google Docs Ingest for Memory Knowledge Base

Pull recently modified Google Docs, correlate with related emails, and append enriched entries to the daily log.

## Process

### 1. Load State

Read state from `/Users/jesseanglen/Documents/RandomStuff/memory-kb/state/gdocs-state.json`.
If it doesn't exist, this is the first run — set `last_checked` to 7 days ago.

### 2. Search for Recently Modified Docs

Use `search_files` (Google Drive MCP) with:
```
query: "modifiedTime > 'YYYY-MM-DDTHH:MM:SSZ' and mimeType = 'application/vnd.google-apps.document'"
pageSize: 20
```

**Important:** Timestamps MUST use UTC with Z suffix: `2026-04-10T00:00:00Z`

Alternatively, use `list_recent_files` with `orderBy: "lastModified"` and filter to documents.

### 3. Process Each Document

The search tools return content snippets directly. For full content, use `read_file_content` with the document's `id`.

For each document:
1. Check if title + modifiedTime differ from `gdocs-state.json` — skip if unchanged
2. Extract: title, doc ID, last modified, content summary
3. **Identify people and companies** mentioned in the document (names, company names, email addresses)

### 4. EMAIL CORRELATION (Critical Enhancement)

For each document that mentions people or companies, search Gmail for related email threads:

Use `gmail_search_messages` with queries derived from the document content:
- Search by company name: e.g., `"spyder construction"` or `"monetate"`
- Search by person name: e.g., `"david gallo"` or `"steve maher"`
- Search by email addresses found in the doc

For each matching email thread:
1. Use `gmail_read_message` to get the most recent message in the thread
2. Extract: subject, participants, key status/decisions, last activity date

This creates a **unified view** — the document plus all related email communications.

### 5. Append Enriched Entry to Daily Log

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

```markdown
## Google Doc: [Document Title] @ HH:MM PT
**source:** gdocs
**doc_id:** [document ID]
**last_modified:** [ISO timestamp]
**people:** [Names and emails found in doc]

### Document Summary
- [Key content — decisions, plans, terms, important details]

### Related Email Threads
- **[Subject line]** (last activity: [date]) — [1-line summary of thread status]
  - Participants: [list]
  - Key: [latest decision or action item from thread]
- **[Subject line]** (last activity: [date]) — [1-line summary]
  - Participants: [list]
  - Key: [latest status]

### Action Items
- [ ] [Any outstanding items from doc + emails combined]
```

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

### 6. Update State

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

```json
{
  "last_checked": "ISO timestamp with Z suffix",
  "total_runs": N,
  "last_run": {
    "timestamp": "ISO",
    "docs_found": N,
    "docs_ingested": N,
    "docs_unchanged": N,
    "email_threads_correlated": N,
    "status": "success"
  },
  "doc_hashes": {
    "doc_id_1": "title:modifiedTime",
    "doc_id_2": "title:modifiedTime"
  }
}
```

### 7. Report

"Google Docs ingest complete. Found X modified docs, ingested Y with changes, correlated Z email threads."

## MCP Tools Reference

**Google Drive:**
- `search_files` — search by query with date filters and mime type
- `list_recent_files` — list most recently modified files
- `read_file_content` — read full document content by fileId
- `get_file_metadata` — get metadata for a specific file

**Gmail (for correlation):**
- `gmail_search_messages` — search for emails related to doc content
- `gmail_read_message` — read full email for thread context

## Correlation Strategy

The goal is that when Jesse asks about a deal or document, the compiled knowledge article has BOTH the document content AND the email thread context — so the memory surfaces everything relevant in one place.

**What to correlate:**
- Proposals/MSAs → find email threads with the client (by company name or contact name)
- Engagement letters → find the originating conversation and any signed/executed versions
- Meeting notes → find follow-up emails from attendees
- Any doc with a person's name → search for emails with that person

**What NOT to correlate:**
- Internal HR/salary docs → don't search for related emails (privacy)
- Template docs with no specific client → skip correlation
- Docs under 50 words (stubs) → skip entirely

## Notes

- Zero Chrome dependency — pure MCP (Google Drive + Gmail)
- Email correlation is what makes this ingest powerful — it creates unified deal context
- Limit to 3 email threads per document to keep daily log entries manageable
- For large docs (10,000+ words), summarize key sections only

