
Photo by the author
# Entry
Email overload is a fact of life. You open your inbox and find dozens of messages and immediately start mentally triaging. Which ones need attention now? Which ones can wait?
It’s exhausting and it’s effortless to miss something crucial while drowning in notifications.
Here’s a better way: Build an automated Gmail agent in it n8n which rates each incoming email on a scale of 0-100 and takes action based on priority. The system operates continuously and processes emails as they are received.


Complete n8n workflow showing email scoring and priority-based routing | Photo by the author
# Why n8n for email automation?
n8n makes this kind of automation basic. If you are modern to creating workflows with n8n, start with this basic guide First. Visual workflow design allows you to see all the logic at a glance. Native Gmail integration handles authentication without having to deal with OAuth2. Code nodes provide full control over the scoring algorithm using JavaScript. Once launched, it processes emails in the cloud 24/7.
# How the workflow works
The agent uses 13 nodes organized in a clear processing pipeline:
- Gmail trigger monitors your inbox for modern emails
- Advanced email scoring analyzes each message and calculates a priority score
- Route by priority divides emails into four tracks based on the score
- Priority actions complete the appropriate tasks for each category
- Analytical logging tracks metrics so you can improve the system
Four priority levels support different email types:
- Critical (75-100): Starred, marked, triggers Slack alerts
- High (50-74): Marked, creates tasks in the project manager
- Medium (30-49): Labeled, in line for daily inspection
- Low (0-29): Marked with a label, marked as read
# What you will need
Before you start:
- n8n account (in the cloud or on your own server)
- Gmail account for automation
- Optional: Slack webhook URL for critical alerts
- Optional: Task management API endpoint (Asana, Todoist, etc.)
Download the workflow JSON file (attached) and import it into your n8n instance. You need to configure credentials for these nodes:
- Gmail trigger and Gmail action nodes: Link your Gmail OAuth2 credentials (setup guide).
- The knot is loose: Add the webhook URL (or disable this node if not needed).
- HTTP Request Nodes (Task Manager): Add task management API endpoints and authentication for high and medium priority tasks (or disable if not needed).
- HTTP Request (Analytics): Add an analytics endpoint or disable if you don’t track externally.
The workflow will display warnings about credentials in n8n until they are configured. Start with Gmail credentials to test the basic scoring logic, then add other integrations as needed.
# Configuring a Gmail trigger
The Gmail Trigger node polls your inbox for modern emails every minute (you can adjust this interval in the node settings if necessary). Configure it to only watch the INBOX folder so that spam and junk don’t trigger your workflow.
When a modern email arrives, the trigger captures everything you need: sender details, subject, content (both plain text and HTML), attachments, and the message ID to track. Send yourself a test email to see if the trigger works, then check the execution log in n8n to see the scoring in action.
# How email scoring works
The Code node implements a multi-factor scoring algorithm that checks three things:
Sender reputation: The algorithm starts with a base result and adjusts it based on the sender’s domain, email address patterns, and whether they are on your VIP list. Emails from noreply@ addresses will be penalized. Messages from executives or crucial customer domains receive extra points.
Content characteristics: The algorithm searches for urgent keywords (e.g. “as soon as possible”, “urgent”, “immediately”), checks questions requiring answers and awards points for attachments.
Category classification: The system divides emails into categories such as customer communication, finance, meetings and technical issues. Customer and financial emails get higher priority.
The final score combines all three factors, to a maximum of 100. You can see the full implementation in the attached JSON workflow (look for the “Advanced Email Scoring” node).
# Priority routes and activities
Once the email has a result, Switch the node directs it to the appropriate path.
// Critical Priority (75-100)
Urgent customer requests, communication with the director, time-sensitive matters. Workflow:
- Label it “Priority_Critical” in Gmail.
- Star the message for quick access
- Sends a Slack alert with sender, subject, result, and timestamp
This three-tier approach means you’ll see critical emails no matter where you work.
// High priority (50-74)
Meeting requests from stakeholders, customer questions, project updates. Workflow:
- Marks it as “Priority_High”
- Creates a task in the project manager with details and a link back to the email
These emails automatically go into your workflow.
// Medium priority (30-49)
Team updates, informational messages, standard business communications. Workflow:
- Marks it as “Priority_Medium”
- It queues it up for review at a designated email time
You can batch process them later.
// Low priority (0-29)
Newsletters, automatic notifications, marketing emails. Workflow:
- Marks it as “Priority_Low”
- Marks as read
It has been checked and submitted.
# Tracking what works
The analytics node runs in parallel with everything else and captures data from each email: timestamp, sender domain, score and priority level, category and action taken.
This data helps validate the scoring algorithm. Which senders consistently generate high priority emails? What categories do you get most often? You can improve the system based on real data.
# Customization to your needs
The workflow is designed to be modifiable. Here’s what you’ll typically want to change:
VIP domains: Open the “Advanced Email Scoring” JSON node and locate the file vipDomains array. Add domains for your crucial customers, partners and business accounts.
Keyword categories: The algorithm uses keyword lists to classify emails. If you’re in finance, add terms like “audit,” “compliance,” “regulations.” Data scientists can add “model”, “dataset”, “pipeline”. Customize them based on what’s crucial to your job.
Priority thresholds: If you’re receiving too many critical alerts, raise your threshold from 75 to 80. If you’re missing crucial emails, lower it to 70. Monitor your patterns for the first week and adjust.
External services: Replace placeholder URLs with the actual Slack webhook, task manager API, and analytics endpoints. If you do not exploit certain services, please disable these nodes or replace them with alternative ones.
# When something goes wrong
- Emails are not triggering: Check that the Gmail activator is lively and polling every minute. Test your Gmail login details.
- Priority results seem dated: Review your keyword lists and add domain-specific terms. Customize point values based on email patterns.
- Slack notifications not working: Check the webhook URL and permissions. Test it outside n8n first.
- Gmail labels are not applied: Create labels manually in Gmail before running the workflow: Priority_Critical, Priority_High, Priority_Medium, Priority_Low. Or modify the workflow to exploit labels you already have.
# Continued
Currently, it is an automated workflow that works according to predefined rules. Once it’s up and running, you can turn it into a true autonomous agent by adding the following features:
Artificial intelligence integration: To add OpenAI Or Claudius to perform a semantic analysis of the content of e-mail messages. This goes beyond keyword matching to actual understanding. AI can extract action items, detect sentiment, and even generate draft responses. This is where the workflow becomes an agent – making knowledgeable decisions rather than following immobile rules.
Sender learning: Track which senders you respond to consistently and quickly. The workflow can learn your hidden priorities and adjust results accordingly over time. This adaptive behavior is a key feature of agent-based systems.
Following threads: Track email conversations over time. Emails in lively threads can automatically change priority based on context and conversation history.
Astute automatic replies: Detect frequently asked questions and instantly send templated answers, while the AI learns which answers work best.
Calendar integration: When emails mention meetings or deadlines, automatically create calendar events with astute scheduling suggestions.
# Summary
This n8n workflow transforms email from interruption to an organized system. Each incoming message is automatically analyzed and prioritized.
Start with a foundation, then add sophistication over time. Adjust scoring to your communication patterns. Adjust the thresholds as needed. Integrate with the tools you already exploit.
Download the workflow, connect Gmail, customize your grading logic and take control of your inbox.
# Recommended resources
Vinod Chugani was born in India and raised in Japan and brings a global perspective to data science and machine education. It bridges the gap between emerging AI technologies and their practical implementation for working professionals. Vinod focuses on creating accessible learning paths for complicated topics such as agentic artificial intelligence, performance optimization, and AI engineering. Focuses on practical machine learning implementations and mentoring the next generation of data scientists through live sessions and personalized guidance.
