AI Draft Reply Generator for Gmail - n8n Workflow

Automate email handling using this powerful n8n workflow. It uses OpenAI to assess incoming emails and generate professional draft replies directly in Gmail. This n8n workflow saves hours daily.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Business owners or executives dealing with high-volume inboxes who need initial triage.
Users of n8n looking for advanced, AI-driven n8n templates for email automation.
Technical users wanting to leverage the LangChain n8n node functionality for structured LLM outputs.
Individuals aiming to maximize productivity by creating professional draft replies instantly.

Overview

Managing a high volume of incoming email requires constant attention and often consumes significant time. This sophisticated n8n workflow template solves that problem by integrating powerful large language models (LLMs) to handle both triage and initial drafting automatically.

The system first uses an AI n8n node to determine if a response is genuinely needed, effectively filtering out noise like marketing emails or simple notifications. If a reply is required, the subsequent n8n node dedicated to AI generation drafts a professional, contextualized reply directly into your Gmail thread as a draft. This ensures you maintain quality control while dramatically reducing the time spent initiating responses. It’s an essential n8n workflow for modern productivity, offering a great example of how to combine a Gmail n8n trigger with advanced AI logic.

How it Works

This efficient n8n workflow starts with a specialized trigger and progresses through several AI assessment and drafting phases:


  1. Triggering the n8n workflow: The Gmail Trigger n8n node initiates the process whenever a new email is received that was not sent by you (-from:me).

  2. AI Assessment: The email content is passed to the "Assess if message needs a reply" LangChain n8n node. This node uses GPT-4o and a specific prompt to decide if a response is required, returning the result as a structured JSON object.

  3. Data Parsing and Decision: The JSON Parser n8n node extracts the boolean needsReply flag. The subsequent "If Needs Reply" n8n node checks this flag. If the value is true, the n8n workflow continues to the reply generation path.

  4. AI Draft Generation: The "Generate email reply" n8n node, utilizing GPT-4-turbo, takes the original email content and, based on a comprehensive system prompt, acts as a professional assistant to draft a suitable response.

  5. Draft Creation: Finally, the Gmail - Create Draft n8n node takes the AI-generated text and creates a new draft reply within the context of the original email thread, ready for you to review and send. This powerful final step leverages the Gmail n8n node capabilities to save the draft accurately.

Installation Guide

To deploy this useful n8n workflow, follow these steps:


  1. Import: Copy the entire JSON code provided and import it into your n8n instance as a new n8n workflow.

  2. Gmail Credentials: You will need to set up OAuth2 credentials for the Gmail Trigger n8n node and the Gmail - Create Draft n8n node. Ensure these credentials have the necessary scope to read emails and create drafts.

  3. OpenAI Credentials: Set up your OpenAI API Key credentials. The workflow utilizes this connection in two separate LangChain n8n nodes.

  4. Configuration Check: Verify the "Gmail Trigger" n8n node is configured to poll for new emails regularly.

  5. Activate: Once credentials are set and tested, activate the n8n workflow.

Node Details

Gmail Trigger: Function: The starting n8n trigger point for the entire flow. Key Configuration: Filters incoming mail to ignore messages sent by the user (-from:me).
Assess if message needs a reply (LangChain LLM Chain): Function: Determines if the incoming email requires a human response. Key Configuration: Feeds the email subject and body into the prompt. It connects to the OpenAI Chat n8n node (GPT-4o).
OpenAI Chat (n8n node): Function: Provides the language model service for the assessment chain. Key Configuration: Uses gpt-4o and enforces json_object response format.
JSON Parser: Function: Extracts the boolean needsReply value from the structured JSON output provided by the AI assessment n8n node.
If Needs Reply: Function: Core flow control. Only allows the n8n workflow to proceed to the drafting stage if needsReply is true.
Generate email reply (LangChain LLM Chain): Function: Generates a professional draft response based on the detailed system prompt acting as a personal assistant. Key Configuration: Connects to the OpenAI Chat Model n8n node (GPT-4-turbo).


  • Gmail - Create Draft: Function: The final action n8n node. Creates the AI-generated reply as a draft in the original thread. Key Configuration: Uses data expressions to inject the generated text, original subject (prefixed with Re:), and thread ID for accurate placement.

Related n8n Workflows

Free

Nodes: 7 Nodes
Updated: December 26 2025
View all
Created by

Founder of Flowful, an AI consulting agency.

Featured*