After building a File Organizer AI Agent, we now move to one of the most impactful real-world automations: managing email overload.
Emails are one of the most common sources of daily information fatigue. Important messages get buried under newsletters, promotions, and low-priority notifications.
In this project, we will build an Email Summarizer AI Agent using n8n, Ollama, and Phi-3.
This agent will:
Monitor incoming emails
Extract email content
Summarize messages
Identify importance level
Provide actionable insights
Everything runs locally, meaning no external APIs or cloud AI services are required.
What We’re Building
The workflow architecture looks like this:
New Email
↓
n8n Email Trigger
↓
Extract Email Content
↓
Phi-3 Summarization (via Ollama)
↓
Classify Importance
↓
Output Summary / Notification
Example transformation:
Subject: Meeting rescheduled to Friday
Original Email:
Long discussion about schedule changes...
↓
Phi-3 Output:
Summary: Meeting moved to Friday
Importance: High
Action: Update calendar
Why Build an Email Summarizer Agent?
Unlike file organization, email management involves interpretation and prioritization.
A good email agent helps you:
Reduce reading time
Focus on important messages
Avoid missing critical updates
Automatically filter noise
This is where AI adds real value.
Step 1: Configure Email Input in n8n
Open n8n and create a new workflow:
AI Email Summarizer
Now add an email trigger node.
Depending on your setup, this could be:
IMAP Email Trigger
Gmail Trigger
Outlook Trigger
Configure it to watch your inbox in real time.
Once set, every new email will trigger the workflow automatically.
Step 2: Extract Email Content
After the trigger node, add a data extraction step.
We only need:
Subject
Sender
Email body
Example structure:
{
"subject": "Project Update",
"from": "team@company.com",
"body": "We have updated the project timeline..."
}
Keep the input clean before sending it to the AI model.
Step 3: Connect Phi-3 via Ollama
Add an AI Agent node and configure:
Model Provider
Ollama
Model
Phi-3
Endpoint
http://localhost:11434
This ensures all processing stays local on your machine.
Step 4: Create the Summarization Prompt
Prompt design is critical for consistent results.
Use the following structured prompt:
You are an email assistant.
Your task is to:
1. Summarize the email in 1–2 sentences
2. Identify importance (High, Medium, Low)
3. Suggest a possible action
Email:
Subject: {{subject}}
From: {{from}}
Body: {{body}}
Return format:
Summary:
Importance:
Action:
This forces structured output, which is essential for automation.
Step 5: Example AI Output
For an email like:
Subject: Server Maintenance Tonight
Body: We will perform maintenance at 11 PM...
Phi-3 might return:
Summary: Server maintenance scheduled tonight at 11 PM.
Importance: High
Action: Inform stakeholders and prepare downtime notice.
This structured format allows n8n to make decisions automatically.
Step 6: Add Decision Logic
After the AI node, add a Switch node.
We will classify emails based on importance.
Rules:
High → Immediate Notification
Medium → Daily Digest
Low → Store Only
This is the decision layer of the agent.
Step 7: Configure Output Actions
Now we define what happens for each category.
High Priority Emails
Send notification (Telegram, Discord, Email)
Mark as unread
Flag for review
Medium Priority Emails
Add to daily summary log
Store in database or spreadsheet
Low Priority Emails
Archive automatically
No notification
Step 8: Optional Enhancement — Daily Digest System
Instead of sending every summary individually, you can batch medium-priority emails.
Workflow:
Collect Emails (24h)
↓
Group Data
↓
Phi-3 Summary Report
↓
Send Daily Digest
This creates a personal AI assistant that summarizes your entire inbox each day.
Step 9: Testing the Agent
Send test emails such as:
Example 1
Subject: Invoice for April Services
Example 2
Subject: Weekly Newsletter
Example 3
Subject: Urgent: Password Reset Required
Observe how the AI classifies and summarizes each message.
Why This Architecture Works
This system separates responsibilities clearly:
n8n Handles
Email monitoring
Data routing
Notifications
Storage
Scheduling
Phi-3 Handles
Understanding email content
Summarization
Priority classification
Action suggestions
This division ensures reliability and scalability.
Improving the Agent
Once the basic system works, you can enhance it with:
1. Calendar Integration
Automatically create events from emails.
2. Task Management
Convert important emails into tasks (Todoist, Notion, etc.).
3. Sender Reputation System
Prioritize emails based on sender history.
4. Spam Filtering Layer
Use AI to detect and ignore irrelevant messages.
5. Memory System
Store past summaries to improve future classification.
Limitations of the Basic Version
While powerful, this initial version has limitations:
No long-term memory
No deep contextual understanding
Relies on email content quality
May misclassify ambiguous messages
These will be addressed in later advanced agent designs.
What We Learned
This project reinforces the core AI agent pattern:
Input → Process → Reason → Decide → Act
In this case:
Input: Email
Process: n8n extraction
Reason: Phi-3 summarization
Decide: Importance classification
Act: Notification or storage
This pattern is the foundation of all practical AI automation systems.
Conclusion
We have now built a fully functional Email Summarizer AI Agent that runs entirely on local infrastructure.
It demonstrates how AI can be used not just for conversation, but for real productivity improvement.
With n8n handling automation and Phi-3 providing intelligence, we can transform overwhelming email streams into structured, actionable insights.
What’s Next?
Now that we can organize files and manage emails, the next step is expanding our agent capabilities further.
In the next article, we will build:
How to Give Your AI Agent Memory Using Simple Storage
This will allow our agents to remember past interactions, improve decision-making, and become more context-aware over time.
No comments:
Post a Comment