AutomationFlowsAI & RAG › AI Email Responder with Gmail & Gemini

AI Email Responder with Gmail & Gemini

Original n8n title: Smart Email Responder Workflow Using AI

ByAnkur Parag Kulkarni @ankur on n8n.io

This project presents an intelligent email management system powered by advanced artificial intelligence. It utilizes Google's Gemini 2.0 AI model to automatically categorize incoming emails into queries, project updates, and feedback, and generates context-specific responses in…

Event trigger★★★★☆ complexityAI-powered14 nodesGmail TriggerText ClassifierGoogle Gemini ChatEmail SendGmailGoogle Calendar
AI & RAG Trigger: Event Nodes: 14 Complexity: ★★★★☆ AI nodes: yes Added:

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

This workflow follows the Gmail → Gmail Trigger 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
{
  "id": "1RHsJldA8GlWFp1E",
  "meta": {
    "templateId": "3277",
    "templateCredsSetupCompleted": true
  },
  "name": "Smart Email Auto-Responder",
  "tags": [],
  "nodes": [
    {
      "id": "e485ab21-6c33-4cb1-9bd1-3fea3a1d431a",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "position": [
        1480,
        220
      ],
      "parameters": {
        "simple": false,
        "filters": {
          "labelIds": [
            "Label_43975351283257832"
          ]
        },
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyHour"
            }
          ]
        }
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "d52b02ce-95aa-495f-a6b4-d5dd791f2808",
      "name": "Text Classifier",
      "type": "@n8n/n8n-nodes-langchain.textClassifier",
      "position": [
        1820,
        400
      ],
      "parameters": {
        "options": {},
        "inputText": "={{ $('Gmail Trigger').item.json.subject }}\n{{ $('Gmail Trigger').item.json.text }}",
        "categories": {
          "categories": [
            {
              "category": "Questions",
              "description": "Use this category when the email is asking for information about our company, products, processes, pricing, timelines, legal terms or any other general inquiry that expects a factual explanation or guidance."
            },
            {
              "category": "Project Update",
              "description": "Choose this category when the sender is notifying us about progress or changes: signing the agreement, submitting or revising scripts, updating requirements, sharing evaluation results, or any status report that moves an ongoing project forward"
            },
            {
              "category": "Feedback",
              "description": "Select this category when the email contains compliments, complaints, suggestions, or any qualitative feedback about our service, product, communication or overall experience"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "adfca78f-9ce5-4345-baaa-017538e433be",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        1840,
        680
      ],
      "parameters": {
        "options": {},
        "modelName": "models/gemini-2.0-flash-exp"
      },
      "credentials": {
        "googlePalmApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "e7c91741-20d6-4c54-8dd5-efec164c29b3",
      "name": "Youtube Video Inquiry",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2260,
        580
      ],
      "parameters": {
        "html": "=<!DOCTYPE html>\n<html>\n<head>\n  <style>\n    body{font-family:Arial,sans-serif;line-height:1.6;color:#333;margin:0;padding:0;}\n    .container{width:100%;max-width:600px;margin:0 auto;padding:20px;}\n    .header{background:#f4f4f4;padding:10px 20px;text-align:center;border-bottom:1px solid #ddd;}\n    .header h1{margin:0;color:#555;}\n    .content{padding:20px;}\n    .content h2{color:#555;font-size:18px;margin:20px 0 10px;}\n    .content p{margin-bottom:15px;}\n    .content ul{list-style:disc;padding-left:20px;}\n    .content ul li{margin-bottom:10px;}\n    .content a{color:#007BFF;text-decoration:none;}\n    .content a:hover{text-decoration:underline;}\n    .footer{text-align:center;font-size:12px;color:#888;margin-top:20px;}\n  </style>\n</head>\n<body>\n  <div class=\"container\">\n    <div class=\"header\">\n      <h1>Project Update Acknowledgement</h1>\n    </div>\n\n    <div class=\"content\">\n      <p>\n        Hi {{ $json.from.value[0].name || $('Gmail Trigger').item.json.headers.from.split('<')[0].trim() || 'there' }},\n      </p>\n\n      <p>\n        Thank you for your recent update on the project. We\u2019ve reviewed the information you provided and have logged it in our system.\n      </p>\n\n      <h2>What we received:</h2>\n      <ul>\n        <li>Signed agreement / contract confirmation.</li>\n        <li>Revised requirements or scope changes.</li>\n        <li>Draft scripts or other deliverables for review.</li>\n        <li>Evaluation results or performance reports.</li>\n      </ul>\n\n      <h2>Next steps:</h2>\n      <ul>\n        <li>Our team will review the materials and integrate any changes within <strong>2\u20133 business days</strong>.</li>\n        <li>If clarifications are needed, we\u2019ll reach out via email or schedule a quick call.</li>\n        <li>You\u2019ll receive the updated project timeline once the review is complete.</li>\n      </ul>\n\n      <p>\n        If you have additional files or questions, feel free to reply directly to this email.\n      </p>\n\n      <p>\n        We appreciate your prompt communication and look forward to moving the project ahead smoothly.\n      </p>\n\n      <p>\n        Best regards,<br>\n        <strong>Sophia Mitchell</strong><br>\n        Project Coordinator | <a href=\"https://syncbricks.com\" target=\"_blank\">syncbricks.com</a><br>\n        WhatsApp: +1 &nbsp;\n      </p>\n    </div>\n\n    <div class=\"footer\">\n      \u00a9 2025 SyncBricks. All rights reserved.\n    </div>\n  </div>\n</body>\n</html>\n",
        "options": {
          "appendAttribution": false
        },
        "subject": "=Re: {{ $('Gmail Trigger').item.json.subject }}",
        "toEmail": "={{ $json.from.value[0].name }} <{{ $json.from.value[0].address }}>",
        "fromEmail": "user@example.com"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "61243957-40d1-4fb2-ad0a-6f923587c4db",
      "name": "Send Email",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2260,
        760
      ],
      "parameters": {
        "html": "=<!DOCTYPE html>\n<html>\n<head>\n  <style>\n    body{font-family:Arial,sans-serif;line-height:1.6;color:#333;margin:0;padding:0;}\n    .container{width:100%;max-width:600px;margin:0 auto;padding:20px;}\n    .header{background:#f4f4f4;padding:10px 20px;text-align:center;border-bottom:1px solid #ddd;}\n    .header h1{margin:0;color:#555;}\n    .content{padding:20px;}\n    .content h2{color:#555;font-size:18px;margin:20px 0 10px;}\n    .content p{margin-bottom:15px;}\n    .content ul{list-style:disc;padding-left:20px;}\n    .content ul li{margin-bottom:10px;}\n    .content a{color:#007BFF;text-decoration:none;}\n    .content a:hover{text-decoration:underline;}\n    .footer{text-align:center;font-size:12px;color:#888;margin-top:20px;}\n  </style>\n</head>\n<body>\n  <div class=\"container\">\n    <div class=\"header\">\n      <h1>Thank You for Your Feedback</h1>\n    </div>\n\n    <div class=\"content\">\n      <p>\n        Hi {{ $json.from.value?.[0]?.name || $('Gmail Trigger').item.json.headers.from.split('<')[0].trim() || 'there' }},\n      </p>\n\n      <p>\n        Thank you for taking the time to share your feedback about SyncBricks. We truly value every comment\u2014whether a\n        compliment, suggestion, or concern\u2014because it helps us improve.\n      </p>\n\n      <h2>What happens next:</h2>\n      <ul>\n        <li>Your message has been logged in our system&nbsp;(<strong>Reference ID:</strong>\n          {{ $json.id.slice(-6) }}).</li>\n        <li>Our team will review it within <strong>1 business day</strong>.</li>\n        <li>If an action is required, the appropriate team member will follow up directly with you.</li>\n      </ul>\n\n      <p>\n        If you need to add more details, simply reply to this email\u2014your message wil\n",
        "options": {
          "appendAttribution": false
        },
        "subject": "=Re:  {{ $('Gmail Trigger').item.json.Subject }}",
        "toEmail": "={{ $json.from.value[0].name }} <{{ $json.from.value[0].address }}>",
        "fromEmail": "user@example.com"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "a2542d02-4018-45e5-a8f2-875e669c77a3",
      "name": "Mark as Read",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2780,
        460
      ],
      "parameters": {
        "messageId": "={{ $('Gmail Trigger').all()[0].json.id }}\n",
        "operation": "markAsRead"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "0a1d79a3-91cf-4bf6-93bb-1482549a74dd",
      "name": "Apply Label",
      "type": "n8n-nodes-base.gmail",
      "position": [
        2960,
        460
      ],
      "parameters": {
        "labelIds": [
          "CATEGORY_UPDATES"
        ],
        "messageId": "={{ $('Gmail Trigger').all()[0].json.id }}\n",
        "operation": "addLabels"
      },
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "28467e9f-a730-4545-89cb-7d2c629edd71",
      "name": "Emails from Existing Contracts",
      "type": "n8n-nodes-base.if",
      "position": [
        1640,
        220
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "or",
          "conditions": [
            {
              "id": "7cffe101-333d-4ec2-a822-181fe421745b",
              "operator": {
                "type": "string",
                "operation": "contains"
              },
              "leftValue": "={{ $json.headers.from }}",
              "rightValue": "@syncbricks.com"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "b150ab4d-dcbb-4ae6-9503-5914e39f41ac",
      "name": "Reply",
      "type": "n8n-nodes-base.if",
      "position": [
        1640,
        460
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "07a6d5e2-ffc5-41d8-b69a-abd6860879c0",
              "operator": {
                "type": "string",
                "operation": "notStartsWith"
              },
              "leftValue": "={{ $json.subject }}",
              "rightValue": "Re:"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "1f043246-cbd0-466d-bbfd-b13131a66f03",
      "name": "QuestionsReply",
      "type": "n8n-nodes-base.emailSend",
      "position": [
        2720,
        160
      ],
      "parameters": {
        "html": "=<p>\n  Hi {{ $json.senderName }} <{{ $json.senderEmail }}>,\n</p>\n\n<p>Thanks for reaching out with your questions. I\u2019d love to cover everything face-to-face.</p>\n\n<p><strong>Location:</strong><br>\n123 Main St<br>\nLos Angeles, CA 90089\n</p>\n\n<p>We just sent you three calendar invitations for these time slots:</p>\n\n<ul>\n  {{ $json.slotTimes.map(t => `<li>${t}</li>`).join('') }}\n</ul>\n\n<p>\n  Click <em>Yes</em> on the invite that works best for you.  \n  Google will reserve that slot automatically; the other two will stay open.\n</p>\n\n<p>\n  If none of the times work, reply with a couple of alternatives and I\u2019ll find something that fits.\n</p>\n\n<p>Looking forward to meeting you!<br>\u2014 Corvin</p>\n",
        "options": {
          "appendAttribution": false
        },
        "subject": "=Re: {{ $json.originalSub }}",
        "toEmail": "={{ $json.senderName }} <{{ $json.senderEmail }}>",
        "fromEmail": "user@example.com"
      },
      "credentials": {
        "smtp": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 2.1
    },
    {
      "id": "60d50fdc-4e7f-4ab1-a240-1be4c8ae7520",
      "name": "Google Calendar",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        2100,
        160
      ],
      "parameters": {
        "limit": 3,
        "options": {
          "query": "Available \u2013 Office Visit",
          "orderBy": "startTime",
          "recurringEventHandling": "expand"
        },
        "timeMax": "=",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "user@example.com",
          "cachedResultName": "Meeting slots"
        },
        "operation": "getAll"
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "48a8b613-54e3-4002-8830-1726a23d24aa",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        2280,
        160
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "de676780-43c8-476d-ab8a-a692ffe4e65f",
      "name": "Google Calendar1",
      "type": "n8n-nodes-base.googleCalendar",
      "position": [
        2520,
        300
      ],
      "parameters": {
        "eventId": "={{$json.id}}",
        "calendar": {
          "__rl": true,
          "mode": "list",
          "value": "user@example.com",
          "cachedResultName": "Meeting slots"
        },
        "operation": "update",
        "updateFields": {
          "attendeesUi": {
            "values": {
              "attendees": [
                "={{ $(\"Gmail Trigger\").item.json.from.value[0].address }}\n"
              ]
            }
          },
          "sendUpdates": "all"
        }
      },
      "credentials": {
        "googleCalendarOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "df5552fc-910b-4b13-81fa-0c9d98ce82d7",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        2520,
        140
      ],
      "parameters": {
        "jsCode": "const triggerJson = $('Gmail Trigger').item.json;\nconst headersFrom  = triggerJson.headers.from;      // \"Name <user@example.com>\"\n\n// Split into name and address\nconst namePart = headersFrom.split('<')[0].replace(/^From:\\s*/i, '').trim();\nconst emailPart = headersFrom.match(/<([^>]+)>/)?.[1] || headersFrom;\n\nconst slotTimes = items.map(i =>\n  new Date(i.json.start.dateTime || i.json.start.date).toLocaleString(\n    'en-US',\n    { weekday:'short', month:'short', day:'numeric', hour:'numeric',\n      minute:'2-digit', hour12:true }\n  )\n);\n\nreturn [{\n  json: {\n    slotTimes,\n    senderName:  namePart,\n    senderEmail: emailPart,\n    originalSub: triggerJson.subject               // pass the subject along\n  }\n}];\n"
      },
      "typeVersion": 2
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "2b74a94c-8a92-4a15-b0a4-5590afba0f39",
  "connections": {
    "Code": {
      "main": [
        [
          {
            "node": "QuestionsReply",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reply": {
      "main": [
        [
          {
            "node": "Text Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Send Email": {
      "main": [
        [
          {
            "node": "Mark as Read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mark as Read": {
      "main": [
        [
          {
            "node": "Apply Label",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "Emails from Existing Contracts",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "QuestionsReply": {
      "main": [
        [
          {
            "node": "Mark as Read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Google Calendar1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text Classifier": {
      "main": [
        [
          {
            "node": "Google Calendar",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Youtube Video Inquiry",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Send Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Calendar1": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Youtube Video Inquiry": {
      "main": [
        [
          {
            "node": "Mark as Read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Text Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Emails from Existing Contracts": {
      "main": [
        [],
        [
          {
            "node": "Reply",
            "type": "main",
            "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 project presents an intelligent email management system powered by advanced artificial intelligence. It utilizes Google's Gemini 2.0 AI model to automatically categorize incoming emails into queries, project updates, and feedback, and generates context-specific responses in…

Source: https://n8n.io/workflows/4807/ — 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

3277. Uses gmailTrigger, textClassifier, lmChatGoogleGemini, emailSend. Event-driven trigger; 16 nodes.

Gmail Trigger, Text Classifier, Google Gemini Chat +3
AI & RAG

This n8n workflow is designed to intelligently manage incoming emails and automatically send personalized responses based on the content. It classifies emails using LangChain's Text Classifier, sends

Gmail Trigger, Text Classifier, Google Gemini Chat +3
AI & RAG

This workflow showcases various useful Gmail search, filter, and AI categorization operations and generates a knowledge graph for your mail using the InfraNodus GraphRAG API, which you can use to reve

HTTP Request, Google Gemini Chat, Gmail +3
AI & RAG

This n8n template demonstrates how to deploy an AI workflow in production while simultaneously running a robust, data-driven Evaluation Framework to ensure quality and optimize costs.

Sentiment Analysis, Gmail, Gmail Trigger +3
AI & RAG

This n8n template automatically classifies incoming emails (Sales, Support, Internal, Finance, Promotions) and routes them to a dedicated OpenAI LLM Agent for processing. Depending on the category, th

OpenAI, Gmail, Text Classifier +16