AutomationFlowsEmail & Gmail › AI Gmail Auto-Responder with OpenAI

AI Gmail Auto-Responder with OpenAI

Original n8n title: Email Auto-responder AI

Email Auto-Responder AI. Uses gmailTrigger, openAi, gmail, googleSheets. Event-driven trigger; 6 nodes.

Event trigger★★★★☆ complexityAI-powered6 nodesGmail TriggerOpenAIGmailGoogle Sheets
Email & Gmail Trigger: Event Nodes: 6 Complexity: ★★★★☆ AI nodes: yes Added:

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
{
  "name": "Email Auto-Responder AI",
  "nodes": [
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "filters": {
          "readStatus": "unread",
          "receivedAfter": "={{ $now.minus(1, 'hour').toISO() }}"
        },
        "options": {}
      },
      "id": "c3d4e5f6-3333-4000-8000-000000000001",
      "name": "Gmail Trigger",
      "type": "n8n-nodes-base.gmailTrigger",
      "typeVersion": 1.2,
      "position": [
        250,
        300
      ],
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "resource": "chat",
        "operation": "message",
        "model": "gpt-4o",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are an AI email assistant. Analyze the incoming email and draft an appropriate reply. You must respond with a JSON object containing:\n- \"analysis\": brief summary of the email\n- \"category\": one of [inquiry, complaint, scheduling, follow_up, spam, personal]\n- \"confidence\": number 0-1 indicating how confident you are in the draft\n- \"draft_reply\": the full email reply text\n- \"subject\": reply subject line\n\nBe professional, concise, and helpful. Do not agree to anything on behalf of the user. If unsure, indicate that the user will follow up personally."
            },
            {
              "role": "user",
              "content": "=From: {{ $json.from.value[0].address }}\nSubject: {{ $json.subject }}\n\nBody:\n{{ $json.text || $json.snippet }}"
            }
          ]
        },
        "options": {
          "temperature": 0.4,
          "maxTokens": 1024
        }
      },
      "id": "c3d4e5f6-3333-4000-8000-000000000002",
      "name": "OpenAI Analyze & Draft",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "typeVersion": 1.6,
      "position": [
        500,
        300
      ],
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": false,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "confidence-check",
              "leftValue": "={{ JSON.parse($json.text).confidence }}",
              "rightValue": 0.7,
              "operator": {
                "type": "number",
                "operation": "gte",
                "name": "filter.operator.gte"
              }
            },
            {
              "id": "not-spam",
              "leftValue": "={{ JSON.parse($json.text).category }}",
              "rightValue": "spam",
              "operator": {
                "type": "string",
                "operation": "notEquals",
                "name": "filter.operator.notEquals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "c3d4e5f6-3333-4000-8000-000000000003",
      "name": "Confidence Check",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.1,
      "position": [
        750,
        300
      ]
    },
    {
      "parameters": {
        "sendTo": "={{ $('Gmail Trigger').item.json.from.value[0].address }}",
        "subject": "={{ JSON.parse($('OpenAI Analyze & Draft').item.json.text).subject }}",
        "emailType": "text",
        "message": "={{ JSON.parse($('OpenAI Analyze & Draft').item.json.text).draft_reply }}",
        "options": {
          "replyTo": "={{ $('Gmail Trigger').item.json.messageId }}"
        }
      },
      "id": "c3d4e5f6-3333-4000-8000-000000000004",
      "name": "Gmail Send Reply",
      "type": "n8n-nodes-base.gmail",
      "typeVersion": 2.1,
      "position": [
        1000,
        200
      ],
      "credentials": {
        "gmailOAuth2": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "your-google-sheet-id",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Email Log",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "timestamp": "={{ $now.toISO() }}",
            "from": "={{ $('Gmail Trigger').item.json.from.value[0].address }}",
            "subject": "={{ $('Gmail Trigger').item.json.subject }}",
            "category": "={{ JSON.parse($('OpenAI Analyze & Draft').item.json.text).category }}",
            "confidence": "={{ JSON.parse($('OpenAI Analyze & Draft').item.json.text).confidence }}",
            "auto_replied": "=true",
            "analysis": "={{ JSON.parse($('OpenAI Analyze & Draft').item.json.text).analysis }}"
          }
        },
        "options": {}
      },
      "id": "c3d4e5f6-3333-4000-8000-000000000005",
      "name": "Google Sheets Log",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1250,
        200
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "your-google-sheet-id",
          "mode": "id"
        },
        "sheetName": {
          "__rl": true,
          "value": "Email Log",
          "mode": "name"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "timestamp": "={{ $now.toISO() }}",
            "from": "={{ $('Gmail Trigger').item.json.from.value[0].address }}",
            "subject": "={{ $('Gmail Trigger').item.json.subject }}",
            "category": "={{ JSON.parse($('OpenAI Analyze & Draft').item.json.text).category }}",
            "confidence": "={{ JSON.parse($('OpenAI Analyze & Draft').item.json.text).confidence }}",
            "auto_replied": "=false",
            "analysis": "={{ JSON.parse($('OpenAI Analyze & Draft').item.json.text).analysis }}"
          }
        },
        "options": {}
      },
      "id": "c3d4e5f6-3333-4000-8000-000000000006",
      "name": "Log Skipped Email",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.5,
      "position": [
        1000,
        450
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Gmail Trigger": {
      "main": [
        [
          {
            "node": "OpenAI Analyze & Draft",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Analyze & Draft": {
      "main": [
        [
          {
            "node": "Confidence Check",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Confidence Check": {
      "main": [
        [
          {
            "node": "Gmail Send Reply",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Log Skipped Email",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Gmail Send Reply": {
      "main": [
        [
          {
            "node": "Google Sheets Log",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null
}

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

Email Auto-Responder AI. Uses gmailTrigger, openAi, gmail, googleSheets. Event-driven trigger; 6 nodes.

Source: https://github.com/mlnjsh/n8n-workflows-mega/blob/main/workflows/ai-agents/03-email-auto-responder-ai.json — original creator credit. Request a take-down →

More Email & Gmail workflows → · Browse all categories →

Related workflows

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

Email & Gmail

Send A Chatgpt Email Reply And Save Responses To Google Sheets. Uses openAi, gmailTrigger, stickyNote, gmail. Event-driven trigger; 49 nodes.

OpenAI, Gmail Trigger, Gmail +2
Email & Gmail

Code. Uses openAi, gmailTrigger, stickyNote, gmail. Event-driven trigger; 49 nodes.

OpenAI, Gmail Trigger, Gmail +2
Email & Gmail

This workflow sends a OpenAI GPT reply when an email is received from specific email recipients. It then saves the initial email and the GPT response to an automatically generated Google spreadsheet.

OpenAI, Gmail Trigger, Gmail +2
Email & Gmail

n8n Recruitment. Uses gmailTrigger, openAi, googleSheets, gmail. Event-driven trigger; 20 nodes.

Gmail Trigger, OpenAI, Google Sheets +4
Email & Gmail

Email AI Agent. Uses gmailTrigger, textClassifier, lmChatOpenAi, gmail. Event-driven trigger; 18 nodes.

Gmail Trigger, Text Classifier, OpenAI Chat +3