Quick overview
This workflow checks Gmail every hour, filters out automated senders, uses Google Gemini to summarize and classify each new email, logs the analysis to an n8n Data Table, and sends a Telegram alert when an email is marked as high priority.
How it works
- Runs every hour and pulls new emails from Gmail.
- Normalizes the email fields (sender, subject, received time, body text) and truncates long content while filtering out senders that match blocked “no-reply/newsletter” keywords.
- Checks an n8n Data Table for the email’s message ID to skip messages that were already processed.
- Sends the cleaned email content to Google Gemini, which returns a structured JSON with summary, category, priority, action items, deadline, sentiment, and key entities.
- Upserts the email metadata and Gemini analysis into the n8n Data Table for tracking and search.
- If Gemini rates the email as High priority, sends a formatted Telegram message with the summary, required action, and deadline.
Setup
- Connect a Gmail credential (service account as configured) and ensure the Gmail Trigger has access to the mailbox you want to monitor.
- Add a Google Gemini (Google PaLM) API credential for the Gemini chat model used by the email analysis step.
- Create an n8n Data Table with the expected columns and paste its ID into the
data_table_id value in the Set Context step.
- Connect a Telegram Bot credential and set the correct Telegram chat ID in the Telegram alert step (replace the current value if needed).
- Review and update the Set Context values (owner name/email, blocked sender keywords, and max content length) to match your preferences.
Requirements
- n8n Version: Built and tested on n8n 2.20.0+. (Note: You may encounter errors on older versions. It is highly recommended to update to the latest n8n version to use this workflow effectively).
- Google Gemini API key credential.
- Gmail OAuth2 credential.
- Telegram Bot API credential and Chat ID.
- Built-in n8n Data Table feature enabled.
Customization
- Switch the Input Source: You don't have to use Gmail. Swap the trigger for an IMAP, Outlook, or Zoho Mail node if you use a different provider.
- Refine the AI Persona: Modify the system prompt inside the AI Agent node to fine-tune how it categorizes emails specific to your industry (e.g., adding a "Lead", "Support Ticket", or "Invoice" category).
- Change the Alert Channel: Prefer team visibility? Replace the Telegram node with a Slack or Discord node to notify an entire channel when a high-priority email arrives.
Additional info
About the Author
Created by: Nguyễn Thiệu Toàn (Jay Nguyen)
Email: [email protected]
Website: nguyenthieutoan.com
Company: GenStaff (genstaff.net)
Socials (Facebook / X / LinkedIn): @nguyenthieutoan
More templates: n8n.io/creators/nguyenthieutoan