<aside>

Goal

Automate personalized email responses by combining contact data lookup with AI-generated replies, eliminating manual email handling while maintaining authentic, context-aware communication.

Solution

Features


Steps

1. Email Monitoring

Node: Gmail Trigger

Purpose: Monitors Gmail inbox for new incoming emails.

Configuration:

2. Contact Lookup

Node: Get row(s) (Data Table)

Purpose: Searches for sender email in Contacts database.

Configuration:

Output: Contact record with Name, Email, Phone, Notes (if exists)

Design Decision: If contact not found, workflow stops here. Only known contacts receive automated responses to prevent spam-like behavior.

3. AI Response Generation

Node: Message a model (Claude)

Purpose: Generates personalized email response using contact context.

Configuration:

User Prompt:

You are an AI assistant helping to write professional email responses.

Create a well-formatted HTML email response based on the customer information and received email.

Customer Data:
1-Name: {{ $json.Name }}

2-Notes: {{ $json.Notes }}

Received Email:
1-Email Subject: {{ $('Gmail Trigger').item.json.headers.subject }}

2-Email Body: {{ $('Gmail Trigger').item.json.text }}

CRITICAL: Your response MUST follow this EXACT format:

Subject: [Your subject line]

HTML_BODY_START
<p>Hi [Name],</p>

<p>[First paragraph with warm acknowledgment]</p>

<p>[Main content addressing their needs]</p>

<p>[Next steps or questions]</p>

<p>Best regards,<br>
Alvaro</p>
HTML_BODY_END

Rules:
- Use <p> tags for paragraphs
- Use <br> for line breaks
- Keep it clean and professional
- The HTML_BODY_START and HTML_BODY_END markers are REQUIRED

4. Response Parsing

Node: Code in Python (Beta)

Purpose: Extracts structured subject and HTML body from Claude's response.

Logic:

Why needed: Gmail node requires separate subject and body fields

5. Email Delivery

Node: Send a message (Gmail)

Purpose: Sends formatted HTML email response to original sender.

Configuration:


Tools Used


Impact


Learnings


Database Schema

Contacts Table:


Sales Data Analysis Agent

This workflow also includes a conversational AI agent for analyzing sales data using natural language queries.

Architecture

Trigger: Chat interface (When chat message received)

AI Agent: Sales Data Agent with Claude Sonnet 4.5 (via OpenRouter)

Tools Available:

  1. All Rows - Returns complete sales dataset
  2. Product Name Query - Filters by product (Wireless Headphones, Bluetooth Speaker, Phone Case)
  3. Date Query - Filters by date (YYYY-MM-DD format)
  4. Product ID Query - Filters by ID (WH001, BS002, PC003) </aside>

Screenshot 2025-10-02 163854.png

๐Ÿ“‚ Download & Explore the Workflow:

Smart Gmail Auto-Reply with Claude.json

View GitHub Repository:

Smart-Gmail-Auto-Reply-with-Claude-n8n/Smart Gmail Auto-Reply with Claude.json at main ยท AlvLeoAI/Smart-Gmail-Auto-Reply-with-Claude-n8n