Introduction
Welcome to Article 4 of the AI Automation Series! This is where things get truly exciting — we’re going to connect ChatGPT (OpenAI API) to n8n and build an intelligent email responder. This AI agent will read incoming support emails, understand the context, and automatically generate and send professional responses without any human involvement.
🌍 Real-World Scenario: AI Customer Support Agent
A SaaS company receives 200+ support emails daily. Their team spends 4+ hours just triaging and replying to basic questions. By connecting ChatGPT to their email workflow in n8n, they can automate 70% of responses — handling FAQs, account questions, and billing inquiries automatically while escalating complex issues to humans.
⚙️ Step 1: Get Your OpenAI API Key
Go to https://platform.openai.com and sign in. Navigate to “API Keys” in the left menu. Click “Create new secret key” and copy it immediately (you won’t see it again). Make sure to add billing information since the API is pay-as-you-go (typically $0.002 per 1K tokens for GPT-3.5-turbo, very affordable for most use cases).
⚙️ Step 2: Add OpenAI Credentials in n8n
In n8n, go to Settings > Credentials > New Credential. Search for “OpenAI” and select it. Paste your API key in the “API Key” field and click “Save”. Your OpenAI account is now connected to n8n.
🔨 Step 3: Build the AI Email Responder Workflow
Step 3.1 – Gmail Trigger: Watch for New Emails
Create a new workflow in n8n. Add a “Gmail Trigger” node. Connect your Gmail account. Set it to trigger on “New Email”. Add a filter: Label = “Support” (or Unread). Set polling interval to every 5 minutes.
Step 3.2 – Extract Email Content
Add a “Set” node to extract and clean the email data. Create variables: sender_email = {{$json.from}}, sender_name = {{$json.fromName}}, subject = {{$json.subject}}, email_body = {{$json.text}} (plain text version of email).
Step 3.3 – ChatGPT Node: Classify the Email
Add an “OpenAI” node. Select “Message a Model”. Use GPT-3.5-turbo. Set the system prompt to: “You are an email classifier for a SaaS company. Classify this email into one of these categories: FAQ, BILLING, TECHNICAL, COMPLAINT, or ESCALATE. Reply with only the category name.” Set the user message to: {{$node[“Set”].json[“email_body”]}}. This determines what kind of response to send.
Step 3.4 – Add an IF Node for Routing
Add an “IF” node. Condition: {{$json.message.content}} does NOT equal “ESCALATE”. This routes FAQs, billing, and technical queries to the AI responder, while ESCALATE emails go to a human agent via Slack notification.
Step 3.5 – ChatGPT Node: Generate the Response
On the “True” path, add another OpenAI node. System prompt: “You are a professional customer support agent for AcmeSaaS. Write a helpful, friendly, and concise email response. Sign off as ‘The AcmeSaaS Support Team’. Keep responses under 150 words.” User message: “The customer sent this email: {{$node[“Set”].json[“email_body”]}} — Category: {{$node[“OpenAI”].json[“message”][“content”]}}. Write an appropriate response.”
Step 3.6 – Gmail: Send the Reply
Add a Gmail “Send Email” node. Set “To” = {{$node[“Set”].json[“sender_email”]}}, “Subject” = Re: {{$node[“Set”].json[“subject”]}}, “Body” = {{$node[“OpenAI1”].json[“message”][“content”]}}. Check “Is Reply” and set the Thread ID to reply in the same email thread.
⚙️ Step 4: Handle Escalations
On the “False” path (ESCALATE emails), add a Slack node. Send a message to #support-escalations: “🚨 Escalation needed! From: {{sender_name}} ({{sender_email}}) — Subject: {{subject}} — Please review and respond manually.”
📊 Results & Impact
After implementing this automation, the company saw: 73% of emails handled automatically, average response time dropped from 4 hours to under 3 minutes, customer satisfaction scores improved by 22%, and the support team could focus on complex issues that truly needed human expertise.
🚀 What’s Next?
In Article #5, we’ll build an AI-powered lead qualification system using Make.com + ChatGPT that scores incoming leads and automatically routes them to the right sales rep based on their potential value.