Automate Gmail Email Sorting with Telegram & n8n AI

This n8n workflow tackles the common pain of inbox overload by automatically archiving and labeling Gmail emails based on AI analysis triggered via Telegram. It simplifies email management by accurately categorizing necessary versus unnecessary emails, saving users hours weekly.
gmail
telegramTrigger
agent
+6
Workflow Identifier: 1229
NODES in Use: manualTrigger, telegramTrigger, gmail, filter, agent, gmailTool, aggregate, telegram, lmChatOpenRouter
Automate Gmail sorting with n8n and Telegram

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What this workflow does

This workflow sorts Gmail inbox emails automatically. It uses AI to decide which emails to keep and which to archive. The workflow starts when a user sends a message to a Telegram bot. Then, it scans all inbox emails, checks if they are already sorted, and uses AI to label or archive them. Finally, it sends a summary back through Telegram. This saves time by reducing manual email sorting and helps find important emails faster.


Who should use this workflow

Users with busy Gmail inboxes can benefit from this automation. It suits people who get many emails every day and struggle to organize them. Anyone wanting to stop missing important emails or wasting time on manual sorting will find it helpful. Users comfortable sending simple messages in Telegram and connecting their Gmail and AI accounts also fit well.


Tools and services used


How this workflow works

Inputs

The workflow starts when the Telegram bot receives any user message. It then accesses all Gmail emails labeled “INBOX”. It filters out emails already labeled as “NotNeed” or “MustRead”.

Processing steps

Each remaining email is sent to the AI model. The AI reads the email’s details and decides if it should be archived or labeled as important. Appropriate Gmail actions run: archive (remove INBOX label) or apply labels from the AI result. All AI decisions are collected for a report.

Outputs

The workflow sends a summary message back to the Telegram chat. This report shows how many emails were archived or labeled and any notes from AI.


Beginner step-by-step: How to use this workflow in n8n

1. Import the workflow

  1. Download the workflow file using the Download button on this page.
  2. Inside the n8n editor, click “Import from File” and select the downloaded file.

2. Add your credentials

  1. Fill in Telegram Bot API credentials to connect the Telegram Trigger and Telegram nodes.
  2. Add Gmail OAuth2 credentials with modify scope for the Gmail nodes.
  3. Enter your OpenRouter API key in the OpenRouter Chat Model node.

3. Update settings if needed

  1. Check and update Gmail label names or IDs in the label setter and archiver nodes if custom labels exist.
  2. Confirm the Telegram chat ID for summary messages matches your bot conversations.

4. Test the workflow

  1. Use the manualTrigger node or send a message to your Telegram bot to start the workflow.
  2. Watch node executions in n8n to verify emails are categorized correctly.

5. Activate for production

  1. Switch the workflow from draft to active mode.
  2. Monitor logs for errors and adjust as needed.

Customization ideas


Possibilities and failures to watch for

  • Telegram trigger may fail if the bot webhook URL is not set up correctly.
  • Gmail nodes require proper OAuth scopes; missing scopes cause label or archive failures.
  • AI output depends on clear instructions. If labels or archive results are wrong, review the prompt.
  • Incorrect label IDs cause Gmail errors; verify labels exist in the Gmail account before use.

Summary of expected results

✓ Saves daily hours otherwise spent on manual email sorting.
✓ Automatically archives junk emails and labels important ones.
✓ Sends summaries so users know what changed in their inbox.
✓ Reduces missed emails and inbox stress.
✓ Works triggered by simple Telegram messages, easy to control.


Automate Gmail sorting with n8n and Telegram

Visit through Desktop to Interact with the Workflow.

Author
Written By
Vikash Kumar
Building AI agents, n8n workflows and end-to-end automation for 30+ Brands across India, the US, Europe, Dubai & Australia. 7+ years of Experience saving founders real hours every week - no code required.
Author
Written By
Vikash Kumar
Building AI agents, n8n workflows and end-to-end automation for 30+ Brands across India, the US, Europe, Dubai & Australia. 7+ years of Experience saving founders real hours every week - no code required.

Frequently Asked Questions

The workflow starts when the Telegram bot receives any user message.
An AI model using OpenRouter GPT-4.1 analyzes email content and outputs instructions on archiving or labeling.
Failures often happen due to missing Gmail OAuth scopes or incorrect label IDs.
Yes, a scheduled trigger node can be added to run the workflow periodically without Telegram.

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.