n8n

How to Automate Google Drive Knowledge Search?

Turn your Google Drive folder into a smart knowledge base. Files are read every night, converted into vector data, and saved to a database for fast search. Great for teams that need quick answers from PDFs, text, and JSON.

Two triggers control the run, a manual test and a daily schedule at 3 AM. The flow lists a source folder in Google Drive, loops through each file, downloads it, and routes it by type. PDFs, text, and JSON are parsed with the right extractor. The text is split into small chunks with 50 character overlap, turned into embeddings with OpenAI text embedding 3 small, and inserted into a PostgreSQL table with PGVector. After indexing, the file is moved to a processed folder so it will not be handled again.

Setup needs Google Drive access, an OpenAI API key, and a PostgreSQL database with the PGVector extension. Expect faster search and less manual sorting as new files are indexed while you sleep. Useful for internal knowledge search, policy libraries, playbooks, and project docs.

What are the key features?

  • Manual and schedule triggers support test runs and unattended nightly runs at 3 AM
  • Google Drive folder search fetches all files and loops through them in batches
  • File type switch routes PDFs text and JSON to the right extractor for accurate parsing
  • Extract from PDF Text and JSON nodes pull clean text ready for embedding
  • Recursive character text splitter uses 50 character overlap to keep context across chunks
  • OpenAI embeddings use the text embedding 3 small model for cost effective vectors
  • Postgres PGVector store writes vectors to table n8n_vectors_wfs and collection n8n_wfs
  • Move File shifts the original file to a processed folder in Google Drive

What are the benefits?

  • Reduce manual sorting and copy paste from 60 minutes a day to under 5 minutes
  • Automate nightly intake so 80 percent of uploads are processed with no human touch
  • Eliminate up to 90 percent of copy paste errors by using structured extractors
  • Handle up to 10 times more files with batch processing and chunked indexing
  • Connect Google Drive OpenAI and PostgreSQL in one seamless pipeline
  • Avoid duplicates by moving processed files to a separate folder

How do you set it up?

  1. Import the template into n8n: Create a new workflow in n8n > Click the three dots menu > Select 'Import from File' > Choose the downloaded JSON file.
  2. You'll need accounts with Google Drive, OpenAI and PostgreSQL. See the Tools Required section above for links to create accounts with these services.
  3. In n8n Cloud open the Search Folder node, the Download File node, and the Move File node. For each one, in the Credential to connect with field click Create new credential and follow the on screen steps to connect your Google Drive account.
  4. Get your OpenAI API key from the OpenAI account dashboard. In the Embeddings OpenAI node click Create new credential, choose API Key, paste your key, and save. Keep the model set to text embedding 3 small.
  5. Prepare your PostgreSQL database with the PGVector extension enabled. In the Postgres PGVector Store node click Create new credential and enter host, port, database, user, password, and SSL if required. Use or confirm the table name n8n_vectors_wfs and the collection name n8n_wfs.
  6. Set the source folder in the Search Folder node by choosing the correct Google Drive folder ID. Set the processed folder ID in the Move File node so indexed files are moved out of the intake folder.
  7. Open the Switch node and confirm the rules detect PDFs text files and JSON files. If your files use other MIME types or extensions, add conditions to match them.
  8. Review the Recursive Character Text Splitter settings. Keep the 50 character overlap, and adjust chunk size if your documents are very long or very short.
  9. Open the Schedule Trigger node and set the time that fits your team. The current rule runs at 3 AM.
  10. Run a manual test: click Execute Workflow. Confirm new records appear in your PostgreSQL table and the files move to the processed folder in Google Drive.
  11. If you see errors about permissions, check Google Drive sharing and PostgreSQL user rights. If embeddings fail, verify the OpenAI key and model name. If no rows are inserted, confirm the Switch rules match your file types.

Tools Required

$24 / mo or $20 / mo billed annually to use n8n in the cloud. However, the local or self-hosted n8n Community Edition is free.

Google Drive

Sign up

Drive API: $0 (no additional cost; quota-limited)

OpenAI

Sign up

Pay-as-you-go: GPT-5 at $1.25 per 1M input tokens and $10 per 1M output tokens

PostgreSQL

Sign up

Free: $0 (open-source PostgreSQL License; self-hosted)

Credits:
Author: AlexK1919. License: Creative Commons Attribution ShareAlike 4.0 International. License details

Similar Templates

Join Futurise to access 1,200+ automation templates

Get instant access to ready-made automation workflows for n8n, Make.com, AI agents, and more. Download, customise, and deploy in minutes.