Gmail to PGVector with Ollama

October 9, 2025

Aladuddin Aladin

This workflow automates the process of fetching emails from Gmail, extracting their content and metadata, and storing both structured data and vector embeddings in PostgreSQL with PGVector. By embedding email text using the Ollama nomic-embed-text model, it enables advanced similarity searches and retrieval-augmented generation (RAG) use cases.

It supports both bulk historical imports (based on your Gmail account creation date) and real-time synchronization with new incoming emails. Perfect for building AI-powered knowledge bases, semantic search systems, or intelligent email assistants.

✨ Key Features

  • Gmail Integration: Connects directly to Gmail to fetch emails with full metadata and attachments.
  • Bulk Import Support: Import all historical emails since account creation using a batch process.
  • Real-time Sync: Gmail Trigger checks for new emails every minute.
  • Metadata Storage: Saves structured data (sender, recipient, subject, CC, date, attachments, thread ID) in a emails_metadata table.
  • Text Vectorization: Uses Ollama embeddings (nomic-embed-text) to convert email text into high-dimensional vectors.
  • PGVector Storage: Stores embeddings in an emails_embeddings table for similarity search.
  • Flexible Chunking: Splits long email texts into manageable chunks for better embedding accuracy.
  • Search Ready: Enables semantic queries, clustering, and retrieval use cases over your email corpus.

About the author

Alauddin Aladin is an AI Automation expert helping businesses streamline operations, boost productivity, and scale effortlessly using tools like Make.com and n8n. With over a decade of experience in digital systems and automation strategy, Alauddin empowers entrepreneurs to save time and grow smarter through intelligent workflows and AI-driven solutions.

Leave a Comment