Automatisierung von E-Mail-Antworten mit künstlicher Prüfung durch GPT-4o-mini und Gmail

Fortgeschritten

Dies ist ein Automatisierungsworkflow mit 14 Nodes. Hauptsächlich werden If, Gmail, GmailTrigger, ChainLlm, LmChatOpenAi und andere Nodes verwendet. Automatisierung der E-Mail-Antworten mit manueller Überprüfung durch GPT-4o-mini und Gmail

Voraussetzungen
  • Google-Konto + Gmail API-Anmeldedaten
  • OpenAI API Key

Kategorie

-
Workflow-Vorschau
Visualisierung der Node-Verbindungen, mit Zoom und Pan
Workflow exportieren
Kopieren Sie die folgende JSON-Konfiguration und importieren Sie sie in n8n
{
  "id": "YwTxqfTx1nnu0SLw",
  "meta": {
    "instanceId": "15d6057a37b8367f33882dd60593ee5f6cc0c59310ff1dc66b626d726083b48d",
    "templateCredsSetupCompleted": true
  },
  "name": "Automate Email Responses with GPT-4o-mini and Human Review in Gmail",
  "tags": [
    "GPT-4o-mini",
    "Gmail",
    "Human-in-the-loop",
    "AI",
    "Automation",
    "Email Responder",
    "Sales"
  ],
  "nodes": [
    {
      "id": "8129d250-e99b-48ea-a3a5-e9fb4728a623",
      "name": "Zur Freigabe senden",
      "type": "n8n-nodes-base.gmail",
      "position": [
        1840,
        1536
      ],
      "webhookId": "d62eb733-4e9f-420a-9b3d-5993448b85b1",
      "parameters": {
        "sendTo": "reviewer@example.com",
        "message": "=Original Customer Email:\n---\n{{ $('Gmail Trigger1').item.json.text }}\n---\n\nAI-Generated Reply (Draft):\n---\n{{ $json.output.body }}\n---\n\nPlease reply to this email with \"approve\" to send, or provide feedback for revision.",
        "options": {},
        "subject": "=RE: {{ $('Classify Potential Leads').item.json.subject }}",
        "operation": "sendAndWait",
        "responseType": "freeText"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "S97D1LtEAoJViOUO",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "7e7642e7-0635-43e0-a608-f2262717a9fb",
      "name": "✅ An Kunden senden",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2336,
        1360
      ],
      "webhookId": "543e2088-a720-4131-a924-81c72196164f",
      "parameters": {
        "sendTo": "={{ $('Gmail Trigger1').item.json.from.value[0].address }}",
        "message": "={{ $json.output.body }}",
        "options": {
          "appendAttribution": false
        },
        "subject": "={{ $json.output.subject }}",
        "emailType": "text"
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "S97D1LtEAoJViOUO",
          "name": "Gmail account"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "41f86e19-ffba-49aa-b83a-bbd62a648171",
      "name": "IF Genehmigt?",
      "type": "n8n-nodes-base.if",
      "position": [
        2048,
        1536
      ],
      "parameters": {
        "options": {
          "caseSensitive": false
        },
        "conditions": {
          "string": [
            {
              "value1": "={{ $json.data.text }}",
              "value2": "approve",
              "operation": "contains"
            },
            {
              "value1": "={{ $json.data.text }}",
              "value2": "承認",
              "operation": "contains"
            }
          ]
        },
        "combineOperation": "any"
      },
      "typeVersion": 1
    },
    {
      "id": "bfed408e-b2ba-4a17-9260-d8a4c3dfc12c",
      "name": "Gmail Trigger1",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        864,
        1552
      ],
      "parameters": {
        "simple": false,
        "filters": {},
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "id": "S97D1LtEAoJViOUO",
          "name": "Gmail account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "6e872edb-3a18-42d3-8c15-af2e1d92eee8",
      "name": "No Operation, do nothing1",
      "type": "n8n-nodes-base.noOp",
      "position": [
        1296,
        1744
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "29cbeac3-9b59-4dce-82d0-3a74e343c662",
      "name": "OpenAI Chat Model (for Classifier)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1088,
        1744
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "PlV73EwiIxyWywLc",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c444e590-b47d-4b90-aa8b-68a0e81ad61c",
      "name": "Potenzielle Leads klassifizieren",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        1088,
        1552
      ],
      "parameters": {
        "options": {
          "fallback": "other"
        },
        "inputText": "={{ $json.text }}",
        "categories": {
          "categories": [
            {
              "category": "AI Leads",
              "description": "=Routes emails that are potential AI leads. Catches inquiries about pricing, implementation, or requests for more information. Also identifies emails describing a business problem or task they want to solve or automate using AI, such as automating customer service or phone calls."
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e3610bb3-ce48-4c4b-aa0c-f1004f02a85b",
      "name": "Basic LLM Chain",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        1488,
        1536
      ],
      "parameters": {
        "text": "={{ $('Classify Potential Leads').item.json.text }}",
        "messages": {
          "messageValues": [
            {
              "message": "=# Role:\nYou are an AI Sales Development Representative (SDR) for **Momentum AI**, an agency specializing in custom AI automation solutions. Your primary role is to respond to inbound emails from potential leads who have questions about Momentum AI's products and services.\n\n# Mission:\nYour mission is to act as the first point of contact, building trust by resolving the lead's initial questions and challenges, with the ultimate goal of advancing them to the next stage in the sales funnel, such as a product demo or a specialist consultation.\n\n# Guiding Principles:\n1.  **Customer-Centric:** Always strive to understand the lead's business challenges and position your response as a contribution to their solution.\n2.  **Accuracy & Transparency:** Provide information based *exclusively* on the Knowledge Base below. If a question cannot be answered, state this transparently and never speculate or invent information.\n3.  **Proactive Engagement:** Do not let the conversation end with a simple Q&A. Always propose a logical and beneficial next step to deepen the engagement and move the conversation forward.\n4.  **Tone of Voice:** Maintain a professional, yet friendly and reliable tone, positioning yourself as a helpful \"AI partner.\" Avoid excessive jargon and explain concepts in clear, simple terms.\n\n# Response Generation Workflow:\n1.  **Step 1: Analyze Intent:**\n    *   Carefully read the inbound email to identify the lead's **primary questions**, their potential underlying **business needs**, and their current stage (**e.g., early information gathering vs. ready to implement**).\n\n2.  **Step 2: Retrieve Information & Construct Response:**\n    *   Consult the **Knowledge Base (FAQs)** below to find the relevant information for each question.\n    *   Structure your response as follows:\n        *   **1. Opening:** Thank the sender for their inquiry and briefly acknowledge their main question (e.g., \"Thank you for reaching out with your questions about our AI agent pricing.\").\n        *   **2. Body:** Answer each of the lead's questions clearly and concisely, using information from the Knowledge Base. Rephrase the information into a natural, conversational format—do not simply copy and paste.\n        *   **3. Call to Action (CTA):** Based on the nature of their inquiry, propose the most appropriate next step using the **\"CTA Logic\"** section below.\n\n3.  **Step 3: Handle Exceptions:**\n    *   If the Knowledge Base does not contain the answer to a specific question, respond honestly and professionally. Never invent an answer. Use one of the following approaches:\n        *   **Example 1 (for technical questions):** \"That's an excellent question. To give you the most accurate technical details on that, I'd like to connect you with one of our solution architects. Would you be open to a brief call with them?\"\n        *   **Example 2 (for general unknowns):** \"I don't have the specific details for that particular question at hand. However, I can connect you with a specialist on our team who can provide a comprehensive answer. May I make that introduction?\"\n\n---\n# Knowledge Base (FAQs):\n\n*   **Q: What kind of AI agents does Momentum AI build?**\n    *   A: We specialize in building bespoke AI agents that automate and optimize specific business workflows. Common examples include **(1) Intelligent Customer Support Agents** that resolve inquiries across email and chat, **(2) Automated Lead Qualification Agents** that score and route new leads, **(3) Internal Knowledge Base Assistants** that help your team find information instantly, and **(4) Data Entry & Processing Agents** that handle tedious administrative tasks. Every agent is custom-built from the ground up to meet your unique operational needs.\n\n*   **Q: What does your pricing look like?**\n    *   A: Our pricing is tailored to the project's scope. We typically offer a **one-time project fee** for initial development and a **monthly subscription fee** for hosting, maintenance, and ongoing performance tuning. The final cost depends on the agent's complexity and the number of systems it needs to integrate with. We always start with a complimentary discovery call to understand your goals, after which we can provide a detailed proposal and a transparent quote.\n\n*   **Q: What is the development timeline for a custom AI agent?**\n    *   A: Our process is agile and collaborative. A typical project timeline is **6-12 weeks**, broken down into three phases: **(1) Discovery & Design (1-2 weeks)**, where we map out your process and define the agent's logic. **(2) Development & Integration (4-8 weeks)**, where we build and connect the agent. **(3) Testing & Deployment (1-2 weeks)**, where we ensure everything works perfectly before going live. We provide a more precise timeline after the initial discovery phase.\n\n*   **Q: What makes Momentum AI different from off-the-shelf AI tools?**\n    *   A: Our key differentiator is our **consulting-led approach**. We don't just provide software; we partner with you to deeply analyze your existing workflows and re-engineer them for maximum AI efficiency. Unlike rigid, pre-built tools, our custom solutions are infinitely flexible and designed to integrate seamlessly into your exact processes. Furthermore, we provide a dedicated performance dashboard and ongoing optimization to ensure you achieve a clear ROI.\n\n*   **Q: What systems can your agents integrate with?**\n    *   A: Our agents are built for flexibility and can integrate with virtually any system that offers an API. We have extensive experience connecting with CRMs (like **Salesforce, HubSpot**), support desks (**Zendesk, Intercom**), communication platforms (**Slack, Microsoft Teams**), and internal databases. If a standard API isn't available, we can often develop a custom connector to bridge the gap.\n\n---\n# Call-to-Action (CTA) Logic:\n*   **If the lead asks about pricing or quotes:**\n    *   \"To provide you with an accurate quote, I'd suggest a brief 15-minute call to discuss your specific requirements. You can book a time that works for you directly on this calendar: [Link to Calendar]\"\n*   **If the lead asks vague questions about features or use cases:**\n    *   \"It might be helpful to see our AI agents in action. Would you be interested in a short, personalized demo where we can show you how it could work for a business like yours?\"\n*   **If the lead asks highly technical or integration-specific questions:**\n    *   \"For technical details like that, it's best to speak directly with our solutions architect. Shall I coordinate a brief meeting for you with them?\"\n*   **If the lead seems to be in an early information-gathering stage:**\n    *   \"We have a document that provides a more detailed overview of our services. Would you like me to send that over? You might also find the case studies on our website helpful: [Link to Case Studies Page]\"\n\n# Constraints:\n*   Do not speculate or provide information that is not in the Knowledge Base.\n*   Do not make definitive promises about product features or pricing.\n*   Never speak negatively about competitors.\n*   If an email is clearly spam or not a genuine inquiry, respond with a polite, generic message and end the conversation: \"Thank you for your message. If you have specific questions about Momentum AI services, please let us know.\"\n\n# Signature:\nAlways end your emails with the following signature.\n\n---\nBest regards,\n\nYUSUKE YAMAMOTO\nSales Development, Momentum AI\n[Company Website URL]\n---\n\n# Task Definition:\nYour task is determined by the data provided in the \"Input Data\" section below.\n1.  **If ONLY a `[Customer's Email]` is provided:** This is a **first draft creation**. Follow the \"Response Generation Workflow\" to write a new email response from scratch based on the customer's inquiry.\n2.  **If BOTH `[Human Feedback]` and `[Previous Email Draft]` are provided:** This is a **revision task**. Analyze the human's feedback and revise the `[Previous Email Draft]` to incorporate their suggestions. Do not start from scratch. Focus ONLY on applying the requested changes to the previous draft.\n\n# Input Data:\nThe input will be a combination of the following data fields. Some fields may be empty depending on the task.\n\n[Customer's Email]:\n\"\"\"\n{{ $('Classify Potential Leads').item.json.text }}\n\"\"\"\n\n[Human Feedback]:\n\"\"\"\n{{ $if($('IF Approved?').isExecuted, $('IF Approved?').last().item.json.data.text, '') }}\n\"\"\"\n\n[Previous Email Draft]:\n\"\"\"\n{{ $if($('IF Approved?').isExecuted, $self.item.json.output.body, '') }}\n\"\"\"\n"
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.6
    },
    {
      "id": "12714d3d-ee8a-4daa-a9e1-717404404c6a",
      "name": "Structured Output Parser",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        1632,
        1744
      ],
      "parameters": {
        "jsonSchemaExample": "{\n  \"subject\": \"This is an example subject line.\",\n  \"body\": \"This is an example email body.\\nIt can have multiple lines.\"\n}"
      },
      "typeVersion": 1.3
    },
    {
      "id": "9df68f69-8cc9-46a5-869d-5f03310381a4",
      "name": "OpenAI Chat Model (for LLM Chain)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1488,
        1744
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "PlV73EwiIxyWywLc",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "e6f54c9a-d971-460d-8549-d3369a19c52f",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        848,
        1296
      ],
      "parameters": {
        "color": 6,
        "width": 540,
        "height": 220,
        "content": "### Phase 1: Email Intake & Classification\n\n1.  **Gmail Trigger**: Watches for new emails.\n2.  **Classify Potential Leads**: Uses AI to check if the email is a potential lead. If not, the workflow stops."
      },
      "typeVersion": 1
    },
    {
      "id": "0d8ac3be-a67b-4835-9430-8c20141b655a",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1440,
        1104
      ],
      "parameters": {
        "color": 5,
        "width": 540,
        "height": 400,
        "content": "### Phase 2: AI Draft Generation\n\n-   **Basic LLM Chain**: The core AI agent. It receives the customer's email (and human feedback if it's a revision) and generates a reply.\n\n-   **OpenAI Chat Model**: The actual AI model (e.g., GPT-4o Mini) that powers the LLM Chain.\n\n-   **Structured Output Parser**: **Crucial for stability.** This forces the AI's free-text output into a structured JSON format (`{\"subject\": \"...\", \"body\": \"...\"}`). This prevents errors in later nodes."
      },
      "typeVersion": 1
    },
    {
      "id": "5062a472-a4f6-49a5-8664-d62153579b38",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1800,
        1040
      ],
      "parameters": {
        "color": 2,
        "width": 540,
        "height": 460,
        "content": "### Phase 3: Human Review & Loop\n\n1.  **Send for Review**: Sends the AI-generated draft to a human for approval. The workflow **pauses** here until a reply is received.\n\n2.  **IF Approved?**: Checks the reply for keywords like \"approve\" or \"承認\".\n    -   **True (Approved)**: Proceeds to send the email to the customer.\n    -   **False (Revision needed)**: The workflow **loops back** to the `Basic LLM Chain`, feeding the human's feedback into the prompt for revision."
      },
      "typeVersion": 1
    },
    {
      "id": "5fa2379e-4a6f-474c-83b5-4b533e54b6d0",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2296,
        1120
      ],
      "parameters": {
        "color": 4,
        "width": 540,
        "height": 200,
        "content": "### Phase 4: Final Action\n\n-   **✅ Send to Customer**: Once approved, this node sends the final, polished email to the original customer."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "334a762e-0d9b-4ec3-9f2c-ebab56adf947",
  "connections": {
    "41f86e19-ffba-49aa-b83a-bbd62a648171": {
      "main": [
        [
          {
            "node": "7e7642e7-0635-43e0-a608-f2262717a9fb",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "e3610bb3-ce48-4c4b-aa0c-f1004f02a85b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "bfed408e-b2ba-4a17-9260-d8a4c3dfc12c": {
      "main": [
        [
          {
            "node": "c444e590-b47d-4b90-aa8b-68a0e81ad61c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e3610bb3-ce48-4c4b-aa0c-f1004f02a85b": {
      "main": [
        [
          {
            "node": "8129d250-e99b-48ea-a3a5-e9fb4728a623",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8129d250-e99b-48ea-a3a5-e9fb4728a623": {
      "main": [
        [
          {
            "node": "41f86e19-ffba-49aa-b83a-bbd62a648171",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c444e590-b47d-4b90-aa8b-68a0e81ad61c": {
      "main": [
        [
          {
            "node": "e3610bb3-ce48-4c4b-aa0c-f1004f02a85b",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "6e872edb-3a18-42d3-8c15-af2e1d92eee8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "12714d3d-ee8a-4daa-a9e1-717404404c6a": {
      "ai_outputParser": [
        [
          {
            "node": "e3610bb3-ce48-4c4b-aa0c-f1004f02a85b",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "9df68f69-8cc9-46a5-869d-5f03310381a4": {
      "ai_languageModel": [
        [
          {
            "node": "e3610bb3-ce48-4c4b-aa0c-f1004f02a85b",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "29cbeac3-9b59-4dce-82d0-3a74e343c662": {
      "ai_languageModel": [
        [
          {
            "node": "c444e590-b47d-4b90-aa8b-68a0e81ad61c",
            "type": "ai_languageModel",
            "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

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
Kategorie-
Node-Typen9
Schwierigkeitsbeschreibung

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

Autor
YUSUKE YAMAMOTO

YUSUKE YAMAMOTO

@yusuke-yamamoto

Business creator from Tokyo. Designing AI-driven automations that enhance marketing, reporting, and daily operations. I turn complex workflows into simple, elegant automations with n8n.

Externe Links
Auf n8n.io ansehen

Diesen Workflow teilen

Kategorien

Kategorien: 34