Developer & DevOps

Extract Gmail Messages and Store in Vector Database

20 nodes 298 158 Automatic trigger
Download

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. 1.Receive new Gmail messages via trigger
  2. 2.Load and process message content
  3. 3.Split text into logical, processable segments
  4. 4.Convert segments into numerical vectors using embeddings
  5. 5.Batch vectors for efficient processing
  6. 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

Embeddings Document Default Data Loader Text Splitter Gmail Split In Batches Postgres Vector Store

Details

Trigger Automatic trigger
Nodes 20
Apps 7
Views 298
Downloads 158

How to Use

  1. 1.Click "Download Template"
  2. 2.Open your n8n dashboard
  3. 3.Go to Workflows > Import from File
  4. 4.Select downloaded file and configure credentials

Nodes Used (20)

/

Embeddings Ollama

Embeddings Ollama

#1

Default Data Loader

Document Default Data Loader

#2

Recursive Character Text Splitter

Text Splitter Recursive Character Text Splitter

#3

Gmail Trigger

Gmail

#4

Loop Over Items

Split In Batches

#5

Split Out

Split Out

#6

Was manually triggered?

If

#7

Manual Trigger

Manual Trigger

#8

No Operation, do nothing

No Op

#9

Sticky Note

Sticky Note

#10

Sticky Note1

Sticky Note

#11

Sticky Note2

Sticky Note

#12

Set before and after dates

Set

#13

Extract email fields

Set

#14

Sticky Note3

Sticky Note

#15

Store structured

Postgres

#16

Store vectorized

Vector Store P G Vector

#17

Create the table

Postgres

#18

Explode interval into weeks

Code

#19

Get a batch of messages

Gmail

#20