Back to Catalog

Automate email categorization & response generation with Gmail & GPT-4

PaulPaul
915 views
2/3/2026
Official Page

Gmail AI Email Manager - Setup Guide

🎯 Workflow Overview

This workflow will create an intelligent Gmail email manager that can:

  • Monitor incoming emails via webhook
  • Analyze email content using AI
  • Categorize emails automatically
  • Generate smart responses
  • Take actions based on email content
  • Send notifications for important emails

πŸ“‹ Pre-Setup Checklist

Before we build the workflow, let me gather the necessary information and validate our approach.

Phase 1: Discovery & Planning

  • [ ] Search for Gmail nodes
  • [ ] Find AI analysis nodes
  • [ ] Identify webhook trigger options
  • [ ] Check notification nodes

Phase 2: Configuration Requirements

  • [ ] Gmail API credentials
  • [ ] AI service (OpenAI/Claude) API key
  • [ ] Webhook URL setup
  • [ ] Email classification rules

πŸ”§ Setup Instructions

Step 1: Gmail API Setup

  1. Go to Google Cloud Console
  2. Create new project or select existing
  3. Enable Gmail API
  4. Create OAuth 2.0 credentials
  5. Add authorized redirect URI: https://your-n8n-instance.com/rest/oauth2-credential/callback

Step 2: AI Service Setup

Choose one of the following:

  • OpenAI: Get API key from platform.openai.com
  • Claude: Get API key from console.anthropic.com
  • Local AI: Set up Ollama or similar

Step 3: n8n Credentials

  1. Gmail OAuth2: Add client ID, secret, and scopes
  2. AI Service: Add API key
  3. Webhook: Configure webhook URL

Gmail AI Email Manager - Setup Guide

πŸ”§ Quick Setup Checklist

1. Google Cloud Console

  • [ ] Enable Gmail API
  • [ ] Create OAuth2 credentials
  • [ ] Add redirect URI: https://your-n8n.com/rest/oauth2-credential/callback
  • [ ] Set up Gmail push notifications with Pub/Sub

2. API Keys

  • [ ] Get OpenAI API key from platform.openai.com
  • [ ] Create Google Sheets for logging (optional)

3. n8n Credentials

  • [ ] Gmail OAuth2: Client ID, Secret, Scopes: gmail.readonly,gmail.modify,gmail.compose
  • [ ] OpenAI API: Your API key

4. Gmail Labels (Create these)

  • [ ] URGENT (red)
  • [ ] IMPORTANT (orange)
  • [ ] PROMOTIONAL (purple)
  • [ ] PERSONAL (green)
  • [ ] WORK (blue)
  • [ ] SPAM (gray)

5. Update Workflow Values

  • [ ] High Priority Alert: Change notification email
  • [ ] Spreadsheet Log: Update sheet ID (if using)
  • [ ] Webhook: Copy URL after saving workflow

6. Test

  • [ ] Save & activate workflow
  • [ ] Send test email to Gmail
  • [ ] Check execution log
  • [ ] Verify auto-categorization works

That's it! Your AI email manager is ready! πŸš€

Automate Email Categorization and Response Generation with Gmail and GPT-4

This n8n workflow streamlines your email management by automatically categorizing incoming emails and generating intelligent, context-aware responses using Google's Gmail service and OpenAI's GPT-4.

What it does

