Optimize Document Handling with n8n Vector DB Loader from Google Drive

This workflow automates loading, splitting, embedding, and storing Google Drive documents into a Postgres PGVector database. It solves time-wasting manual document processing with efficient vector search prep using n8n.
manualTrigger
googleDrive
switch
+6
Workflow Identifier: 1944
NODES in Use: manualTrigger, googleDrive, switch, extractFromFile, splitInBatches, textSplitterRecursiveCharacterTextSplitter, documentDefaultDataLoader, embeddingsOpenAi, vectorStorePGVector

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

Visit through Desktop for Best experience

What this workflow does

This workflow automatically loads files from a Google Drive folder, extracts their text content, splits that text into small parts, creates embeddings with OpenAI, and saves these embeddings into a Postgres database using PGVector. It stops manual work and mistakes. It helps users find information fast from many documents in Google Drive.

The main problem solved is saving time and avoiding errors in handling different file types and large text for vector search databases.


Who should use this workflow

This is for anyone who has many documents like PDFs, text files, or JSON files in Google Drive and wants them turned automatically into searchable vectors. Users who want to connect these vectors with a Postgres PGVector database will find it useful.

If you want to stop manually downloading and processing files but still want fast, reliable search over document content, this workflow fits well.


Tools and services used

  • Google Drive API: To list and download files from a specific Drive folder.
  • n8n nodes: Including Schedule Trigger, Search Folder, SplitInBatches, Download File, Switch, text and JSON Extract nodes, Recursive Character Text Splitter, Default Data Loader, Embeddings OpenAI, Postgres PGVector Store, and Move File.
  • OpenAI API: For generating vector embeddings using the model text-embedding-3-small.
  • Postgres Database with PGVector extension: For storing vector embeddings and enabling similarity searches.

How the workflow works (Input → Process → Output)

Inputs

  • Files located in a selected Google Drive folder, which can be PDFs, plain text files, or JSON files.
  • OpenAI API Key to generate embeddings.
  • Postgres database credentials with PGVector enabled.

Processing Steps

  • The Schedule Trigger runs the workflow on a set time or manually.
  • Search Folder node lists all files in the chosen Drive folder.
  • SplitInBatches node processes files one by one to manage load.
  • Download File node fetches each file content using its ID.
  • Switch node checks the file type by MIME type (PDF, text, or JSON).
  • Depending on the type, the workflow uses specific extraction nodes to get readable text:
    • PDF text extractor for PDFs.
    • Plain text extractor for text files.
    • JSON parser for JSON files.
  • Recursive Character Text Splitter breaks long texts into small parts with 50 characters overlapping for better embedding quality.
  • Default Data Loader prepares the text chunks for embedding.
  • Embeddings OpenAI generates vector embeddings using the text-embedding-3-small model.
  • Postgres PGVector Store saves these vectors in the table n8n_vectors_wfs inside the collection n8n_wfs.
  • Move File moves processed files to a “vectorized” folder in Google Drive to keep the source clean.

Outputs

  • Vectors stored in a Postgres database ready for fast similarity search.
  • Processed files organized in the “vectorized” folder.
  • Logs and status updates inside n8n for each workflow run.

Beginner step-by-step: How to build this workflow in n8n

Import the workflow

  1. Download the workflow file from this page using the Download button.
  2. Open n8n editor where you want to use this workflow.
  3. Click “Import from File” and upload the downloaded workflow JSON file.

Set up credentials and IDs

  1. Add or update Google Drive OAuth2 credentials in n8n.
  2. Set OpenAI API Key in the Embeddings OpenAI node credentials.
  3. Update Postgres database credentials in the Postgres PGVector Store node.
  4. Replace the Google Drive folder IDs for the source and target folders if needed (for Search Folder and Move File nodes).

Test the workflow

  1. Run the workflow manually once to check it downloads files, extracts content, generates embeddings, stores vectors, and moves files correctly.
  2. Review logs in n8n to catch any errors.

Activate for production

  1. Switch the workflow to active mode to run on schedule.
  2. Monitor executions regularly.
  3. If self-hosting n8n, consider checking self-host n8n for server setup advice.

Common errors and how to fix them

  • No files found: Check Google Drive folder ID. Make sure OAuth2 credentials have enough permissions. Re-authenticate if needed.
  • Embedding API errors: Confirm OpenAI API Key is valid and not expired. Update keys if needed.
  • Files not moving: Verify the target folder ID and that your Google Drive account has edit rights.
  • PGVector errors: Ensure Postgres has PGVector extension installed and the connection details are correct.

Customization ideas

  • Change the Recursive Character Text Splitter overlap size to tune embedding context.
  • Add MIME types in the Switch node to support more file types (like Word documents).
  • Modify the Move File node folder to send processed files to a different destination.
  • Adjust batch size in the SplitInBatches node to control processing speed.
  • Try other OpenAI embedding models like text-embedding-3-large for better quality embeddings.

Summary of results

✓ Saves time by automating file downloads and content extraction.
✓ Reduces errors by processing files automatically based on type.
✓ Creates quality embeddings for fast search in Postgres PGVector.
✓ Organizes files by moving processed ones to a separate folder.
→ Enables faster and more accurate data retrieval from many documents.
→ Makes document handling easier and consistent across file types.


Frequently Asked Questions

Not by default. The workflow only supports PDF, plain text, and JSON files. The Switch node would need more MIME type cases added to process Word files.
Embedding generation will fail. The Embeddings OpenAI node needs a valid, active API key to work properly.
Change the target folder ID in the Move File node to move processed files to any folder you want in Google Drive.
The SplitInBatches node processes files one by one or in small batches to manage load and API limits effectively.

Promoted by BULDRR AI

Related Workflows

Automate Viral UGC Video Creation Using n8n + Degaus (Beginner-Friendly Guide)

Learn how to automate viral UGC video creation using n8n, AI prompts, and Degaus. This beginner-friendly guide shows how to import, configure, and run the workflow without technical complexity.
Form Trigger
Google Sheets
Gmail
+37
Free

AI SEO Blog Writer Automation Workflows in n8n

A complete beginner guide to building an AI SEO blog writer automation using n8n.
AI Agent
Google Sheets
httpRequest
+5
Free

Automate CrowdStrike Alerts with VirusTotal, Jira & Slack

This workflow automates processing of CrowdStrike detections by enriching threat data via VirusTotal, creating Jira tickets for incident tracking, and notifying teams on Slack for quick response. Save hours daily by transforming complex threat data into actionable alerts effortlessly.
scheduleTrigger
httpRequest
jira
+5
Free

Automate Telegram Invoices to Notion with AI Summaries & Reports

Save hours on financial tracking by automating invoice extraction from Telegram photos to Notion using Google Gemini AI. This workflow extracts data, records transactions, and generates detailed spending reports with charts sent on schedule via Telegram.
lmChatGoogleGemini
telegramTrigger
notion
+9
Free

Automate Email Replies with n8n and AI-Powered Summarization

Save hours managing your inbox with this n8n workflow that uses IMAP email triggers, AI summarization, and vector search to draft concise replies requiring minimal review. Automate business email processing efficiently with AI guidance and Gmail integration.
emailReadImap
vectorStoreQdrant
emailSend
+12
Free

Automate Email Campaigns Using n8n with Gmail & Google Sheets

This n8n workflow automates personalized email outreach campaigns by integrating Gmail and Google Sheets, saving hours of manual follow-up work and reducing errors in email sequences. It ensures timely follow-ups based on previous email interactions, optimizing communication efficiency.
googleSheets
gmail
code
+5
Free