Extract Gmail Messages and Store in Vector Database
Workflow Description
Automation that captures incoming Gmail messages, splits their content into manageable text chunks, converts them into numerical embeddings using embedding models, and stores them in a Postgres vector database for semantic search and intelligent retrieval capabilities.
How it works
- 1.Receive new Gmail messages via trigger
- 2.Load and process message content
- 3.Split text into logical, processable segments
- 4.Convert segments into numerical vectors using embeddings
- 5.Batch vectors for efficient processing
- 6.Store vectors in PGVector database for retrieval
Use cases
- Create intelligent archives of work emails with semantic search capabilities
- Build an internal email search engine that understands meaning beyond keywords
Requirements
- Active Gmail account with API access enabled
- Postgres server with pgvector extension installed
- Local or cloud embedding model (Ollama or alternative)
Service Value
Ideal as a smart automation service combining integrations and AI to produce ready-to-use results.
Apps Used
Details
How to Use
- 1.Click "Download Template"
- 2.Open your n8n dashboard
- 3.Go to Workflows > Import from File
- 4.Select downloaded file and configure credentials
Nodes Used (20)
Embeddings Ollama
Embeddings Ollama
Default Data Loader
Document Default Data Loader
Recursive Character Text Splitter
Text Splitter Recursive Character Text Splitter
Gmail Trigger
Gmail
Loop Over Items
Split In Batches
Split Out
Split Out
Was manually triggered?
If
Manual Trigger
Manual Trigger
No Operation, do nothing
No Op
Sticky Note
Sticky Note
Sticky Note1
Sticky Note
Sticky Note2
Sticky Note
Set before and after dates
Set
Extract email fields
Set
Sticky Note3
Sticky Note
Store structured
Postgres
Store vectorized
Vector Store P G Vector
Create the table
Postgres
Explode interval into weeks
Code
Get a batch of messages
Gmail