Check consent before pgvector indexing in Postgres with OpenAI and Slack
Ready for 3.0What this workflow does
This AI workflow has 21 nodes and runs on a schedule (every day at 02:00). Along the way it connects Postgres, Postgres PGVector Store, Embeddings OpenAI and Slack.
How it runs
Trigger: On a schedule (every day at 02:00).
- Consent Rules (Edit Fields (Set)): sets 5 fields: required_purpose, documents_query, register_query…
- Read The Records Waiting To Be Indexed (Postgres): run a query
- Read The Consent Register (Postgres): run a query
- Match Each Record To Its Consent (Code): runs custom JavaScript code
- Decide If This Record May Be Embedded (Code): runs custom JavaScript code
- Where Does This Record Go? (Switch): routes items into 3 branches
- Embed In Batches (Loop Over Items (Split in Batches)): loops over the items in batches
- Record Why It Was Refused (Postgres): run a query
- Hold It For A Human (Postgres): run a query
- Gather Every Outcome (Merge): merges the data from its input branches
…plus 6 more steps. See the full node list below.
Services it uses
Other OpenAI + Slack templates (979) · Other OpenAI + PostgreSQL templates (191) · Other PostgreSQL + Slack templates (109)
Before you upgrade to n8n 3.0
Nothing in this workflow is removed in n8n 3.0, so it should import and run after the upgrade.
- Code node: the task timeout drops from 300s to 60s. Test with a realistic data volume.
Nodes used (14)
- Schedule Trigger
n8n-nodes-base.scheduleTrigger - Edit Fields (Set)
n8n-nodes-base.set - Postgres
n8n-nodes-base.postgres - Code
n8n-nodes-base.code - Switch
n8n-nodes-base.switch - Loop Over Items (Split in Batches)
n8n-nodes-base.splitInBatches - Postgres PGVector Store
@n8n/n8n-nodes-langchain.vectorStorePGVector - Embeddings OpenAI
@n8n/n8n-nodes-langchain.embeddingsOpenAi - Default Data Loader
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - Recursive Character Text Splitter
@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter - Merge
n8n-nodes-base.merge - If
n8n-nodes-base.if - Slack
n8n-nodes-base.slack - No Operation, do nothing
n8n-nodes-base.noOp
From the author
Quick overview This workflow runs nightly to read unindexed knowledge base records from Postgres, checks each record against a Postgres consent register, and only embeds eligible text with OpenAI into a pgvector index while logging decisions to a manifest and…