Automatische Beantwortung von Gmail-Anfragen mit OpenAI, Google Tabellen und KI-Agenten

Fortgeschritten

Dies ist ein Support, AI-Bereich Automatisierungsworkflow mit 14 Nodes. Hauptsächlich werden Gmail, GmailTrigger, GoogleSheets, Agent, GoogleSheetsTool und andere Nodes verwendet, kombiniert mit KI-Technologie für intelligente Automatisierung. Automatische Beantwortung von Gmail-Anfragen mit OpenAI, Google Tabellen und KI-Agenten

Voraussetzungen
  • Google-Konto + Gmail API-Anmeldedaten
  • Google Sheets API-Anmeldedaten
  • OpenAI API Key
Workflow-Vorschau
Visualisierung der Node-Verbindungen, mit Zoom und Pan
Workflow exportieren
Kopieren Sie die folgende JSON-Konfiguration und importieren Sie sie in n8n
{
  "meta": {
    "instanceId": "d1786ab0d745a7498abf13a9c2cdabb1374c006e889b79eef64ce0386b8f8a41",
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "e0d9ee42-e519-41ef-b11a-0c45f7e7a78e",
      "name": "OpenAI-Chat-Modell",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        280,
        180
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "MGwGMKEkdcjzlYCw",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "a0d9e3a0-52d9-4edc-9806-991c1aeb14a3",
      "name": "OpenAI-Chat-Modell1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        620,
        200
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "MGwGMKEkdcjzlYCw",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "40ba7c6e-5854-4313-b695-9ed86c4c8e80",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        820,
        200
      ],
      "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": "f7dc1cd8-8c69-450a-b3c9-f7fed3f6ffe1",
      "name": "Google Tabellen Context Retrieval Tool",
      "type": "n8n-nodes-base.googleSheetsTool",
      "position": [
        720,
        200
      ],
      "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 – Context & Logs"
        },
        "descriptionType": "manual",
        "toolDescription": "Google Sheet Context Retrieval Tool\nGet Context from Gooogle Sheet"
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "ypmzFxQFfAacuVVC",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "325816aa-d11a-4d73-80f6-b824423e73ae",
      "name": "Send Reply to User",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1000,
        -20
      ],
      "webhookId": "e676b1f3-9342-4ad0-ac8f-71ec08a27fbc",
      "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 – Here’s a Response from Our Team",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "sWl7FFMkEUYBj0zM",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "cc2247c3-2cc6-4c38-9302-555ba124d3e9",
      "name": "Reply Generator KI-Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        660,
        -20
      ],
      "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’s 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": "02a2e4bd-05e6-4b3b-b2a4-fa02623c5b25",
      "name": "Watch Gmail for New Incoming E-Mails",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        40,
        -20
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "sWl7FFMkEUYBj0zM",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "cfa9d0a9-5e38-43ef-9ce7-ddd86c266ec2",
      "name": "Log Inquiries + Response to Google Sheet",
      "type": "n8n-nodes-base.googleSheets",
      "position": [
        1200,
        -20
      ],
      "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 – Context & Logs"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "ypmzFxQFfAacuVVC",
          "name": "Google Sheets account"
        }
      },
      "typeVersion": 4.5
    },
    {
      "id": "47816515-d96d-412c-9ff8-4cb9e3aff9ae",
      "name": "Inquiry Filter",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        260,
        -20
      ],
      "parameters": {
        "options": {},
        "inputText": "={{ $json.text }}",
        "categories": {
          "categories": [
            {
              "category": "Inquiry",
              "description": "The message is asking a question, requesting information, or seeking help — 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": "fca2b9cf-2427-4482-a1d8-8788b2b26507",
      "name": "Haftnotiz2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -280,
        -140
      ],
      "parameters": {
        "color": 4,
        "width": 260,
        "height": 380,
        "content": "## SETUP REQUIRED\n\nGoogle Sheets Structure:\nSheet 1: \"FAQ_Context\"\n• Column A: Context\n\nSheet 2: \"Enquiry_Log\"\n• Column A: Timestamp\n• Column B: Sender Email\n• Column C: Subject\n• Column D: Original Message\n• Column E: AI Response\n\nRequired Credentials:\n• OpenAI API Key\n• Google Sheets Credential\n• Gmail Credential"
      },
      "typeVersion": 1
    },
    {
      "id": "7326118b-b01e-466e-92ec-b4ea5e77af0d",
      "name": "Haftnotiz1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        580,
        -80
      ],
      "parameters": {
        "color": 4,
        "width": 380,
        "height": 520,
        "content": "🤖 Reads email and creates intelligent replies"
      },
      "typeVersion": 1
    },
    {
      "id": "5b256ec0-2b8b-4f24-bf76-8bb489087a25",
      "name": "Haftnotiz",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1140,
        -100
      ],
      "parameters": {
        "color": 4,
        "width": 260,
        "height": 280,
        "content": "✏️ Records every inquiry and response"
      },
      "typeVersion": 1
    },
    {
      "id": "27a368f2-abe2-4f3d-ac3e-c433a5512c61",
      "name": "Haftnotiz3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        300
      ],
      "parameters": {
        "color": 5,
        "width": 460,
        "height": 420,
        "content": "## 📧 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": "3795025b-4daf-439d-82e4-a4f872fe0ea0",
      "name": "Haftnotiz4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        300
      ],
      "parameters": {
        "color": 5,
        "width": 400,
        "height": 340,
        "content": "## 📋 WORKFLOW PROCESS OVERVIEW\nStep 1: 📧 Gmail monitors inbox for new incoming emails\nStep 2: 🤖 AI classifies email as genuine inquiry vs spam/newsletter\nStep 3: 🔍 AI analyzes customer questions and searches FAQ database\nStep 4: ✍️ AI generates comprehensive, contextual response using approved answers\nStep 5: 📤 Automated reply sent to customer with professional tone\nStep 6: 📝 Complete interaction logged to Google Sheets for tracking"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {
    "Watch Gmail for New Incoming Emails": [
      {
        "id": "1970bbabb2a1b16a",
        "to": {
          "html": "<span class=\"mp_address_group\"><span class=\"mp_address_name\">Billy Christi Hartanto</span> &lt;<a href=\"mailto:billychartanto@gmail.com\" class=\"mp_address_email\">billychartanto@gmail.com</a>&gt;</span>",
          "text": "\"Billy Christi Hartanto\" <billychartanto@gmail.com>",
          "value": [
            {
              "name": "Billy Christi Hartanto",
              "address": "billychartanto@gmail.com"
            }
          ]
        },
        "date": "2025-05-26T08:34:35.000Z",
        "from": {
          "html": "<span class=\"mp_address_group\"><span class=\"mp_address_name\">Billy Christi Hartanto</span> &lt;<a href=\"mailto:billychartanto@gmail.com\" class=\"mp_address_email\">billychartanto@gmail.com</a>&gt;</span>",
          "text": "\"Billy Christi Hartanto\" <billychartanto@gmail.com>",
          "value": [
            {
              "name": "Billy Christi Hartanto",
              "address": "billychartanto@gmail.com"
            }
          ]
        },
        "html": "<div dir=\"ltr\">What is your pricing?<br><br>what is your uptime<br><br>what will happen for new user?</div>\n",
        "text": "1. Can I try your service before paying? 2. How do I cancel my subscription? 3. I need a refund. How does that work? 4. Where can I download my invoice? 5. What’s included in the Basic Plan? 6. Do you integrate with Google Sheets and Airtable? 7. Is your platform GDPR-compliant? 8. I’m locked out of my account—what should I do? 9. How can I upgrade my current plan? 10. Do you offer support in Indonesian?",
        "headers": {
          "to": "To: Billy Christi Hartanto <billychartanto@gmail.com>",
          "date": "Date: Mon, 26 May 2025 16:34:35 +0800",
          "from": "From: Billy Christi Hartanto <billychartanto@gmail.com>",
          "subject": "Subject: I want to ask something",
          "message-id": "Message-ID: <CAMAvGrJjGkxgDQU+yLWckOVW7JvYGWvQQEDOoXZk6WYoGESVgQ@mail.gmail.com>",
          "content-type": "Content-Type: multipart/alternative; boundary=\"0000000000006cd8ca063605d1a4\"",
          "mime-version": "MIME-Version: 1.0"
        },
        "subject": "I want to ask something",
        "labelIds": [
          "UNREAD",
          "IMPORTANT",
          "SENT",
          "INBOX"
        ],
        "threadId": "1970bba4c2e53c91",
        "messageId": "<CAMAvGrJjGkxgDQU+yLWckOVW7JvYGWvQQEDOoXZk6WYoGESVgQ@mail.gmail.com>",
        "textAsHtml": "<p>What is your pricing?</p><p>what is your uptime</p><p>what will happen for new user?</p>",
        "sizeEstimate": 744
      }
    ]
  },
  "connections": {
    "47816515-d96d-412c-9ff8-4cb9e3aff9ae": {
      "main": [
        [
          {
            "node": "Reply Generator AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "47816515-d96d-412c-9ff8-4cb9e3aff9ae",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Reply Generator AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "325816aa-d11a-4d73-80f6-b824423e73ae": {
      "main": [
        [
          {
            "node": "cfa9d0a9-5e38-43ef-9ce7-ddd86c266ec2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply Generator AI Agent": {
      "main": [
        [
          {
            "node": "325816aa-d11a-4d73-80f6-b824423e73ae",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "40ba7c6e-5854-4313-b695-9ed86c4c8e80": {
      "ai_outputParser": [
        [
          {
            "node": "Reply Generator AI Agent",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Watch Gmail for New Incoming Emails": {
      "main": [
        [
          {
            "node": "47816515-d96d-412c-9ff8-4cb9e3aff9ae",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets Context Retrieval Tool": {
      "ai_tool": [
        [
          {
            "node": "Reply Generator AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}
Häufig gestellte Fragen

Wie verwende ich diesen Workflow?

Kopieren Sie den obigen JSON-Code, erstellen Sie einen neuen Workflow in Ihrer n8n-Instanz und wählen Sie "Aus JSON importieren". Fügen Sie die Konfiguration ein und passen Sie die Anmeldedaten nach Bedarf an.

Für welche Szenarien ist dieser Workflow geeignet?

Fortgeschritten - Support, Künstliche Intelligenz

Ist es kostenpflichtig?

Dieser Workflow ist völlig kostenlos. Beachten Sie jedoch, dass Drittanbieterdienste (wie OpenAI API), die im Workflow verwendet werden, möglicherweise kostenpflichtig sind.

Workflow-Informationen
Schwierigkeitsgrad
Fortgeschritten
Anzahl der Nodes14
Kategorie2
Node-Typen9
Schwierigkeitsbeschreibung

Für erfahrene Benutzer, mittelkomplexe Workflows mit 6-15 Nodes

Autor
Billy Christi

Billy Christi

@billy

I'm a professional software engineer and n8n expert with a passion for building scalable, no-code and low-code automation workflows. I specialize in creating seamless integrations between APIs, CRMs, and everyday tools to help businesses save time, reduce manual work, and operate smarter. Whether it's automating marketing pipelines, backend systems, or approval processes, I turn complex logic into simple, powerful workflows with n8n.

Externe Links
Auf n8n.io ansehen

Diesen Workflow teilen

Kategorien

Kategorien: 34