# Gate pgvector indexing by checking consent in Postgres: n8n workflow

> Started by a clock, and works across Postgres and Slack. It puts OpenAI behind a retrieval step, so answers are drawn from documents you supply rather than...

Source: https://millionrounds.com/workflow/gate-pgvector-indexing-by-checking-consent-in-postgres (Millionrounds; every figure on the page links to its filing or article)

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

# Gate pgvector indexing by checking consent in Postgres

Started by a clock, and works across Postgres and Slack. It puts OpenAI behind a retrieval step, so answers are drawn from documents you supply rather than from the model alone. 21 steps, 2 branches, 1 loop or waits: large, and worth reading before you trust it with anything live.

Large Calls a model: OpenAI Retrieval

[Download free](https://millionrounds.com/login?next=%2Fapp%2Fworkflow%2Fgate-pgvector-indexing-by-checking-consent-in-postgres)

**21 steps** Large: read it before trusting it with anything live

**2** Branches: places the flow splits

**1** Loop or waits

**2** Services it connects to

## The flow

Starts it 1 Model 4 Logic 9 Service 7

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

- 1 **Index Run Every Night** Schedule trigger *Starts it*
- 2 **Turn The Text Into Vectors** Embeddings Open Ai *Model*
- 3 **Split Long Records** Text Splitter Recursive Character Text Splitter *Model*
- 4 **Consent Rules** Set *Logic*
- 5 **Add To The Index** Vector Store PGVector *Model*
- 6 **Load The Record Text** Document Default Data Loader *Model*
- 7 **Read The Records Waiting To Be Indexed** Postgres *Service*
- 8 **Mark The Record As Indexed** Postgres *Service*
- 9 **Read The Consent Register** Postgres *Service*
- 10 **Write The Inclusion Manifest** Postgres *Service*
- 11 **Match Each Record To Its Consent** Code *Logic*
- 12 **Embed In Batches** Split In Batches *Logic*
- 13 **Decide If This Record May Be Embedded** Code *Logic*
- 14 **Gather Every Outcome** Merge *Logic*
- 15 **Where Does This Record Go?** Switch *Logic*
- 16 **Summarise This Index Run** Code *Logic*
- 17 **Record Why It Was Refused** Postgres *Service*
- 18 **Hold It For A Human** Postgres *Service*
- 19 **Anything Refused Or Held?** If *Logic*
- 20 **Tell The Data Protection Owner** Slack *Service*
- 21 **Everything Was Eligible** No Op *Logic*

## How it's built

- **Starts on:** A clock
- **Steps:** 21, with 2 branches, 1 loop or waits
- **Size:** Large: read it before trusting it with anything live
- **Connects to:** Postgres, Slack
- **Model:** OpenAI
- **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 Postgres and Slack accounts, and a key for OpenAI. You connect your own accounts after importing it; none are included.

What starts it?

It starts on a clock.

Does it use AI?

Yes. It calls OpenAI. Its answers draw on documents you give it, not on the model alone. Model calls are billed by the provider, not by n8n.

How long does it take to set up?

Take your time. At 21 steps it is large: read it before trusting it with anything live.

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 21 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%2Fgate-pgvector-indexing-by-checking-consent-in-postgres)
- **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.

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

## Workflows like it

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

- [**AI-powered content analysis with Decodo and OpenAI** 21 steps · calls a model · Gmail, Google Docs](https://millionrounds.com/workflow/ai-powered-content-analysis-with-decodo-and-openai)
- [**Create script-to-video avatar videos with HeyGen** 21 steps · calls a model · Gmail, Google Drive](https://millionrounds.com/workflow/create-script-to-video-avatar-videos-with-heygen)
- [**Phase-based blog creation system with Claude and Google Sheets** 21 steps · calls a model · Google Sheets, Slack](https://millionrounds.com/workflow/phase-based-blog-creation-system-with-claude-and-google-shee)
- [**Query PostgreSQL from Slack with Google Sheets and Gemini** 21 steps · calls a model · Google Sheets, Postgres](https://millionrounds.com/workflow/query-postgresql-from-slack-with-google-sheets-and-gemini)
- [**Screen CVs with OpenAI and PostgreSQL** 21 steps · calls a model · Postgres](https://millionrounds.com/workflow/screen-cvs-with-openai-and-postgresql)
- [**Create secure human-in-the-loop approval flows with Postgres** 21 steps · Postgres, Telegram](https://millionrounds.com/workflow/create-secure-human-in-the-loop-approval-flows-with-postgres)
