What Is This?
This is a tutorial that shows how to make an AI email assistant that gets smarter over time.
It’s like giving your Gmail a brain… and then sending it to school.
Email comes in ➜ Agent checks memory ➜ Picks action ➜ Replies smartly ➜ Learns from feedback ➜ Improves next time.
What Makes It Smart?
It remembers stuff. But not just one kind of memory—it’s got three:
-
Short-Term Memory (Episodic):
Remembers past emails and what to do with them. -
Long-Term Facts (Semantic):
Knows stuff like your calendar and favorite contacts. -
Instructions That Improve (Procedural):
Learns from feedback and updates how it behaves.
What Can It Do?
- Sort emails: Should it ignore, notify, or respond?
- Write replies: Based on past behavior and facts.
- Learn from mistakes: You give feedback, it improves.
Basically, it’s the intern who actually learns… not just nods.
How It Works (Simple Version)
1. Email Comes In
Someone sends an email—like “Hey, is the API broken?”
2. Bot Reads Memory
Checks old emails that look similar. If last time it was ignored, it may ignore again.
3. Bot Decides What To Do
Should it ignore? Should it alert someone? Or draft a reply?
4. Bot Replies (if needed)
Uses tools like email sender or calendar checker.
5. You Give Feedback
“Hey bot, that was dumb. Say this instead.”
6. Bot Updates Instructions
Next time, it does better.
What’s Inside?
- A few tools: write email, check calendar.
- A brain made with LangGraph + LangMem.
- Some fake memory examples like spam mail or tech issues.
Tools Used
write_email()
— Sends an email (pretend one).check_calendar_availability()
— Fakes calendar times.- Memory tools — Adds, finds, and updates memories.
Example Run (Real Output)
Before Learning:
Email: “Quick question about API docs”
Response: “How can I assist you today?”
(Yes, that’s it. Bot was lazy.)
After Feedback:
Response: “Hi Alice, looks like the API docs need fixing. Here’s how I can help…”
(Now we’re talking.)
What’s Behind the Scenes?
- Email enters
- Triage — Bot checks examples to decide action
- Reply agent — If reply needed, it crafts one
- Procedural memory — Instructions get better
- Graph — Connects all steps like a flowchart
Built using fancy stuff like LangGraph
, LangChain
, and OpenAI GPT-4o-mini
.
(But ignore the jargon—it’s just the engine, not the car.)
Stored Memories (Examples)
{
"email": {
"subject": "BIG SALE!!!"
},
"label": "ignore"
}
{
"email": {
"subject": "API Documentation Issue"
},
"label": "respond"
}
These teach the bot what to do when something similar comes in again.
Why Feedback Matters
Telling the bot when it messes up makes it better.
Example:
“If it says API docs, it’s important. Always respond, and be helpful.”
Boom. The bot rewrites its brain, and next time it sounds like it knows what it’s doing.
Why This Is Cool
- It remembers like a real person.
- It learns from mistakes.
- You don’t need to babysit it.
- You can plug it into more than email later.
It’s not just smart—it gets smarter. No excuses.
Try It or Read More
Quick Recap
Step | What It Does |
---|---|
Email comes in | Looks like junk? Spam? Urgent? |
Checks memory | What did I do with this last time? |
Responds | Writes reply or ignores politely |
Gets feedback | “Don’t do that again” |
Updates itself | Becomes slightly less dumb |
Final Thought
It’s like training a goldfish to do email.
But this one actually remembers.