# Gmail to vector embeddings with PGVector and Ollama: n8n workflow

> Started by an arriving email, and works across Gmail and Postgres. 16 steps, 1 branch, 1 loop or waits: a working afternoon to understand properly.

Source: https://millionrounds.com/workflow/gmail-to-vector-embeddings-with-pgvector-and-ollama (Millionrounds; every figure on the page links to its filing or article)

[Automation library](https://millionrounds.com/workflows) · [Data collection](https://millionrounds.com/workflows?category=Data+collection#library)

# Gmail to vector embeddings with PGVector and Ollama

Started by an arriving email, and works across Gmail and Postgres. 16 steps, 1 branch, 1 loop or waits: a working afternoon to understand properly.

Medium Retrieval

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fgmail-to-vector-embeddings-with-pgvector-and-ollama)

**16 steps** Medium: a working afternoon

**1** Branch: places the flow splits

**1** Loop or waits

**2** Services it connects to

## The flow

Starts it 2 Model 4 Logic 7 Service 3

The steps in the order they run, from what starts it.

- 1 **Embeddings Ollama** Embeddings Ollama *Model*
- 2 **Recursive Character Text Splitter** Text Splitter Recursive Character Text Splitter *Model*
- 3 **Gmail Trigger** Gmail trigger *Starts it*
- 4 **Manual Trigger** Manual trigger *Starts it*
- 5 **Store vectorized** Vector Store PGVector *Model*
- 6 **Default Data Loader** Document Default Data Loader *Model*
- 7 **Extract email fields** Set *Logic*
- 8 **Create the table** Postgres *Service*
- 9 **Was manually triggered?** If *Logic*
- 10 **Store structured** Postgres *Service*
- 11 **Explode interval into weeks** Code *Logic*
- 12 **No Operation, do nothing** No Op *Logic*
- 13 **Loop Over Items** Split In Batches *Logic*
- 14 **Split Out** Split Out *Logic*
- 15 **Set before and after dates** Set *Logic*
- 16 **Get a batch of messages** Gmail *Service*

## How it's built

- **Starts on:** An arriving email
- **Steps:** 16, with 1 branch, 1 loop or waits
- **Size:** Medium: a working afternoon
- **Connects to:** Gmail, Postgres
- **Model:** None. This is plumbing, not judgement
- **Retrieval:** Answers are drawn from documents you supply, not from the model alone

## Questions

What does it need to run?

An n8n account, plus your own Gmail and Postgres accounts. You connect your own accounts after importing it; none are included.

What starts it?

It starts on an arriving email.

Does it use AI?

No. Every step is fixed logic or a call to a service, so it does the same thing every time.

How long does it take to set up?

Plan an afternoon. 16 steps is enough that you should read each one before running it.

How do I import it?

Copy the workflow, open a new workflow in n8n and paste. The steps appear on the canvas, ready for your own accounts.

**Before you run it**

Nothing here has been tested by us. It is somebody's working automation, read and described from its own steps. Treat the connections it wants as a list of accounts it will touch, and read the 16 steps before you point it at anything that matters.

## Run it in n8n

- **Create your n8n account** Free to start. n8n is where the workflow runs. [Create an n8n account ↗](https://millionrounds.com/n8n)
- **Download the workflow** Free with a Millionrounds account. [Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fgmail-to-vector-embeddings-with-pgvector-and-ollama)
- **Paste it into n8n** Open a new workflow in n8n and paste. Then connect your own accounts.

Stored with the author's traces removed: canvas notes, instance identifiers, saved credential names and any live document they had left behind.

## Connects to

Each opens the other workflows that use it.

[Gmail](https://millionrounds.com/workflows?service=Gmail#library)[Postgres](https://millionrounds.com/workflows?service=Postgres#library)

## Workflows like it

Also data collection, with the same services where possible, closest in size first.

- [**Capture and reply to cleaning enquiries with Google Sheets** 16 steps · Gmail, Google Sheets](https://millionrounds.com/workflow/capture-and-reply-to-cleaning-enquiries-with-google-sheets)
- [**Capture cleaning enquiries from WordPress forms** 16 steps · Gmail, Google Sheets](https://millionrounds.com/workflow/capture-cleaning-enquiries-from-wordpress-forms)
- [**Trading journal & performance tracker with Airtable and Gmail** 16 steps · Airtable, Gmail](https://millionrounds.com/workflow/trading-journal-and-performance-tracker-with-airtable-and-gm)
- [**YouTube trend detector with Gmail and Google Sheets** 16 steps · Gmail, Google Sheets](https://millionrounds.com/workflow/youtube-trend-detector-with-gmail-and-google-sheets)
- [**Clean and deduplicate supplier master data with Google Sheets** 16 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/clean-and-deduplicate-supplier-master-data-with-google-sheet)
- [**Compare gold and equity performance with Google Sheets** 16 steps · calls a model · Gmail, Google Sheets](https://millionrounds.com/workflow/compare-gold-and-equity-performance-with-google-sheets)
