Building The Brain: Life-OS Inbox Handoff¶
Keywords: building-the-brain · life-os · inbox-bot · second-brain · agentic-router · gmail · calendar · notion · n8n · forge
Date: 2026-04-27
Author: Claude Code (Opus 4.7) in n8n-telegram_Opus47 session
Status: Foundation partially built; brain not yet wired; Notion redesign pending before brain wires to it
1. The Vision (one paragraph)¶
Justin wants one inlet for everything in his life, todos, calendar events, reminders, habits, notes, ideas, captured from anywhere (Telegram voice/text, iOS Shortcut, future: Mac hotkey, Apple Watch, browser ext). The inlet routes mostly to Notion (notes, todos, habits, knowledge) and Google Calendar (time-based events), with reminders pushed back via Telegram. The system must be easy to extend, adding a new capability should be cheap, never a rewrite.
This is not a smarter calendar handler. This is the chat-driven life-OS he's been describing for months, finally getting built.
2. The Architecture (plain English)¶
Voice / text from anywhere
(Telegram bot, iOS Shortcut, future inlets)
│
▼
┌───────────────┐
│ INBOX BRAIN │ ← Sonnet 4.6, single Python module
│ + memory │ - reads message + last ~10 exchanges
│ + tools │ - decides what to do
└───────┬───────┘ - calls tools
│
┌───────────┴───────────┐
↓ ↓
┌─────────────────┐ ┌──────────────────┐
│ Notion (notes, │ │ Google Cal │
│ todos, habits, │ │ (time-based) │
│ ideas, etc.) │ └──────────────────┘
└─────────────────┘ ┌──────────────────┐
│ Reminders/Nudges │
│ (Telegram push) │
└──────────────────┘
(Gmail, TickTick, etc. plug in same way)
Key architectural concepts¶
| Concept | Plain meaning | Where it lives |
|---|---|---|
| Brain | Sonnet LLM that reads your message, decides what to do, calls tools | scripts/integrations/telegram/inbox_brain.py (not yet built) |
| Tool registry | Python list. Each entry is one capability (name + description + handler). Brain reads the list to know what it can do. | inside inbox_brain.py |
| n8n workflow | A "narrow door", one specific HTTP endpoint that calls one specific external API using a stored credential. The brain never holds OAuth tokens; it goes through workflows. | n8n container CT 106 on Finn |
| Auth | Every workflow checks X-Forge-Auth header against FORGE_WEBHOOK_SECRET. Secret in ~/.forge-secrets/n8n.env on UDev. |
shared |
| Call helper | scripts/n8n/call.sh <path> '<json>', every script that talks to n8n uses this |
shared |
| Inlets | Different ways to feed messages into the brain: Telegram bot, iOS webhook, future hotkeys | inbox_bot.py, inbox_webhook.py |
| Skills | Prebuilt slash commands for Claude Code itself (e.g. /recall, /spawn). Different concept; nothing to do with brain or n8n. |
.claude/skills/ |
Why workflows per action (vs one giant "do anything" workflow)¶
Trade between safety and speed-of-extension. Current pattern: one workflow per (service × verb). Each workflow does one specific thing → tight blast radius if brain hallucinates. Cost: ~5 min to build a new workflow when adding a verb.
Alternative: one generic gcal-call / notion-call per service. Brain picks method + path. Faster to extend, but if brain gets prompt-injected it can do anything that service allows.
Decision (2026-04-27): stay per-action for now. Don't break callers mid-flight. Revisit if per-action fatigue sets in. Don't consolidate while the email chat is actively editing email workflows, that would break their work.
3. Cost model (Max $100 plan)¶
The Max plan = a token-equivalent budget refilled every 5h. Different models burn it at different rates:
| Model | Relative burn | Where used |
|---|---|---|
| Opus 4.7 | 1× (heaviest) | Architecture / planning sessions |
| Sonnet 4.6 | ~0.2× | Brain default, code edits, daily work |
| Haiku 4.5 | ~0.04× | Tiny one-shot classification |
What burns budget: Claude conversations (this one), claude -p calls fired from scripts, spawned worker sessions, parallel sessions.
What does NOT burn budget: n8n container running, Notion/Gcal/TG APIs themselves, webhooks, hooks, dispatcher, context API, all systemd services, secrets storage.
Inbox brain projection: ~3-5k Sonnet tokens per voice/text message. 50 messages/day = ~250k Sonnet tokens/day. Rounding error on the Max plan.
Discipline rules: - Default brain to Sonnet, not Opus - Use Haiku for tiny classify-only jobs - Don't run parallel Opus workers unless needed - Background scheduled agents → Sonnet by default
4. What's BUILT today (2026-04-27)¶
n8n workflows live + active (20 total)¶
All in infra/n8n/workflows/*.json. Activated, smoke-tested, callable via scripts/n8n/call.sh <name> '<json>'.
| Group | Workflows | Built by |
|---|---|---|
list-recent-emails, archive-emails, block-sender, unsubscribe-sender, create-gmail-draft-business, verify-gmail-business, verify-gmail-personal |
Email-cleanup chat (separate session, threading fix in progress 2026-04-27) | |
| Calendar | create-calendar-event, list-calendar-events, delete-calendar-event, verify-calendar |
This session 2026-04-27 |
| Notion | notion-search-databases, notion-get-database, notion-create-page, notion-query-database, notion-update-page |
This session 2026-04-27 |
| TickTick | ticktick-create-task, ticktick-list-projects, ticktick-list-project-tasks |
Earlier session |
| Plumbing | forge-hello |
Earlier session (auth test) |
n8n credentials available¶
| Cred ID | Service | Type |
|---|---|---|
t5YQ9F5vvgEFd6qL |
Google Calendar | googleCalendarOAuth2Api |
mgQHSiQOlbURyLs1 |
Notion | notionApi |
| Gmail business OAuth | (via gmail-business cred) | googleOAuth2Api |
| Gmail personal OAuth (read-only) | (via gmail-personal cred) | googleOAuth2Api |
N4en6wi0o81nWDcn |
Cloudflare | cloudflareApi |
tc1oVB8LQUUzlBiZ |
Home Assistant | homeAssistantApi |
mEef8a4KkOzn3d7y |
Eight Sleep wellness | httpBasicAuth |
saT0X6MMAFLKrBOT |
Garmin Connect wellness | httpBasicAuth |
Missing: personal Gmail MODIFY scope (blocked on Justin's Phase 0 account hardening).
Existing Notion DBs (visible to integration)¶
| DB | ID | Purpose |
|---|---|---|
| JustinWieb Tasks | 19cb373d-9209-41b4-8b70-0c02038671f2 |
Existing tasks. Status options: Pending Payment, Not started, In progress, Done, Archived |
| JustinWieb Projects | da9777e9-4067-46dc-be74-f26732b6fdae |
Projects, linked to tasks via "Project" relation |
| Time Tracker | 2290950b-d7a9-80db-b0b1-dc00dd02ab9d |
Work hour / billing tracker |
⚠️ Justin paused brain build because his Notion is a year stale and he wants to redesign before wiring. No new DBs exist for Inbox / Habits / Knowledge / Content / etc. yet.
Inlets live + healthy¶
| Inlet | Service | Tested |
|---|---|---|
@jw_inbox_bot (Telegram voice/text) |
forge-telegram-inbox.service |
✓ |
inbox.justinkrystal.com/inbox (iOS Shortcut HTTP) |
forge-inbox-webhook.service |
✓ |
push.sh updates (outbound to @jw_updates_bot) |
direct sendMessage | ✓ |
Inbox bot (current behavior, to be replaced)¶
scripts/integrations/telegram/inbox_bot.py uses Haiku to classify each message into one of {NOTE, NUDGE, TODO, CALENDAR, SHOPPING, QUESTION} and dispatches to a hardcoded handler. Multi-step requests fail (e.g. "delete those events" got squashed to TODO). This is what the brain replaces.
5. What's NOT built yet¶
| Component | Status | Notes |
|---|---|---|
inbox_brain.py |
Not started | Skeleton outlined, paused for Notion redesign |
| Tool registry | Not started | Python dict with name → schema → handler |
| Context log | Not started | data/inbox-context.jsonl, last N exchanges + their results |
| Inlet cutover | Not started | inbox_bot.py + inbox_webhook.py still use the old intent_route |
update-calendar-event workflow |
Not started | Needed for "add description / move event / change attendees" |
| Notion DB redesign | Pending Justin's design pass | Inbox / Habits / Knowledge / Content / Contacts DBs to be decided |
| Reference docs refresh | Pending | reference_telegram_inbox.md is stale (says intents are stubbed; some are actually wired now) |
6. Capability menu, what we COULD build¶
Per surface, by risk (R = read, W = write, S = send/destructive) and effort (★ = one workflow, ★★ = workflow + brain logic, ★★★ = multi-step orchestration).
6.1 Personal Gmail, [email protected]¶
Hard limit: never send. Read/draft/archive/filter only, recovery email for entire digital life.
| Action | Risk | Effort |
|---|---|---|
| List unread / search by sender/label/query | R | ★ |
| Read full email body + thread | R | ★ |
| Inbox stats (unread by label/sender) | R | ★★ |
| Apply/remove labels | W | ★ |
| Archive (one or batch) | W | ★ |
| Trash (reversible 30 days) | W | ★ |
| Create draft reply (you send manually) | W | ★ |
| Create new draft | W | ★ |
| Block sender / create filter | W | ★ |
| Unsubscribe via List-Unsubscribe | W | ★ |
| Snooze | W | ★ |
| Save attachment to Drive | W | ★ |
| Detect security alerts → morning brief | R+notify | ★★ |
| Smart triage, "is this important" | R | ★★ |
| Auto-tag receipts/bills/invoices for review | R+W | ★★ |
6.2 Business Gmail, [email protected]¶
All of personal, plus send (always confirm).
| Action | Risk | Effort |
|---|---|---|
| Send draft (with confirm) | S | ★ |
| Reply with proper threading | S | ★ |
| Forward | S | ★ |
| Schedule send | S | ★★ |
| Out-of-office detection on inbound | R | ★★ |
| Follow-up reminders ("Tracy hasn't replied in 3d") | R+notify | ★★ |
| Customer-support triage queue | R | ★★ |
| Sponsor-pitch pipeline (Scout-Pitcher pattern) | R+S | ★★★ |
| Receipt → expense ledger | R+W | ★★ |
| Auto-draft for common patterns | R+W | ★★★ |
| Invoice tracking (sent/paid/overdue) | R+W | ★★ |
6.3 Google Calendar¶
Lower risk, events are easy to undo.
| Action | Risk | Effort |
|---|---|---|
| Create / list / delete | W | ★ (done) |
| Update (description, time, location, attendees) | W | ★ |
| Move event (change time) | W | ★ |
| Find conflicts | R | ★ |
| Find open slot | R | ★★ |
| Multi-calendar (personal + business) | R/W | ★ |
| Add Zoom/Meet link | W | ★ |
| Recurring events | W | ★ |
| Travel time / buffer blocks | W | ★★ |
| Time blocking | W | ★ |
| Day brief, "what's my day look like" | R | ★★ |
| Meeting prep brief 5 min before each | R+notify | ★★★ |
| End-of-day summary | R+notify | ★★ |
| Respond to invites | W | ★ |
6.4 Notion¶
Capabilities ready; what gets used depends on the redesign.
| Action | Risk | Effort |
|---|---|---|
| Search DBs / read schema | R | ★ (done) |
| Query DB with filters | R | ★ (done) |
| Create page in any DB | W | ★ (done) |
| Update page (any field, archive) | W | ★ (done) |
| Append blocks (add content to page) | W | ★ |
| Read page content (body, not just properties) | R | ★ |
| Create new DB (during redesign) | W | ★ |
| Cross-DB rollups via relations | R | ★★ |
What you DO with Notion depends on which DBs you build:
- Inbox, quick capture, sort later
- Tasks, todos with due dates, recurring
- Projects, multi-step things linked to tasks
- Habits, daily check-ins
- Knowledge, "remember that …" retrieved by /recall
- Content, ideas → scripts → published, per brand
- Contacts/CRM, who, last contact, threads
- Reading list: URLs, tags, retrieved by topic
7. Cross-cutting features (the killer apps)¶
| Feature | What | Touches | Effort |
|---|---|---|---|
| Morning brief | 7am push: calendar today, unread top 3, tasks due, wellness, weather | Cal + Gmail + Notion + Context API | ★★★ |
| Email → Task | "Make this email a task" → Notion task with thread link | Gmail + Notion | ★★ |
| Email → Calendar | Parses meeting details from email body → creates event | Gmail + Cal | ★★★ |
| Calendar → Meeting note | Each meeting auto-creates Notion notes page; agenda from email | Cal + Notion + Gmail | ★★★ |
| Sponsor pipeline (Scout-Pitcher-Sender) | Incoming pitch → triage → Notion contact/project → draft reply for approval → send | Gmail + Notion | ★★★ |
| Daily journal | EOD: emails sent, events done, tasks completed → Notion daily page | Cal + Gmail + Notion | ★★ |
| Follow-up watcher | "Tracy hasn't replied since Monday" → inbox bot ping | Gmail + push | ★★ |
| Receipts → ledger | Scan personal+business Gmail for receipts → Notion ledger DB | Gmail + Notion | ★★★ |
| Travel mode | Trip in Calendar → packs Notion travel page + flight/hotel emails | Cal + Gmail + Notion | ★★★ |
| "What did I say to X" | Pulls last 3 threads with someone, summarizes | Gmail | ★★ |
| Birthday/anniversary watcher | Cron checks Notion contacts → pings inbox bot day-of | Notion + push | ★ |
8. Recommended starter pack (after Notion redesign)¶
Six things that compound, in order of "hits hardest first":
| # | Feature | Effort |
|---|---|---|
| 1 | Inbox brain v1: Sonnet + tool registry, all current workflows wired | ~3-4h |
| 2 | update-calendar-event workflow + brain integration ("add description / move / cancel") |
~30 min |
| 3 | Email → Notion task (one-shot capture from inbox) | ~1h |
| 4 | Morning brief push at 7am | ~2h |
| 5 | Follow-up watcher for business Gmail | ~2h |
| 6 | Sponsor pipeline scaffold (drafts only, no auto-send) | ~half-day |
After this, every new feature is mostly registry entries + one workflow. The system gets cheaper to extend the more you use it.
9. Open decisions (need Justin)¶
- Notion DB redesign. Which DBs to build/keep/retire? Suggested baseline:
- Inbox (quick capture, sort later), new
- Tasks, keep existing JustinWieb Tasks
- Projects, keep existing JustinWieb Projects
- Habits, new
- Knowledge, new (for "remember that …")
- Content calendar (per brand), new
- Contacts/CRM, new (for sponsor pipeline)
- Time Tracker, keep, but probably out of scope for brain
- Default routing rule when ambiguous:
| Option | Behavior |
|---|---|
| Inbox-first (recommended) | Everything ambiguous lands in "Inbox" DB; you sort in Notion |
| Best-guess + tag | Brain routes directly, tags
[uncertain]if confidence < 80% | - Top 3-4 daily-use features to anchor build order. The starter pack above is a guess: Justin should pick which actually matters daily.
- Consolidation question, stay per-action or move to generic
<service>-call? Current verdict: per-action, revisit only if fatigue sets in.
10. Files you'll work with¶
| File | Purpose |
|---|---|
scripts/integrations/telegram/inbox_bot.py |
Telegram inlet: Whisper + intent_route + dispatch (to be replaced by brain call) |
scripts/integrations/telegram/inbox_webhook.py |
iOS Shortcut HTTP inlet, same intent_route + dispatch |
scripts/integrations/telegram/inbox_brain.py |
TO BUILD, single Sonnet brain w/ tool registry |
scripts/n8n/call.sh |
Helper used by brain to call n8n workflows |
infra/n8n/workflows/*.json |
Source of truth for every workflow |
data/inbox-context.jsonl |
TO BUILD, context log of last N exchanges |
~/.forge-secrets/n8n.env |
N8N_BASE_URL + N8N_WEBHOOK_SECRET |
~/.forge-secrets/telegram-inbox.env |
Inbox bot token + authorized user ID |
memory/handoffs/building-the-brain-life-os-inbox-2026-04-27.md |
This file |
memory/general/second-brain-vision-2026-04-25.md |
Earlier vision doc, includes Scout-Pitcher pattern |
11. Likely approach (when resuming)¶
Phase 0: Notion redesign (Justin-led, no code)¶
- Justin reviews existing 3 DBs (Tasks, Projects, Time Tracker)
- Decide which new DBs to build (Inbox, Habits, Knowledge, Content, CRM)
- Decide schema for each (minimum viable; can grow)
- Either Justin builds them in Notion UI, or brain-builder session uses
notion-create-page(after we add anotion-create-databaseworkflow) to scaffold
Phase 1: Brain MVP¶
- Add
update-calendar-eventworkflow (5 min) - Build
inbox_brain.py: - Tool registry (start with ~10 tools, calendar CRUD + Notion CRUD + capture-note + schedule-nudge)
- Loop: call
claude -p --model sonnet, parse structured JSON, execute tools, repeat up to N iterations - Context log read/write
- Cut
inbox_bot.pyandinbox_webhook.pyover to brain (replace intent_route+dispatch withinbox_brain.handle()) - Test 6-8 utterances (single-step, multi-step, ambiguous, references)
- Update
reference_telegram_inbox.md, register in MEMORY.md
Phase 2: First killer apps¶
- Email → Notion task (one new tool, brain registry entry)
- Morning brief (cron + push to
@jw_updates_bot)
Phase 3+: One feature at a time¶
Per the menu in §6-7. Each is small once the foundation is there.
12. Don't do¶
- ❌ Don't consolidate workflows while the email chat is editing email workflows. Will break their work mid-flight.
- ❌ Don't wire brain to Notion until Justin's redesign is done (DBs would be wrong).
- ❌ Don't grant any agent OAuth on personal Gmail. Read-only + draft-only forever (per CLAUDE.md security rule).
- ❌ Don't auto-send any business email without per-batch confirmation.
- ❌ Don't use Opus for brain default: Sonnet is right tradeoff. Opus only for design/architecture sessions.
- ❌ Don't build features ahead of Justin picking the starter pack. Wasted work if he doesn't use them.
13. Done when¶
- Justin's Notion redesign decisions captured here (or in a follow-up doc)
-
inbox_brain.pybuilt + tested with ≥6 utterances - Telegram + iOS Shortcut inlets cut over to brain
-
update-calendar-eventworkflow live - First killer app shipped (suggested: morning brief)
-
reference_inbox_brain.mdwritten + registered in MEMORY.md -
reference_telegram_inbox.mdupdated to reflect brain architecture
14. Conversation pointers (this session)¶
Daily log: memory/daily/2026-04-27.md, checkpoints from 14:25 → 16:xx
- Bot-created calendar event cleanup + agentic-router design
- Vision pivot, inbox bot as the life-OS inlet
- Inbox brain build paused: Notion needs redesign first
- Capability menu: Gmail + Calendar + Notion + cross-cutting features
Related references:
- memory/general/second-brain-vision-2026-04-25.md, earlier vision, Scout-Pitcher pattern
- reference_telegram_inbox.md, current inbox bot architecture (now partially stale)
- reference_n8n_outbound.md, n8n outbound calling pattern
- reference_telegram_bot.md, chat bot (@GregTwoPointO_Bot, plugin-based)
- infra/n8n/outbound-pattern.md, workflow conventions