
Weekend Agent Challenge: InboxTriage
The agent that triages your inbox before you wake up.
Vision & What the Agent Does
Most people start the day losing. You open your laptop and the inbox is already a
mess — newsletters, automated notifications, a couple of genuinely urgent
threads, and two or three real asks from real people, all shuffled together. The
first thirty minutes go to sorting instead of doing. That half hour is the
freshest, highest-leverage part of the day, and it evaporates into triage.
InboxTriage exists to give that half hour back. It's an always-on agent that
wakes up before you do, reads everything that landed overnight, and has a single,
prioritized morning brief waiting when you open your laptop. Crucially, it
doesn't just summarize — it decides:
- what needs a reply today,
- what's a FYI worth skimming,
- what's noise it can safely set aside, and
- which threads have gone quiet and deserve a nudge.
For the top few "reply today" items, it goes one step further and drafts a
suggested reply you can approve, edit, or ignore.
What triggers it: nothing you touch. An Amazon EventBridge Scheduler cron
(
cron(0 6 * * ? *) ) fires at 6 AM every day and invokes the agent directly.
There is deliberately no button and no manual path — "always-on" is the whole
point.What it does on its own: on each run it fetches new mail since the last run,
classifies and scores every message with a model, detects stale threads you owe
a reply on, drafts replies for the top three reply-today items, and assembles a
brief.
How it reports back: a clean, prioritized morning-brief email delivered via
Amazon SES — a two-sentence "here's your day" opener, then the ranked
reply-today list with suggested drafts inline, then the stale-thread nudges, then
the FYIs. The email itself, timestamped at 6 AM, is the proof it ran while you
were asleep.
One rule is baked into the design and never bent: InboxTriage drafts but never
sends or deletes anything. Every action that changes state stays with the human.
That's not a config toggle you could flip — there is simply no send-a-reply or
delete-mail code path in the system. The only outbound email it can produce is
the brief, addressed to you.
How You Built It
The core is a small, linear pipeline, one module per stage:
fetch → classify → detect-stale → draft → assemble → send └──── dedup + run log (DynamoDB) ────┘A few decisions shaped it:
Draft-only as a structural guarantee, not a promise. It would have been easy
to add a "send" button and gate it behind a flag. I deliberately didn't. The
sender module can only send the brief to the owner; there is no function
anywhere that replies to source mail. If you can't do the dangerous thing, you
can't do it by accident.One interface in front of the model. Everything talks to Bedrock through a
single
LLMClient with one method, complete(system, user) . Production uses a
BedrockClient (Amazon Nova by default, via the unified Converse API); tests
and local runs use a ScriptedClient with canned responses. Swapping models —
even to a different family — is a one-line change to BEDROCK_MODEL_ID , because
Converse normalizes the call shape. This also made the whole thing testable
without spending a cent on inference.Prompts as files, not strings. Classification, prioritization, drafting, and
nudge prompts live as plain
.txt templates in prompts/ . Tuning a prompt is a
text edit in its own diff — no code change, no redeploy of logic.Challenges, and how I got past them
- Reliable classification. My first attempt batched many emails into one
prompt to save calls. The model drifted — labels bled together and priorities
became mush. I switched to one message per call with a tight,
JSON-only prompt and a tolerant parser (
extract_json) that survives prose or a stray```jsonfence. Anything still unparseable degrades to "FYI" so a message is never silently dropped.
- Not processing the same mail twice. Overlapping windows and retries would otherwise double-count. DynamoDB holds a checkpoint (end of the last successful window) plus dedup markers per message id (with a TTL so the table self-prunes). The checkpoint only advances after a successful send, so a crash mid-run re-processes its window next time instead of losing mail.
- Email auth without leaking secrets. Credentials never live in code or env vars — they're pulled from AWS Secrets Manager at runtime and cached for the warm container. The IMAP mailbox is opened read-only so the agent physically cannot mutate your inbox.
- A brief that's actually pleasant to read. The brief renders to both HTML (for the eye) and plain text (for deliverability and screen readers), and both are snapshot-tested so a prompt tweak can't quietly break the layout.
AWS Services Used / Architecture Overview
Concern | Service |
|---|---|
Autonomous trigger | Amazon EventBridge Scheduler — cron(0 6 * * ? *) , invokes Lambda directly |
Agent orchestration | AWS Lambda (Python 3.12) |
Reasoning layer | Amazon Bedrock — Nova (classify, score, draft, nudge) |
Dedup + checkpoint + run history | Amazon DynamoDB (single-table) |
Brief delivery | Amazon SES |
Email read path | IMAP (default) or Gmail API read-only |
Secrets | AWS Secrets Manager |
(optional) Run-history dashboard | AWS Amplify Hosting + Cognito |
6:00 AM ─► EventBridge Scheduler ─► AWS Lambda (orchestrator) │ ┌───────────────────────────┼───────────────────────────┐ DynamoDB Amazon Bedrock Amazon SES (dedup + checkpoint + log) (Nova reasoning) (morning-brief email)How it's triggered, concretely: the schedule is an
AWS::Scheduler::Schedule with a dedicated IAM role scoped to
lambda:InvokeFunction on this one function, State: ENABLED on deploy. The next
6 AM tick produces the first brief with zero human involvement. The whole stack
is defined in AWS SAM ( infra/template.yaml ) and fits the AWS Free Tier.What You Learned
This was my first time wiring EventBridge Scheduler straight to a Lambda as
the sole trigger, and it reframed how I think about "an app" — there's no
frontend, no request, no user in the loop at run time. The product is the
scheduled side effect.
A few other firsts and takeaways:
- Bedrock prompt design for structure. Getting reliable JSON out of a model is less about clever wording and more about a narrow task per call plus a forgiving parser. One-email-at-a-time beat clever batching decisively.
- DynamoDB as agent memory. A single-table design cleanly held three different concerns (checkpoint, dedup, history) and the TTL feature meant I never had to write a cleanup job.
- SES deliverability basics — verifying senders, the sandbox, and why a plain-text alternative part matters.
- Designing for "can't do harm." The most valuable design move was making the unsafe action impossible, not disabled. That's a pattern I'll reuse for any agent that touches something people care about.
Link to App or Repo
Source (Lambda handler, prompt templates, SAM infra, tests, and a
zero-AWS local runner):
github.com/swarit-1/inboxtriage .
Run the whole pipeline on sample mail with no AWS account —
make preview writes
the exact HTML brief the agent produces.
Enjoyed reading this content? Let the author know!
Your likes, comments, shares, and saves help creators reach more builders.
Loading recommendations
Loading article