Templates / Gmail to vector embeddings with PGVector and Ollama

Gmail to vector embeddings with PGVector and Ollama

Ready for 3.0

by Alfonso Corretti ✓ · 3,683 views · created 2025-04-27 · Personal Productivity, AI RAG

Ready for 3.0. This template uses no nodes that n8n 3.0 removes. No removed nodes, versions or helpers found. Static check, last run 2026-10-19.

What 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).

  1. Create the table (Postgres): run a query
  2. Extract email fields (Edit Fields (Set)): sets 9 fields: email_text, email_from, email_to…
  3. Explode interval into weeks (Code): runs custom JavaScript code
  4. Store structured (Postgres): create or update
  5. Split Out: splits a list into separate items
  6. Store vectorized (Postgres PGVector Store): stores documents in the Postgres PGVector Store vector store, with embeddings: Embeddings Ollama; document loader: Default Data Loader
  7. Loop Over Items (Loop Over Items (Split in Batches)): loops over the items in batches
  8. Was manually triggered? (If): checks a condition and branches into true / false
  9. Set before and after dates (Edit Fields (Set)): sets 2 fields: after, before
  10. Get a batch of messages (Gmail): get many

Services it uses

Embeddings OllamaGmailPostgresPostgres PGVector Store

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)

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…

Excerpt from Alfonso Corretti's description on n8n.io.

View the original on n8n.io → Check your own copy

Get the weekly “what broke” email

New templates, newly broken ones, and n8n release changes. One short email a week.

Form not loading? Subscribe here.