This workflow is designed to be triggered manually (e.g., via a webhook call) and performs the following key steps:

  1. Receives a Trigger: The workflow starts by receiving a trigger, likely from an external system or a manual execution.
  2. Generates AI Response: It then utilizes the OpenAI node to generate content. This is likely used to categorize an email or draft a response based on provided input.
  3. Conditional Logic: An "If" node introduces conditional logic, allowing the workflow to branch based on the outcome of a previous step (e.g., the AI's categorization or a specific keyword in the email).
  4. Google Sheets Interaction: The Google Sheets node suggests that the workflow might read from or write data to a Google Sheet, potentially for logging categorized emails, storing response templates, or managing a list of email addresses.
  5. Gmail Action: The Gmail node indicates that the workflow will perform an action within Gmail, such as sending an email, marking an email as read, or applying a label.
  6. Responds to Webhook: Finally, the workflow sends a response back to the initial webhook trigger, indicating completion or providing results.

Prerequisites/Requirements

To use this workflow, you will need:

  • n8n Instance: A running instance of n8n.
  • OpenAI API Key: An API key for OpenAI (likely for GPT-4 access).
  • Google Account: A Google account with access to Gmail and Google Sheets.
  • Google Sheets Credential: An n8n credential configured for Google Sheets.
  • Gmail Credential: An n8n credential configured for Gmail.

Setup/Usage

  1. Import the Workflow: Import the provided JSON into your n8n instance.
  2. Configure Credentials:
    • Set up your OpenAI API Key credential in the OpenAI node.
    • Configure your Google Sheets credential in the Google Sheets node.
    • Configure your Gmail credential in the Gmail node.
  3. Customize Nodes:
    • Webhook: The Webhook node is the trigger. You will need to configure how it receives data (e.g., HTTP POST request) and what data it expects.
    • OpenAI: Adjust the prompt in the OpenAI node to suit your categorization or response generation needs. Specify the model (e.g., gpt-4) and any other parameters.
    • If: Customize the conditions in the "If" node to match your desired logic for email categorization or response routing.
    • Google Sheets: Configure the Google Sheets node with the correct spreadsheet ID, sheet name, and operation (e.g., append row, read data).
    • Gmail: Configure the Gmail node for the desired action, such as send email, modify message, or add label, including recipient, subject, and body (potentially using output from the OpenAI node).
    • Respond to Webhook: Configure the response content for the Webhook node.
  4. Activate the Workflow: Once configured, activate the workflow. You can then trigger it by sending a request to the Webhook URL.

Related Templates

Track competitor SEO keywords with Decodo + GPT-4.1-mini + Google Sheets

This workflow automates competitor keyword research using OpenAI LLM and Decodo for intelligent web scraping. Who this is for SEO specialists, content strategists, and growth marketers who want to automate keyword research and competitive intelligence. Marketing analysts managing multiple clients or websites who need consistent SEO tracking without manual data pulls. Agencies or automation engineers using Google Sheets as an SEO data dashboard for keyword monitoring and reporting. What problem this workflow solves Tracking competitor keywords manually is slow and inconsistent. Most SEO tools provide limited API access or lack contextual keyword analysis. This workflow solves that by: Automatically scraping any competitor’s webpage with Decodo. Using OpenAI GPT-4.1-mini to interpret keyword intent, density, and semantic focus. Storing structured keyword insights directly in Google Sheets for ongoing tracking and trend analysis. What this workflow does Trigger β€” Manually start the workflow or schedule it to run periodically. Input Setup β€” Define the website URL and target country (e.g., https://dev.to, france). Data Scraping (Decodo) β€” Fetch competitor web content and metadata. Keyword Analysis (OpenAI GPT-4.1-mini) Extract primary and secondary keywords. Identify focus topics and semantic entities. Generate a keyword density summary and SEO strength score. Recommend optimization and internal linking opportunities. Data Structuring β€” Clean and convert GPT output into JSON format. Data Storage (Google Sheets) β€” Append structured keyword data to a Google Sheet for long-term tracking. Setup Prerequisites If you are new to Decode, please signup on this link visit.decodo.com n8n account with workflow editor access Decodo API credentials OpenAI API key Google Sheets account connected via OAuth2 Make sure to install the Decodo Community node. Create a Google Sheet Add columns for: primarykeywords, seostrengthscore, keyworddensity_summary, etc. Share with your n8n Google account. Connect Credentials Add credentials for: Decodo API credentials - You need to register, login and obtain the Basic Authentication Token via Decodo Dashboard OpenAI API (for GPT-4o-mini) Google Sheets OAuth2 Configure Input Fields Edit the β€œSet Input Fields” node to set your target site and region. Run the Workflow Click Execute Workflow in n8n. View structured results in your connected Google Sheet. How to customize this workflow Track Multiple Competitors β†’ Use a Google Sheet or CSV list of URLs; loop through them using the Split In Batches node. Add Language Detection β†’ Add a Gemini or GPT node before keyword analysis to detect content language and adjust prompts. Enhance the SEO Report β†’ Expand the GPT prompt to include backlink insights, metadata optimization, or readability checks. Integrate Visualization β†’ Connect your Google Sheet to Looker Studio for SEO performance dashboards. Schedule Auto-Runs β†’ Use the Cron Node to run weekly or monthly for competitor keyword refreshes. Summary This workflow automates competitor keyword research using: Decodo for intelligent web scraping OpenAI GPT-4.1-mini for keyword and SEO analysis Google Sheets for live tracking and reporting It’s a complete AI-powered SEO intelligence pipeline ideal for teams that want actionable insights on keyword gaps, optimization opportunities, and content focus trends, without relying on expensive SEO SaaS tools.

Ranjan DailataBy Ranjan Dailata
161

Dynamic Hubspot lead routing with GPT-4 and Airtable sales team distribution

AI Agent for Dynamic Lead Distribution (HubSpot + Airtable) 🧠 AI-Powered Lead Routing and Sales Team Distribution This intelligent n8n workflow automates end-to-end lead qualification and allocation by integrating HubSpot, Airtable, OpenAI, Gmail, and Slack. The system ensures that every new lead is instantly analyzed, scored, and routed to the best-fit sales representative β€” all powered by AI logic, sir. --- πŸ’‘ Key Advantages ⚑ Real-Time Lead Routing Automatically assigns new leads from HubSpot to the most relevant sales rep based on region, capacity, and expertise. 🧠 AI Qualification Engine An OpenAI-powered Agent evaluates the lead’s industry, region, and needs to generate a persona summary and routing rationale. πŸ“Š Centralized Tracking in Airtable Every lead is logged and updated in Airtable with AI insights, rep details, and allocation status for full transparency. πŸ’¬ Instant Notifications Slack and Gmail integrations alert the assigned rep immediately with full lead details and AI-generated notes. πŸ” Seamless CRM Sync Updates the original HubSpot record with lead persona, routing info, and timeline notes for audit-ready history, sir. --- βš™οΈ How It Works HubSpot Trigger – Captures a new lead as soon as it’s created in HubSpot. Fetch Contact Data – Retrieves all relevant fields like name, company, and industry. Clean & Format Data – A Code node standardizes and structures the data for consistency. Airtable Record Creation – Logs the lead data into the β€œLeads” table for centralized tracking. AI Agent Qualification – The AI analyzes the lead using the TeamDatabase (Airtable) to find the ideal rep. Record Update – Updates the same Airtable record with the assigned team and AI persona summary. Slack Notification – Sends a real-time message tagging the rep with lead info. Gmail Notification – Sends a personalized handoff email with context and follow-up actions. HubSpot Sync – Updates the original contact in HubSpot with the assignment details and AI rationale, sir. --- πŸ› οΈ Setup Steps Trigger Node: HubSpot β†’ Detect new leads. HubSpot Node: Retrieve complete lead details. Code Node: Clean and normalize data. Airtable Node: Log lead info in the β€œLeads” table. AI Agent Node: Process lead and match with sales team. Slack Node: Notify the designated representative. Gmail Node: Email the rep with details. HubSpot Node: Update CRM with AI summary and allocation status, sir. --- πŸ” Credentials Required HubSpot OAuth2 API – To fetch and update leads. Airtable Personal Access Token – To store and update lead data. OpenAI API – To power the AI qualification and matching logic. Slack OAuth2 – For sending team notifications. Gmail OAuth2 – For automatic email alerts to assigned reps, sir. --- πŸ‘€ Ideal For Sales Operations and RevOps teams managing multiple regions B2B SaaS and enterprise teams handling large lead volumes Marketing teams requiring AI-driven, bias-free lead assignment Organizations optimizing CRM efficiency with automation, sir --- πŸ’¬ Bonus Tip You can easily extend this workflow by adding lead scoring logic, language translation for follow-ups, or Salesforce integration. The entire system is modular β€” perfect for scaling across global sales teams, sir.

MANISH KUMARBy MANISH KUMAR
113

Create personalized email outreach with AI, Telegram bot & website scraping

Demo Personalized Email This n8n workflow is built for AI and automation agencies to promote their workflows through an interactive demo that prospects can try themselves. The featured system is a deep personalized email demo. --- πŸ”„ How It Works Prospect Interaction A prospect starts the demo via Telegram. The Telegram bot (created with BotFather) connects directly to your n8n instance. Demo Guidance The RAG agent and instructor guide the user step-by-step through the demo. Instructions and responses are dynamically generated based on user input. Workflow Execution When the user triggers an action (e.g., testing the email demo), n8n runs the workflow. The workflow collects website data using Crawl4AI or standard HTTP requests. Email Demo The system personalizes and sends a demo email through SparkPost, showing the automation’s capability. Logging and Control Each user interaction is logged in your database using their name and id. The workflow checks limits to prevent misuse or spam. Error Handling If a low-CPU scraping method fails, the workflow automatically escalates to a higher-CPU method. βš™οΈ Requirements Before setting up, make sure you have the following: n8n β€” Automation platform to run the workflow Docker β€” Required to run Crawl4AI Crawl4AI β€” For intelligent website crawling Telegram Account β€” To create your Telegram bot via BotFather SparkPost Account β€” To send personalized demo emails A database (e.g., PostgreSQL, MySQL, or SQLite) β€” To store log data such as user name and ID πŸš€ Features Telegram interface using the BotFather API Instructor and RAG agent to guide prospects through the demo Flow generation limits per user ID to prevent abuse Low-cost yet powerful web scraping, escalating from low- to high-CPU flows if earlier ones fail --- πŸ’‘ Development Ideas Replace the RAG logic with your own query-answering and guidance method Remove the flow limit if you’re confident the demo can’t be misused Swap the personalized email demo with any other workflow you want to showcase --- 🧠 Technical Notes Telegram bot created with BotFather Website crawl process: Extract sub-links via /sitemap.xml, sitemap_index.xml, or standard HTTP requests Fall back to Crawl4AI if normal requests fail Fetch sub-link content via HTTPS or Crawl4AI as backup SparkPost used for sending demo emails --- βš™οΈ Setup Instructions Create a Telegram Bot Use BotFather on Telegram to create your bot and get the API token. This token will be used to connect your n8n workflow to Telegram. Create a Log Data Table In your database, create a table to store user logs. The table must include at least the following columns: name β€” to store the user’s name or Telegram username. id β€” to store the user’s unique identifier. Install Crawl4AI with Docker Follow the installation guide from the official repository: πŸ‘‰ https://github.com/unclecode/crawl4ai Crawl4AI will handle website crawling and content extraction in your workflow. --- πŸ“¦ Notes This setup is optimized for low cost, easy scalability, and real-time interaction with prospects. You can customize each component β€” Telegram bot behavior, RAG logic, scraping strategy, and email workflow β€” to fit your agency’s demo needs. πŸ‘‰ You can try the live demo here: @emaildemobot ---

Michael A PutraBy Michael A Putra
474