Automate email responses with GPT-4o-mini and human review in Gmail
This n8n template demonstrates a “Human-in-the-Loop” workflow where AI automatically drafts replies to inbound emails, which are then reviewed and approved by a human before being sent. This powerful pattern ensures both the efficiency of AI and the quality assurance of human oversight.
Use cases are many: Streamline sales inquiry responses, manage first-level customer support, handle initial recruitment communications, or any business process that requires personalized yet consistent email replies.
Good to know
- At the time of writing, the cost per execution depends on your OpenAI API usage. This workflow uses a cost-effective model like gpt-4o-mini. See OpenAI Pricing for updated info.
- The AI’s knowledge base and persona are fully customizable within the Basic LLM Chain node’s prompt.
How it works
- The Gmail Trigger node starts the workflow whenever a new email arrives in the specified inbox.
- The Classify Potential Leads node uses AI to determine if the incoming email is a potential lead. If not, the workflow stops.
- The Basic LLM Chain, powered by an OpenAI Chat Model, generates a draft reply based on a detailed system prompt and your internal knowledge base.
- A Structured Output Parser is crucially used to force the AI’s output into a reliable JSON format (
{"subject": "...", "body": "..."}), preventing errors in subsequent steps. - The Send for Review Gmail node sends the AI-generated draft to a human reviewer and pauses the workflow, waiting for a reply.
- The IF node checks the reviewer’s reply for approval keywords (e.g., “approve”, “承認”).
- If approved, the ✅ Send to Customer Gmail node sends the final email to the original customer.
- If not approved, the reviewer’s feedback is treated as a revision request, and the workflow loops back to the Basic LLM Chain to generate a new draft incorporating the feedback.
How to use
- Gmail Trigger node: Configure with your own Gmail account credentials.
- Send for Review node: Replace the placeholder email
reviewer@example.comwith the actual reviewer's email address. - IF node: You can customize the approval keywords to match your team’s vocabulary.
- OpenAI Nodes: Ensure your OpenAI credentials are set up. You can select a different model if needed, but the prompt is optimized for models like GPT-4o mini.
Requirements
- An OpenAI account for the LLM.
- A Gmail account for receiving customer emails and for the review process.
Customising this workflow
- By modifying the prompt and knowledge base in the Basic LLM Chain, you can adapt this agent for various departments, such as technical support, HR, or public relations.
- The approval channel is not limited to Gmail. You can easily replace the review nodes with Slack or Microsoft Teams nodes to fit your internal communication tools.
Automate Email Responses with GPT-4o-mini and Human Review in Gmail
This n8n workflow automates the process of drafting email responses using an AI model (GPT-4o-mini) and provides an optional human review step before sending. It helps streamline customer support, sales inquiries, or any scenario requiring quick, intelligent email replies.
What it does
This workflow performs the following steps:
- Triggers on new emails: Listens for new incoming emails in a specified Gmail account.
- Classifies email intent: Uses a Text Classifier node to determine the intent or category of the incoming email.
- Generates a draft response: If the email intent is suitable for AI response, a Basic LLM Chain node, powered by an OpenAI Chat Model (GPT-4o-mini), generates a draft reply.
- Parses structured output: A Structured Output Parser extracts the generated response in a defined format.
- Conditional routing for review: An If node checks a condition (likely based on the classified intent or a confidence score) to decide if human review is needed.
- Sends draft for human review (optional): If human review is required, the draft email is sent to a specified Gmail address (or another system for review). This step is currently represented by a "No Operation" node, implying a placeholder for a human-in-the-loop (HITL) process.
- Sends automated response: If no human review is needed, the AI-generated draft is automatically sent as a reply via Gmail.
Prerequisites/Requirements
To use this workflow, you will need:
- n8n instance: A running n8n instance.
- Gmail Account: Configured with credentials in n8n for both triggering on new emails and sending replies.
- OpenAI API Key: For the OpenAI Chat Model (GPT-4o-mini) used in the Basic LLM Chain. This will be configured as an n8n credential.
- Langchain Nodes: Ensure the
@n8n/n8n-nodes-langchainpackage is installed and enabled in your n8n instance, as it provides the AI-related nodes (Basic LLM Chain, OpenAI Chat Model, Structured Output Parser, Text Classifier).
Setup/Usage
- Import the workflow: Download the JSON provided and import it into your n8n instance.
- Configure Credentials:
- Set up your Gmail OAuth2 credentials for both the Gmail Trigger and Gmail nodes.
- Set up your OpenAI API Key credential for the OpenAI Chat Model.
- Activate the workflow: Once all credentials are set and configurations are done, activate the workflow.
- Customize:
- Gmail Trigger: Adjust the mailbox and query settings in the Gmail Trigger node to specify which emails should initiate the workflow.
- Text Classifier: Configure the Text Classifier node with your desired categories and examples to accurately classify incoming email intent.
- Basic LLM Chain & OpenAI Chat Model: Fine-tune the prompt in the Basic LLM Chain to guide GPT-4o-mini in generating appropriate responses. Adjust the model parameters in the OpenAI Chat Model if needed.
- Structured Output Parser: Ensure the schema in this node matches the expected output format from your LLM chain.
- If Node: Modify the condition in the
Ifnode to define when a human review is necessary (e.g., based on classification confidence, specific keywords, or a flag from the AI). - Human Review (No Operation, do nothing): Replace the "No Operation, do nothing" node connected to the
Falsebranch of theIfnode with your preferred human review process. This could involve:- Sending an email to a human reviewer with the draft.
- Posting to a Slack channel or other communication platform.
- Creating a task in a project management tool.
- Using n8n's built-in "Wait for Webhook" node for a manual approval step.
- Gmail (Send Reply): Configure the Gmail node to send the final response, ensuring it replies to the original sender and includes the AI-generated content.
Related Templates
AI multi-agent executive team for entrepreneurs with Gemini, Perplexity and WhatsApp
This workflow is an AI-powered multi-agent system built for startup founders and small business owners who want to automate decision-making, accountability, research, and communication, all through WhatsApp. The “virtual executive team,” is designed to help small teams to work smarter. This workflow sends you market analysis, market and sales tips, It can also monitor what your competitors are doing using perplexity (Research agent) and help you stay a head, or make better decisions. And when you feeling stuck with your start-up accountability director is creative enough to break the barrier 🎯 Core Features 🧑💼 1. President (Super Agent) Acts as the main controller that coordinates all sub-agents. Routes messages, assigns tasks, and ensures workflow synchronization between the AI Directors. 📊 2. Sales & Marketing Director Uses SerpAPI to search for market opportunities, leads, and trends. Suggests marketing campaigns, keywords, or outreach ideas. Can analyze current engagement metrics to adjust content strategy. 🕵️♀️ 3. Business Research Director Powered by Perplexity AI for competitive and market analysis. Monitors competitor moves, social media engagement, and product changes. Provides concise insights to help the founder adapt and stay ahead. ⏰ 4. Accountability Director Keeps the founder and executive team on track. Sends motivational nudges, task reminders, and progress reports. Promotes consistency and discipline — key traits for early-stage success. 🗓️ 5. Executive Secretary Handles scheduling, email drafting, and reminders. Connects with Google Calendar, Gmail, and Sheets through OAuth. Automates follow-ups, meeting summaries, and notifications directly via WhatsApp. 💬 WhatsApp as the Main Interface Interact naturally with your AI team through WhatsApp Business API. All responses, updates, and summaries are delivered to your chat. Ideal for founders who want to manage operations on the go. ⚙️ How It Works Trigger: The workflow starts from a WhatsApp Trigger node (via Meta Developer Account). Routing: The President agent analyzes the incoming message and determines which Director should handle it. Processing: Marketing or sales queries go to the Sales & Marketing Director. Research questions are handled by the Business Research Director. Accountability tasks are assigned to the Accountability Director. Scheduling or communication requests are managed by the Secretary. Collaboration: Each sub-agent returns results to the President, who summarizes and sends the reply back via WhatsApp. Memory: Context is maintained between sessions, ensuring personalized and coherent communication. 🧩 Integrations Required Gemini API – for general intelligence and task reasoning Supabase- for RAG and postgres persistent memory Perplexity API – for business and competitor analysis SerpAPI – for market research and opportunity scouting Google OAuth – to connect Sheets, Calendar, and Gmail WhatsApp Business API – for message triggers and responses 🚀 Benefits Acts like a team of tireless employees available 24/7. Saves time by automating research, reminders, and communication. Enhances accountability and strategy consistency for founders. Keeps operations centralized in a simple WhatsApp interface. 🧰 Setup Steps Create API credentials for: WhatsApp (via Meta Developer Account) Gemini, Perplexity, and SerpAPI Google OAuth (Sheets, Calendar, Gmail) Create a supabase account at supabase Add the credentials in the corresponding n8n nodes. Customize the system prompts for each Director based on your startup’s needs. Activate and start interacting with your virtual executive team on WhatsApp. Use Case You are a small organisation or start-up that can not afford hiring; marketing department, research department and secretar office, then this workflow is for you 💡 Need Customization? Want to tailor it for your startup or integrate with CRM tools like Notion or HubSpot? You can easily extend the workflow or contact the creator for personalized support. Consider adjusting the system prompt to suite your business
Automated YouTube video uploads with 12h interval scheduling in JST
This workflow automates a batch upload of multiple videos to YouTube, spacing each upload 12 hours apart in Japan Standard Time (UTC+9) and automatically adding them to a playlist. ⚙️ Workflow Logic Manual Trigger — Starts the workflow manually. List Video Files — Uses a shell command to find all .mp4 files under the specified directory (/opt/downloads/单词卡/A1-A2). Sort and Generate Items — Sorts videos by day number (dayXX) extracted from filenames and assigns a sequential order value. Calculate Publish Schedule (+12h Interval) — Computes the next rounded JST hour plus a configurable buffer (default 30 min). Staggers each video’s scheduled time by order × 12 hours. Converts JST back to UTC for YouTube’s publishAt field. Split in Batches (1 per video) — Iterates over each video item. Read Video File — Loads the corresponding video from disk. Upload to YouTube (Scheduled) — Uploads the video privately with the computed publishAtUtc. Add to Playlist — Adds the newly uploaded video to the target playlist. 🕒 Highlights Timezone-safe: Pure UTC ↔ JST conversion avoids double-offset errors. Sequential scheduling: Ensures each upload is 12 hours apart to prevent clustering. Customizable: Change SPANHOURS, BUFFERMIN, or directory paths easily. Retry-ready: Each upload and playlist step has retry logic to handle transient errors. 💡 Typical Use Cases Multi-part educational video series (e.g., A1–A2 English learning). Regular content release cadence without manual scheduling. Automated YouTube publishing pipelines for pre-produced content. --- Author: Zane Category: Automation / YouTube / Scheduler Timezone: JST (UTC+09:00)
Monitor bank transactions with multi-channel alerts for accounting teams
Enhance financial oversight with this automated n8n workflow. Triggered every 5 minutes, it fetches real-time bank transactions via an API, enriches and transforms the data, and applies smart logic to detect critical, high, and medium priority alerts based on error conditions, amounts, or risk scores. It sends multi-channel notifications via email and Slack, logs all data to Google Sheets, and generates summary statistics for comprehensive tracking. 💰🚨 Key Features Real-time monitoring every 5 minutes for instant alerts. Smart prioritization (Critical, High, Medium) based on risk and errors. Multi-channel notifications via email and Slack. Detailed logging and summary reports in Google Sheets. How It Works Schedule Trigger: Runs every 5 minutes. Fetch Transactions: HTTP request retrieves real-time transaction data. API Error?: If condition for error logic is met, sends error alert. Enrich & Transform Data: Advanced risk calculation enhances data. Critical Alert?: If condition (50% or risk > 8) is met, raises alert. High Priority?: If condition (5% or risk > 7) is met, raises alert. Medium Priority?: If condition is met, raises alert. Log Priority to Sheet: Google Sheets appends critical, high, or medium priority data. Send Critical Email: HTML email to execute sheets append. Send High Priority Email: Email to finance team. Send High Priority Slack: Slack notification to finance team. Send Medium Priority Email: Email to finance team. Merge All Alerts: Combines all alerts for comprehensive tracking. Generate Summary Stats: Code block for analytics. Log Summary to Sheet: Summary statistics storage. Setup Instructions Import the workflow into n8n and configure the bank API credentials in "Fetch Transactions." Set up Google Sheets OAuth2 and replace the sheet ID for logging nodes. Configure Gmail API Key and Slack Bot Token for alerts. Test the workflow with sample transaction data exceeding risk or amount thresholds. Adjust priority conditions (e.g., 50%, 5%, risk > 8) based on your risk policy. Prerequisites Bank API access with real-time transaction data (e.g., https://api.bank.com) Google Sheets OAuth2 credentials Gmail API Key for email alerts Slack Bot Token (with chat:write permissions) Structured transaction data format Google Sheet Structure: Create a sheet with columns: Transaction ID Amount Date Risk Score Priority (Critical/High/Medium) Alert Sent Summary Stats Updated At Modification Options Adjust the "Schedule Trigger" interval (e.g., every 10 minutes). Modify "Critical Alert?" and "High Priority?" conditions for custom thresholds. Customize email and Slack templates with branded messaging. Integrate with fraud detection tools for enhanced risk analysis. Enhance "Generate Summary Stats" with additional metrics (e.g., average risk). Discover more workflows – Get in touch with us