AI · Automation 2025 Completed

AI Email Automation — Intelligent Gmail Reply System

An n8n workflow that reads unread Gmail, classifies each message as personal or business, detects first contact vs follow-up and sends tone-matched AI replies with Claude and GPT.

Built by Redoan Uzzaman, Full-Stack Developer & AI Engineer.

AI Email Automation — Intelligent Gmail Reply System

Overview

This project is an n8n workflow that manages an inbox automatically: it reads incoming Gmail, works out what kind of email it is and where it sits in a conversation, and replies in an appropriate tone.

How it works

A Gmail trigger polls for unread messages every minute. An AI agent extracts the latest message from the thread, then the workflow fetches recent emails and filters them by thread ID to count how many messages the conversation already contains — the signal used to distinguish a first contact from a follow-up.

The email is then classified as Personal, Business or neither by an AI step, confirmed by an n8n text classifier. Emails with no clear category are left alone. Personal and business messages receive the matching Gmail label and are routed into one of four reply paths: personal first contact, personal follow-up, business first contact and business follow-up.

Each path has its own AI agent and prompt, using Anthropic Claude for writing and OpenAI GPT models for extraction and classification. The agents mirror the sender's tone, sign business replies while keeping personal replies casual, and answer within the existing thread so the conversation stays intact.

Key Features

  • Gmail polling every minute for unread messages
  • AI extraction of the latest message in a thread
  • Thread counting to detect first contact vs follow-up
  • Two-stage Personal/Business classification
  • Automatic Gmail labeling
  • Four context-specific reply strategies with tone matching
  • Threaded replies powered by Anthropic Claude

Tech Stack

  • n8n
  • Gmail API
  • Anthropic Claude
  • OpenAI GPT-4.1-mini
  • LangChain
  • JavaScript

Want something like this built?

Redoan Uzzaman takes on AI, automation and full-stack projects for clients worldwide.