Gmail to vector embeddings with PGVector and Ollama
Ready for 3.0What this workflow does
This AI workflow has 16 nodes and runs manually, when you click “Execute workflow” (plus 1 other trigger). Along the way it connects Embeddings Ollama, Gmail, Postgres and Postgres PGVector Store.
How it runs
Trigger: Manually, when you click “Execute workflow” (plus 1 other trigger).
- Create the table (Postgres): run a query
- Extract email fields (Edit Fields (Set)): sets 9 fields: email_text, email_from, email_to…
- Explode interval into weeks (Code): runs custom JavaScript code
- Store structured (Postgres): create or update
- Split Out: splits a list into separate items
- Store vectorized (Postgres PGVector Store): stores documents in the Postgres PGVector Store vector store, with embeddings: Embeddings Ollama; document loader: Default Data Loader
- Loop Over Items (Loop Over Items (Split in Batches)): loops over the items in batches
- Was manually triggered? (If): checks a condition and branches into true / false
- Set before and after dates (Edit Fields (Set)): sets 2 fields: after, before
- Get a batch of messages (Gmail): get many
Services it uses
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
- Still check Gmail Trigger below v1.4 runs as v1.4 (drafts skipped, max emails per poll) (Gmail Trigger).
Nodes used (14)
- Embeddings Ollama
@n8n/n8n-nodes-langchain.embeddingsOllama - Default Data Loader
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - Recursive Character Text Splitter
@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter - Gmail Trigger
n8n-nodes-base.gmailTrigger - Loop Over Items (Split in Batches)
n8n-nodes-base.splitInBatches - Split Out
n8n-nodes-base.splitOut - If
n8n-nodes-base.if - Manual Trigger
n8n-nodes-base.manualTrigger - No Operation, do nothing
n8n-nodes-base.noOp - Edit Fields (Set)
n8n-nodes-base.set - Postgres
n8n-nodes-base.postgres - Postgres PGVector Store
@n8n/n8n-nodes-langchain.vectorStorePGVector - Code
n8n-nodes-base.code - Gmail
n8n-nodes-base.gmail
From the author
Gmail to Vector Embeddings with PGVector and Ollama Who is this for? Everyone! Did you dream of asking an AI "what hotel did I stay in for holidays last summer?" or "what were my marks last semester like?". Dream no more, as vector similarity searches and…