Classify Gmail Emails with GPT-4o mini and Send Telegram Notifications
Gmail AI Email Classifier & Notifier
Since Gmail inboxes can quickly become cluttered, this workflow provides an automated AI-based email classification system. It listens for new emails, categorizes them using an AI classifier, applies Gmail labels, and sends you a Telegram notification with a quick summary.
If you often miss urgent client messages or struggle with sorting work vs. promotions, this workflow ensures you never overlook important emails.
Use case: Especially useful for professionals who receive a high volume of mixed emails (clients, work, promotions). The workflow automatically labels and notifies you of new emails based on their category.
How It Works
Trigger Input
The workflow starts with the Gmail Trigger node, which listens for new incoming emails. By default, it polls every minute, but you can adjust the polling frequency. Email metadata (from, subject, body) is passed downstream.
Example JSON input:
{
"from": "client@example.com",
"subject": "Urgent project deadline",
"text": "Please review the attached contract ASAP"
}
Classify Email (AI)
The Classification Agent (powered by OpenAI via LangChain) receives the email data. It sorts the email into one of four categories:
High Priority – urgent, time-sensitive
Work Related – general work emails
Promotions – newsletters, offers, sales
Other – uncategorized emails
The classifier uses a system prompt to ensure output is returned in JSON format for downstream processing.
Apply Gmail Labels
Based on classification, the workflow applies the corresponding Gmail label:
High Priority → “Important + Starred”
Work Related → “Work” (custom Gmail label)
Promotions → “Promotions” (custom Gmail label)
Each label must already exist in Gmail for the operation to work.
Generate Notification
The AI Agent (notification assistant) takes the classified email and rewrites it into a short, casual notification. Example notification:
[High Priority] New email from client@example.com
Subject: Urgent project deadline
"Please review the attached contract ASAP"
Send to Telegram
The Telegram node sends the generated notification to your personal chat ID. Requires a Telegram bot created with @BotFather and your chat ID configured.
How to Use
Import this workflow into n8n. Set up Gmail OAuth2 credentials and connect your Gmail account. Create Gmail labels: High Priority, Work Related, Promotions. Set up a Telegram bot in @BotFather and copy your chatId into the node. Run the workflow — every new email will now be classified, labeled, and notified.
Requirements
n8n Gmail Trigger** with Gmail OAuth2 credentials OpenAI API key** configured for LangChain nodes Telegram bot** created via @BotFather with your chat ID Existing Gmail labels (Work, Promotions, etc.)
Customizing This Workflow
You can extend it by:
Adding more categories** – e.g., “Finance,” “Personal,” or “Spam.” Changing the notification channel** – send to Slack, Discord, or SMS instead of Telegram. Adjusting classification rules** – edit the system prompt for finer-grained AI sorting. Changing polling frequency** – set Gmail Trigger to every 5 minutes instead of every minute. Expanding extracted fields** – include attachments, links, or CC addresses in the notification.
Related Templates
Instagram Full Profile Scraper with Apify and Google Sheets
📸 Instagram Full Profile Scraper with Apify and Google Sheets This n8n workflow automates the process of scraping ful...
Technology News Workflow Explanation with Key Services
This workflow contains community nodes that are only compatible with the self-hosted version of n8n. Auto-Publish Techn...
Auto-classify Gmail emails with AI and apply labels for inbox organization
Who is this for? Professionals and individuals who receive high volumes of emails, those who want to automatically organ...
🔒 Please log in to import templates to n8n and favorite templates
Workflow Visualization
Loading...
Preparing workflow renderer
Comments (0)
Login to post comments