AutomationFlowsAI & RAG › Auto-respond to Gmail Inquiries Using Openai, Google Sheet & AI Agent

Auto-respond to Gmail Inquiries Using Openai, Google Sheet & AI Agent

ByBilly Christi @billy on n8n.io

This workflow is ideal for: Customer support teams looking to reduce manual response time SaaS companies that frequently receive product inquiries E-commerce stores with common customer questions about orders, shipping, and returns

Event trigger★★★★☆ complexityAI-powered15 nodesOpenAI ChatOutput Parser StructuredGoogle Sheets ToolGmailAgentGmail TriggerGoogle SheetsText Classifier
AI & RAG Trigger: Event Nodes: 15 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #4413 — we link there as the canonical source.

This workflow follows the Agent → Gmail recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "nodes": [
    {
      "id": "0ff8971c-662e-4578-8a9a-340d48724648",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        560,
        320
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6ed348ac-1fed-4f23-93c5-f1870c0507eb",
      "name": "OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        900,
        340
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "379006af-b4c2-4d96-b83d-d8d84b8dcbe7",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1100,
        340
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"respond\": \"Hi!\\nThank you for reaching out.\\nRefunds can be requested within 30 days of purchase.\\nOur pricing starts at $99/month.\\nIf you have more questions, feel free to reply to this email.\"\n}"
      },
      "typeVersion": 1.2
    },
    {
      "id": "328dd554-b7c3-4e03-8869-c1ec6842c469",
      "name": "Google Sheets Context Retrieval Tool",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        1080,
        420
      ],
      "parameters": {
        "options": {},
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bZ7DTp_6-Qs6S7McyIrlMnuCvHbCrgUI-GBjz_eMpHc/edit#gid=0",
          "cachedResultName": "FAQ_Context"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1bZ7DTp_6-Qs6S7McyIrlMnuCvHbCrgUI-GBjz_eMpHc",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bZ7DTp_6-Qs6S7McyIrlMnuCvHbCrgUI-GBjz_eMpHc/edit?usp=drivesdk",
          "cachedResultName": "Gmail Auto-Responder \u2013 Context & Logs"
        },
        "descriptionType": "manual",
        "toolDescription": "Google Sheet Context Retrieval Tool\nGet Context from Gooogle Sheet"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "87c47073-2638-4b67-8d7c-e1a5f8026897",
      "name": "Send Reply to User",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1280,
        120
      ],
      "parameters": {
        "sendTo": "={{ $('Watch Gmail for New Incoming Emails').item.json.to.value[0].address }}",
        "message": "={{ $('Reply Generator AI Agent').item.json.output.respond }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "Thanks for Reaching Out \u2013 Here\u2019s a Response from Our Team",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "6cd58ecb-43b3-411f-a431-6f87c6563341",
      "name": "Reply Generator AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        940,
        120
      ],
      "parameters": {
        "text": "=You are an AI email assistant that helps respond to customer enquiries.\n\nYou are given:\n- A user enquiry (email content)\n- A list of known FAQ context entries from a Google Sheet\n\nYour job is to:\n1. Carefully read the user\u2019s enquiry and identify all individual questions asked.\n2. Check if any of the context entries from the \"Google Sheet Context Retrieval Tool\" to match any of the questions.\n3. Compose ONE complete, friendly, and professional reply that:\n   - Answers all the questions that have matching context entries using ONLY the information provided in the context.\n   - Politely informs the user that for any unanswered questions, the support team will follow up shortly.\n4. DO NOT make up answers or assume information.\n5. Always include a friendly closing sentence:  \n   \"If you have more questions, feel free to reply to this email.\"\n\nImportant:\n- Only use information from the FAQ context.\n- Keep your tone professional, friendly, and clear.\n- Make sure the reply is consolidated into a SINGLE email covering all matched and unmatched questions.\n\n---\n\n### INPUTS\n**User Full Name**\n{{ $json.from.value[0].name }}\n\n**User Enquiry (email content):**  \n{{ $json.text }}\n\n---\n\n### EXAMPLES\n\n**Example Context:**  \n- \"Our pricing starts at $99/month.\"  \n- \"We offer a 14-day free trial.\"  \n- \"Refunds can be requested within 30 days of purchase.\"\n\n**Example Enquiry:**  \n\"Hi **User Full Name**, I want to know if I can get a refund for my purchase and what your pricing is?\"\n\n**Expected Output (in JSON format):**\n\n```json\n{\n  \"respond\": \"Hi!\\nThank you for reaching out.\\nRefunds can be requested within 30 days of purchase.\\nOur pricing starts at $99/month.\\nIf you have more questions, feel free to reply to this email.\"\n}\n",
        "options": {},
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.9
    },
    {
      "id": "b3a097f6-a2b8-4ae2-a4d3-501e160f00f2",
      "name": "Watch Gmail for New Incoming Emails",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        320,
        120
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d21045cb-2eec-4118-9549-1b82921d03b9",
      "name": "Log Inquiries + Response to Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1480,
        120
      ],
      "parameters": {
        "columns": {
          "value": {
            "Timestamp": "={{ $now }}",
            "AI Response": "={{ $('Reply Generator AI Agent').item.json.output.reply }}",
            "Sender Email": "={{ $('Watch Gmail for New Incoming Emails').item.json.to.value[0].address }}",
            "Original Message": "={{ $('Watch Gmail for New Incoming Emails').item.json.text }}"
          },
          "schema": [
            {
              "id": "Timestamp",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Timestamp",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Sender Email",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Sender Email",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Subject",
              "type": "string",
              "display": true,
              "removed": true,
              "required": false,
              "displayName": "Subject",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "Original Message",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "Original Message",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "AI Response",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "AI Response",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {},
        "operation": "append",
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": 419912118,
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bZ7DTp_6-Qs6S7McyIrlMnuCvHbCrgUI-GBjz_eMpHc/edit#gid=419912118",
          "cachedResultName": "Enquiry_Log"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1bZ7DTp_6-Qs6S7McyIrlMnuCvHbCrgUI-GBjz_eMpHc",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1bZ7DTp_6-Qs6S7McyIrlMnuCvHbCrgUI-GBjz_eMpHc/edit?usp=drivesdk",
          "cachedResultName": "Gmail Auto-Responder \u2013 Context & Logs"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "2bf38e09-1469-448d-a793-3a64d744957d",
      "name": "Inquiry Filter",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        540,
        120
      ],
      "parameters": {
        "options": {},
        "inputText": "={{ $json.text }}",
        "categories": {
          "categories": [
            {
              "category": "Inquiry",
              "description": "The message is asking a question, requesting information, or seeking help \u2014 such as product details, pricing, support, or usage instructions."
            },
            {
              "category": "Not Inquiry",
              "description": "\tThe message is not asking for anything. It could be a newsletter, promotion, auto-reply, confirmation, or unrelated content with no actionable question."
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "7b7efbb6-e0fd-487d-921c-724f4ae3a743",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        0,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 260,
        "height": 380,
        "content": "## SETUP REQUIRED\n**Author:** [Billy Christi](https://n8n.io/creators/billy/)\n\n**Copy the Google Sheet template** here:\n   \ud83d\udc49 [Gmail Auto-Responder \u2013 Google Sheet Template](https://docs.google.com/spreadsheets/d/1bZ7DTp_6-Qs6S7McyIrlMnuCvHbCrgUI-GBjz_eMpHc/edit?gid=419912118#gid=419912118)\n\nGoogle Sheets Structure:\nSheet 1: \"FAQ_Context\"\n\u2022 Column A: Context\n\nSheet 2: \"Enquiry_Log\"\n\u2022 Column A: Timestamp\n\u2022 Column B: Sender Email\n\u2022 Column C: Subject\n\u2022 Column D: Original Message\n\u2022 Column E: AI Response\n\nRequired Credentials:\n\u2022 OpenAI API Key\n\u2022 Google Sheets Credential\n\u2022 Gmail Credential"
      },
      "typeVersion": 1
    },
    {
      "id": "46fde5e3-1d14-4c5c-afa2-326036d7b5e5",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        860,
        60
      ],
      "parameters": {
        "color": 4,
        "width": 380,
        "height": 520,
        "content": "\ud83e\udd16 Reads email and creates intelligent replies"
      },
      "typeVersion": 1
    },
    {
      "id": "a05b5499-e586-44fc-a563-7e533647bc87",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1420,
        40
      ],
      "parameters": {
        "color": 4,
        "width": 260,
        "height": 280,
        "content": "\u270f\ufe0f Records every inquiry and response"
      },
      "typeVersion": 1
    },
    {
      "id": "4405bfb8-5c1e-4fce-902e-680b9cfdc00e",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -40,
        440
      ],
      "parameters": {
        "color": 5,
        "width": 460,
        "height": 420,
        "content": "## \ud83d\udce7 Smart Gmail Auto-Responder with AI-Powered Customer Support\nWhat This Template Does:\n\n- Automatically monitors your Gmail inbox for new customer inquiries\n- Uses GPT-4 to intelligently classify emails as inquiries vs spam/newsletters\n- Generates contextual, professional responses using your pre-approved FAQ database\n- Only responds to genuine customer questions - ignores automated emails and promotions\n- Logs all interactions to Google Sheets for analysis and continuous improvement\n- Provides 24/7 instant customer support without human intervention"
      },
      "typeVersion": 1
    },
    {
      "id": "274934c0-00fc-483b-8bd4-972363c4f22b",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        440,
        440
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 340,
        "content": "## \ud83d\udccb WORKFLOW PROCESS OVERVIEW\nStep 1: \ud83d\udce7 Gmail monitors inbox for new incoming emails\nStep 2: \ud83e\udd16 AI classifies email as genuine inquiry vs spam/newsletter\nStep 3: \ud83d\udd0d AI analyzes customer questions and searches FAQ database\nStep 4: \u270d\ufe0f AI generates comprehensive, contextual response using approved answers\nStep 5: \ud83d\udce4 Automated reply sent to customer with professional tone\nStep 6: \ud83d\udcdd Complete interaction logged to Google Sheets for tracking"
      },
      "typeVersion": 1
    },
    {
      "id": "74eea88e-e16f-496f-afb0-53c3e72e66e5",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1760,
        -200
      ],
      "parameters": {
        "color": 4,
        "width": 380,
        "height": 760,
        "content": "# \ud83d\udc4b Hi, I\u2019m Billy\n![My Photo](https://i.ibb.co/Gvn63Bzc/Billy-Christi-AI-Automation.jpg)\nI help businesses build **n8n workflows** & **AI automation projects**.  \nNeed help with n8n or AI Automation projects? \nContact me and let\u2019s build your automation together.\n\n\ud83d\udce9 **Email:** billychartanto@gmail.com  \n\ud83e\udd1d **n8n Creator:** [n8n.io/creators/billy](https://n8n.io/creators/billy/)\n\ud83c\udf10 **My n8n Projects:** [billychristi.com/n8n](https://www.billychristi.com/n8n)  \n\n\n\n---\n\ud83d\udca1 Feel free to get in touch if you\u2019d like help on your next automation project or if you have any feedback or thoughts to share.\n"
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Inquiry Filter": {
      "main": [
        [
          {
            "node": "Reply Generator AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Inquiry Filter",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Reply Generator AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Send Reply to User": {
      "main": [
        [
          {
            "node": "Log Inquiries + Response to Google Sheet",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply Generator AI Agent": {
      "main": [
        [
          {
            "node": "Send Reply to User",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Structured Output Parser": {
      "ai_outputParser": [
        [
          {
            "node": "Reply Generator AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Watch Gmail for New Incoming Emails": {
      "main": [
        [
          {
            "node": "Inquiry Filter",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets Context Retrieval Tool": {
      "ai_tool": [
        [
          {
            "node": "Reply Generator AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This workflow is ideal for: Customer support teams looking to reduce manual response time SaaS companies that frequently receive product inquiries E-commerce stores with common customer questions about orders, shipping, and returns

Source: https://n8n.io/workflows/4413/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This n8n workflow template automates your lead generation and follow-up process using AI. It captures leads through a form, enriches them with company data, classifies them into different categories,

Gmail, Output Parser Structured, Form Trigger +5
AI & RAG

Enterprise-grade resume screening automation built for production environments. This workflow combines intelligent AI analysis with comprehensive error handling to ensure reliable processing of candid

Gmail Trigger, Google Drive, HTTP Request +6
AI & RAG

Transform your manual hiring process into an intelligent evaluation system that saves 15-20 minutes per candidate! This workflow automates the entire candidate assessment pipeline - from CSV/XLSX uplo

Form Trigger, Google Sheets, Google Drive +8
AI & RAG

AI Agents Vs AI Workflow. Uses lmChatOpenAi, gmailTrigger, gmail, gmailTool. Event-driven trigger; 30 nodes.

OpenAI Chat, Gmail Trigger, Gmail +7
AI & RAG

*Tags: AI Agent, Supply Chain, Logistics, Circular Economy, Route Planning, Transportation, GPS API*

Gmail Trigger, Output Parser Structured, Agent +4