AI-Powered Email Replies with Spam Filtering & FAQ Lookup using GPT-4o mini & Pinecone

Go to Workflow
255 views
Built by Matteo Matteo
Created on June 05, 2026

Description

This n8n workflow automates the handling of incoming emails. It detects and filters out spam, searches a knowledge base (FAQ) stored in a Pinecone vector database, and sends a reply using Gmail — all powered by an AI model (GPT-4o mini).

How It Works
Receiving Emails

The Gmail Trigger node checks a Gmail inbox every hour.

When a new email arrives, it starts the workflow.

Fetching Full Email Content

The get_message node retrieves all the details of the message: sender, subject, text, message ID, etc.

Spam Filtering

The Spam checker node uses GPT-4o mini to classify the email as either "spam" or "no spam".

It detects not only classic spam but also automated messages (e.g. from Google or Microsoft).

If marked as "spam", the workflow ends and nothing is processed.

Conditional Filter

The If node checks the spam result.

Only "no spam" emails proceed to the AI Agent.

AI-Based Reply

The AI Agent node generates a response based on:

The email content

A system prompt defining the assistant’s behavior (polite, professional, under the name “Total AI Solutions”)

Information retrieved from the Pinecone Vector Store, which contains FAQs

The AI is instructed to always check the vector store before replying.

The AI prepares both the subject and the body of the reply.

Sending the Reply

The Gmail node sends the reply to the original sender.

It uses the original email's ID to keep the thread intact.

Language Model

The OpenAI Chat Model node provides GPT-4o mini as the language engine for generating responses.

Memory Support

The Simple Memory node maintains short-term context, helpful in multi-turn conversations.

Knowledge Base (FAQ)

The Pinecone Vector Store node connects to a Pinecone index (faqmattabott) containing vectorized FAQ content.

Vectors are created using the Embeddings OpenAI node.

Nodes Used (7)

AI Agent
@n8n/n8n-nodes-langchain.agent
Embeddings OpenAI
@n8n/n8n-nodes-langchain.embeddingsOpenAi
Gmail
n8n-nodes-base.gmail
OpenAI
@n8n/n8n-nodes-langchain.openAi
OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi
Pinecone Vector Store
@n8n/n8n-nodes-langchain.vectorStorePinecone
Simple Memory
@n8n/n8n-nodes-langchain.memoryBufferWindow