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
chatIdinto 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.
Classify Gmail Emails with GPT-4o Mini and Send Telegram Notifications
This n8n workflow automates the classification of incoming Gmail emails using an AI agent powered by GPT-4o Mini and sends real-time notifications to Telegram based on the classification. This helps you quickly triage important emails and stay informed without manually checking your inbox.
What it does
- Monitors Gmail: Continuously listens for new emails in your specified Gmail account.
- Extracts Email Content: Retrieves the subject and body of each new email.
- Classifies Email with AI: Sends the email content to an AI agent (configured with an OpenAI Chat Model) to classify its category (e.g., "Important", "Spam", "Marketing", "Personal").
- Sends Telegram Notification: Based on the AI classification, a notification containing the email's subject, sender, and classified category is sent to a designated Telegram chat.
Prerequisites/Requirements
To use this workflow, you will need:
- n8n Instance: A running n8n instance.
- Gmail Account: A Gmail account configured as a credential in n8n.
- Telegram Account: A Telegram Bot Token and Chat ID configured as a credential in n8n.
- OpenAI API Key: An OpenAI API key (for GPT-4o Mini or another compatible model) configured as a credential in n8n.
Setup/Usage
- Import the Workflow: Download the provided JSON and import it into your n8n instance.
- Configure Credentials:
- Gmail Trigger: Configure your Gmail OAuth2 credential.
- OpenAI Chat Model: Configure your OpenAI API Key credential.
- Telegram: Configure your Telegram Bot Token and specify the Chat ID where notifications should be sent.
- Configure AI Agent (Text Classifier):
- In the "Text Classifier" node, you will define the categories you want your emails to be classified into. For example:
["Important", "Spam", "Marketing", "Personal"]. - The "OpenAI Chat Model" node should be configured to use a suitable model like
gpt-4o-minifor cost-effectiveness and performance.
- In the "Text Classifier" node, you will define the categories you want your emails to be classified into. For example:
- Activate the Workflow: Once all credentials and configurations are set, activate the workflow. It will then start monitoring your Gmail for new emails and sending Telegram notifications.
Related Templates
Automate Dutch Public Procurement Data Collection with TenderNed
TenderNed Public Procurement What This Workflow Does This workflow automates the collection of public procurement data from TenderNed (the official Dutch tender platform). It: Fetches the latest tender publications from the TenderNed API Retrieves detailed information in both XML and JSON formats for each tender Parses and extracts key information like organization names, titles, descriptions, and reference numbers Filters results based on your custom criteria Stores the data in a database for easy querying and analysis Setup Instructions This template comes with sticky notes providing step-by-step instructions in Dutch and various query options you can customize. Prerequisites TenderNed API Access - Register at TenderNed for API credentials Configuration Steps Set up TenderNed credentials: Add HTTP Basic Auth credentials with your TenderNed API username and password Apply these credentials to the three HTTP Request nodes: "Tenderned Publicaties" "Haal XML Details" "Haal JSON Details" Customize filters: Modify the "Filter op ..." node to match your specific requirements Examples: specific organizations, contract values, regions, etc. How It Works Step 1: Trigger The workflow can be triggered either manually for testing or automatically on a daily schedule. Step 2: Fetch Publications Makes an API call to TenderNed to retrieve a list of recent publications (up to 100 per request). Step 3: Process & Split Extracts the tender array from the response and splits it into individual items for processing. Step 4: Fetch Details For each tender, the workflow makes two parallel API calls: XML endpoint - Retrieves the complete tender documentation in XML format JSON endpoint - Fetches metadata including reference numbers and keywords Step 5: Parse & Merge Parses the XML data and merges it with the JSON metadata and batch information into a single data structure. Step 6: Extract Fields Maps the raw API data to clean, structured fields including: Publication ID and date Organization name Tender title and description Reference numbers (kenmerk, TED number) Step 7: Filter Applies your custom filter criteria to focus on relevant tenders only. Step 8: Store Inserts the processed data into your database for storage and future analysis. Customization Tips Modify API Parameters In the "Tenderned Publicaties" node, you can adjust: offset: Starting position for pagination size: Number of results per request (max 100) Add query parameters for date ranges, status filters, etc. Add More Fields Extend the "Splits Alle Velden" node to extract additional fields from the XML/JSON data, such as: Contract value estimates Deadline dates CPV codes (procurement classification) Contact information Integrate Notifications Add a Slack, Email, or Discord node after the filter to get notified about new matching tenders. Incremental Updates Modify the workflow to only fetch new tenders by: Storing the last execution timestamp Adding date filters to the API query Only processing publications newer than the last run Troubleshooting No data returned? Verify your TenderNed API credentials are correct Check that you have setup youre filter proper Need help setting this up or interested in a complete tender analysis solution? Get in touch 🔗 LinkedIn – Wessel Bulte
Auto-reply & create Linear tickets from Gmail with GPT-5, gotoHuman & human review
This workflow automatically classifies every new email from your linked mailbox, drafts a personalized reply, and creates Linear tickets for bugs or feature requests. It uses a human-in-the-loop with gotoHuman and continuously improves itself by learning from approved examples. How it works The workflow triggers on every new email from your linked mailbox. Self-learning Email Classifier: an AI model categorizes the email into defined categories (e.g., Bug Report, Feature Request, Sales Opportunity, etc.). It fetches previously approved classification examples from gotoHuman to refine decisions. Self-learning Email Writer: the AI drafts a reply to the email. It learns over time by using previously approved replies from gotoHuman, with per-classification context to tailor tone and style (e.g., different style for sales vs. bug reports). Human Review in gotoHuman: review the classification and the drafted reply. Drafts can be edited or retried. Approved values are used to train the self-learning agents. Send approved Reply: the approved response is sent as a reply to the email thread. Create ticket: if the classification is Bug or Feature Request, a ticket is created by another AI agent in Linear. Human Review in gotoHuman: How to set up Most importantly, install the gotoHuman node before importing this template! (Just add the node to a blank canvas before importing) Set up credentials for gotoHuman, OpenAI, your email provider (e.g. Gmail), and Linear. In gotoHuman, select and create the pre-built review template "Support email agent" or import the ID: 6fzuCJlFYJtlu9mGYcVT. Select this template in the gotoHuman node. In the "gotoHuman: Fetch approved examples" http nodes you need to add your formId. It is the ID of the review template that you just created/imported in gotoHuman. Requirements gotoHuman (human supervision, memory for self-learning) OpenAI (classification, drafting) Gmail or your preferred email provider (for email trigger+replies) Linear (ticketing) How to customize Expand or refine the categories used by the classifier. Update the prompt to reflect your own taxonomy. Filter fetched training data from gotoHuman by reviewer so the writer adapts to their personalized tone and preferences. Add more context to the AI email writer (calendar events, FAQs, product docs) to improve reply quality.
🎓 How to transform unstructured email data into structured format with AI agent
This workflow automates the process of extracting structured, usable information from unstructured email messages across multiple platforms. It connects directly to Gmail, Outlook, and IMAP accounts, retrieves incoming emails, and sends their content to an AI-powered parsing agent built on OpenAI GPT models. The AI agent analyzes each email, identifies relevant details, and returns a clean JSON structure containing key fields: From – sender’s email address To – recipient’s email address Subject – email subject line Summary – short AI-generated summary of the email body The extracted information is then automatically inserted into an n8n Data Table, creating a structured database of email metadata and summaries ready for indexing, reporting, or integration with other tools. --- Key Benefits ✅ Full Automation: Eliminates manual reading and data entry from incoming emails. ✅ Multi-Source Integration: Handles data from different email providers seamlessly. ✅ AI-Driven Accuracy: Uses advanced language models to interpret complex or unformatted content. ✅ Structured Storage: Creates a standardized, query-ready dataset from previously unstructured text. ✅ Time Efficiency: Processes emails in real time, improving productivity and response speed. *✅ Scalability: Easily extendable to handle additional sources or extract more data fields. --- How it works This workflow automates the transformation of unstructured email data into a structured, queryable format. It operates through a series of connected steps: Email Triggering: The workflow is initiated by one of three different email triggers (Gmail, Microsoft Outlook, or a generic IMAP account), which constantly monitor for new incoming emails. AI-Powered Parsing & Structuring: When a new email is detected, its raw, unstructured content is passed to a central "Parsing Agent." This agent uses a specified OpenAI language model to intelligently analyze the email text. Data Extraction & Standardization: Following a predefined system prompt, the AI agent extracts key information from the email, such as the sender, recipient, subject, and a generated summary. It then forces the output into a strict JSON structure using a "Structured Output Parser" node, ensuring data consistency. Data Storage: Finally, the clean, structured data (the from, to, subject, and summarize fields) is inserted as a new row into a specified n8n Data Table, creating a searchable and reportable database of email information. --- Set up steps To implement this workflow, follow these configuration steps: Prepare the Data Table: Create a new Data Table within n8n. Define the columns with the following names and string type: From, To, Subject, and Summary. Configure Email Credentials: Set up the credential connections for the email services you wish to use (Gmail OAuth2, Microsoft Outlook OAuth2, and/or IMAP). Ensure the accounts have the necessary permissions to read emails. Configure AI Model Credentials: Set up the OpenAI API credential with a valid API key. The workflow is configured to use the model, but this can be changed in the respective nodes if needed. Connect the Nodes: The workflow canvas is already correctly wired. Visually confirm that the email triggers are connected to the "Parsing Agent," which is connected to the "Insert row" (Data Table) node. Also, ensure the "OpenAI Chat Model" and "Structured Output Parser" are connected to the "Parsing Agent" as its AI model and output parser, respectively. Activate the Workflow: Save the workflow and toggle the "Active" switch to ON. The triggers will begin polling for new emails according to their schedule (e.g., every minute), and the automation will start processing incoming messages. --- Need help customizing? Contact me for consulting and support or add me on Linkedin.