Gmail assistant with full Gmail history RAG using OpenAI
Needs changesWhat this workflow does
This AI workflow has 20 nodes and runs when a chat message arrives (plus 2 other triggers). Along the way it connects OpenAI Chat Model, Embeddings OpenAI, Qdrant Vector Store and Gmail.
How it runs
Trigger: When a chat message arrives (plus 2 other triggers).
- RAG Agent (AI Agent): runs an AI agent, with model: OpenAI Chat Model; 1 tool (Qdrant Email Vector Store); memory: Simple Memory
- Get new Email Body (Gmail): get
- Get all emails (Gmail): get many
- Store Emails in Vector DB (Qdrant Vector Store): stores documents in the Qdrant vector store, with embeddings: Embeddings OpenAI; document loader: Set proper metadata
- Refactor Email Body data (Code): runs custom JavaScript code
- Loop over all emails (Loop Over Items (Split in Batches)): loops over the items in batches
- Store Emails in Vector DB (Qdrant Vector Store): stores documents in the Qdrant vector store, with embeddings: Embeddings OpenAI; document loader: Set proper metadata
Services it uses
Other OpenAI + Gmail templates (1,623) · Other OpenAI + Qdrant templates (67) · Other Gmail + Qdrant templates (12)
Before you upgrade to n8n 3.0
1 thing in this workflow is removed in n8n 3.0. Fix it before you upgrade:
- AI Agent v1 (old agent modes) in RAG Agent (v1.7): replace with Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent.
- Also check Gmail Trigger below v1.4 runs as v1.4 (drafts skipped, max emails per poll).
Rather not rewrite it? Many of these flows can be rebuilt in Make (free plan).
Published 2025 — 19% of 2025 templates need changes for 3.0. See how template age affects 3.0 readiness →
- Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
| Removed in 3.0 | Replace with |
|---|---|
| AI Agent v1 (old agent modes) RAG Agent (v1.7) | Latest AI Agent node (Tools Agent). For SQL Agent, use a Postgres or MySQL tool with a recent AI Agent. |
Nodes used (13)
- OpenAI Chat Model
@n8n/n8n-nodes-langchain.lmChatOpenAi - Manual Trigger
n8n-nodes-base.manualTrigger - AI Agent
@n8n/n8n-nodes-langchain.agent - Embeddings OpenAI
@n8n/n8n-nodes-langchain.embeddingsOpenAi - Qdrant Vector Store
@n8n/n8n-nodes-langchain.vectorStoreQdrant - Chat Trigger
@n8n/n8n-nodes-langchain.chatTrigger - Simple Memory
@n8n/n8n-nodes-langchain.memoryBufferWindow - Gmail Trigger
n8n-nodes-base.gmailTrigger - Gmail
n8n-nodes-base.gmail - Code
n8n-nodes-base.code - Loop Over Items (Split in Batches)
n8n-nodes-base.splitInBatches - Default Data Loader
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - Character Text Splitter
@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter
From the author
🧠 RAG with Full Gmail history + Real time email updates in RAG using OpenAI & Qdrant > Summary: > This workflow listens for new Gmail messages, extracts and cleans email content, generates embeddings via OpenAI, stores them in a Qdrant vector database,…