← All N8N workflows
Data & databasesCodeDocument Default Data LoaderEmbeddings OllamaGmailGmail Trigger

Gmail to Vector Embeddings with PGVector and Ollama

Configured with Document Default Data Loader, Embeddings Ollama, Gmail, Gmail Trigger, and additional nodes. Review the connections and setup before adapting this template.

Workflow preview
AI & modelsEmbeddings OllamaEmbeddings OllamaFiles / mediaDefault Data LoaderDocument Default Data Lo…TransformRecursive CharacterText SplitterText Splitter Recursive …TriggerGmail TriggerGmail TriggerRoutingLoop Over ItemsLoop Over ItemsTransformSplit OutSplit OutRoutingWas manually triggered?IfTriggerManual TriggerManual TriggerRoutingNo Operation, donothingNo OpTransformSet before and afterdatesEdit FieldsTransformExtract email fieldsEdit FieldsData storeStore structuredPostgresData storeStore vectorizedVector Store PgvectorData storeCreate the tablePostgresCodeExplode interval intoweeksCodeMessagingGet a batch of messagesGmail

Node categories in this workflow

  • AI & models
  • Files / media
  • Transform
  • Trigger
  • Routing
  • Data store
  • Code
  • Messaging

Icons describe general node roles, inferred from node types. Inspect the parameters for the configured action.

Drag to pan; use + and − to zoom. Reconstructed from the exported node positions; nothing runs here. Dashed lines represent non-main connections. Full node names and notes appear below.

How it works

The exported workflow contains the following configured nodes. Their connections are shown above; inspect the JSON for the complete logic, expressions, and external actions.

Workflow node names, types, and operations
NodeCategoryTypeOperation
Embeddings OllamaAI & modelsEmbeddings OllamaSee node parameters
Default Data LoaderFiles / mediaDocument Default Data LoaderSee node parameters
Recursive Character Text SplitterTransformText Splitter Recursive Character Text SplitterSee node parameters
Gmail TriggerTriggerGmail TriggerSee node parameters
Loop Over ItemsRoutingLoop Over ItemsSee node parameters
Split OutTransformSplit OutSee node parameters
Was manually triggered?RoutingIfSee node parameters
Manual TriggerTriggerManual TriggerSee node parameters
No Operation, do nothingRoutingNo OpSee node parameters
Set before and after datesTransformEdit FieldsSee node parameters
Extract email fieldsTransformEdit FieldsSee node parameters
Store structuredData storePostgresupsert
Store vectorizedData storeVector Store PgvectorSee node parameters
Create the tableData storePostgresexecuteQuery
Explode interval into weeksCodeCodeSee node parameters
Get a batch of messagesMessagingGmailgetAll

Setup

  1. Download the JSON and import it into an isolated n8n instance. Leave the workflow inactive.
  2. Connect your own credentials through n8n’s credential store. Replace REPLACE_WITH_* values with your resource identifiers.
  3. Inspect API destinations, Code nodes, database queries, file paths, and outbound actions.
  4. Run with synthetic data and harmless destinations. Enable triggers only after checking the actual outputs.

Requirements

An n8n instance with the listed node types and compatible versions. Service-connected workflows may require accounts, credentials, or paid APIs.

Credential types declared in the source

None declared. HTTP requests and Code nodes may still need configuration.

Workflow notes

Bulk e-mail import

Bulk e-mail import

Press the Test workflow button to run this once, and bulk import of all your e-mail

IMPORTANT

Specify your Gmail account creation date by editing the code node

Edit this ⬇️

Edit this ⬇️

And specify your Gmail account creation date

Activate the workflow

Activate the workflow

And this trigger will check for new mail, every minute

Magic here 🪄

Magic here 🪄

(not really, just statistics)

E-mail is stored in a emails_metadata structured table, and also fed to the nomic-embed-text model to be stored in a emails_embeddings table as vector embeddings so similarity searches are possible.

The email_id field can be used to make the relation between the structured records and the vector embeddings, as it's stored in their metadata as emails_metadata.id. This is also the case for thread_id.

Gmail to Vector Embeddings with PGVector and Ollama

Gmail to Vector Embeddings with PGVector and Ollama

Purpose and structure

This folder contains the Gmail to Vector Embeddings with PGVector and Ollama workflow. Its executable nodes use code, documentDefaultDataLoader, embeddingsOllama, gmail, gmailTrigger, if, manualTrigger, noOp, postgres, set, splitInBatches, splitOut, textSplitterRecursiveCharacterTextSplitter, vectorStorePGVector. The table and connection map below are derived from the JSON, not an inferred guarantee of behavior.

Setup

Import inactive. Configure your own credentials and replace REPLACE_WITH_* values. Review external destinations and Code nodes before running.

Entry points

Gmail Trigger, Manual Trigger

Verification

Sanitized source candidate; not runtime-tested. This overview is generated from node metadata. Read the folder README for the connection map, credential types, and license.

Attribution

https://github.com/Zie619/n8n-workflows/blob/94007c1445d9258a7da116646b79473e7c7c3282/workflows/Splitout/1783_Splitout_Postgres_Automation_Triggered.json MIT; preserve source notices.

More in Data & databases