Skip to content

How to Turn Google Drive Files into an AI-Ready Knowledge Base

Arrow down icon
How to Turn Google Drive Files into an AI-Ready Knowledge Base
How to Turn Google Drive Files into an AI-Ready Knowledge Base

Most enterprise knowledge is not in databases. It lives in documents: PDFs, reports, invoices, and files stored across systems like Google Drive.

The challenge is not access, it is usability. These files are hard to search, harder to connect, and almost impossible to use in real-time AI workflows.

This guide shows how to solve that using AISquared’s UNIFI platform. You will connect a folder of unstructured files, process them into smaller chunks, generate embeddings, and store the results in a structured format that can be queried and used by AI agents.

Overview

This workflow demonstrates how to connect an unstructured Google Drive folder to UNIFI, process the files through a knowledge base model with chunking and embeddings, and sync the resulting data into a PostgreSQL destination table.

Use case: Invoice PDFs stored in Google Drive are parsed, chunked, embedded, and stored in a Postgres table — enabling semantic search and downstream AI applications via the UNIFI platform.

Step 1 — Configure the Google Drive Source

1.1  Prerequisites

Before connecting UNIFI to Google Drive, you need a GCP Service Account with Drive API access and a JSON key file. Follow the steps below to obtain it.

  1. Go to console.cloud.google.com → IAM & Admin → Service Accounts
  2. Select or create a service account with Google Drive API access enabled
  3. Click the Keys tab → Add Key → Create new key → select JSON
  4. Download the .json file — it contains all credentials needed below
  5. Share your target Drive folder with the service account’s client_email

1.2  Source Configuration Fields

In UNIFI: Sources → New Source → GoogleDrive → Data Format Type: Documents & Files (Unstructured)

All values except type and universe_domain come directly from the downloaded JSON key file. Copy-paste each field verbatim.

Step 2 — Configure the PostgreSQL Destination

2.1  Destination Configuration

In UNIFI: Destinations → New Destination → PostgreSQL → Data Format Type: Tables & Records containing Vector fields

You will need public postgresql database credentials

2.2  Destination Table Schema

Create the following table in your PostgreSQL database before running the sync. UNIFI will map its output fields into these columns.

ColumnTypeDefaultConstraints
idintegersequence (auto)PRIMARY KEY
texttext
created_attimestampnow()NOT NULL
updated_attimestampnow()NOT NULL
filenamevarchar(255)
filetypevarchar(50)
element_idtext

Step 3 — Create the Knowledge Base Model

In UNIFI: Models → New Model → select the Google Drive source created in Step 1

3.1  Chunking Parameters

Chunking controls how documents are split into processable segments before embedding.

ParameterValueDescription
Chunk Size1000Number of tokens or characters per chunk
Chunk Overlap250Overlapping tokens between consecutive chunks — preserves context across boundaries

3.2  Embedding Configuration

Embeddings convert text chunks into vector representations for semantic search and retrieval.

ParameterValueNotes
Embedding Provideropen_aiOpenAI embeddings API
Embedding Modeltext-embedding-3-smallCost-efficient model; swap for text-embedding-3-large for higher accuracy
API Key(OpenAI API key)Obtain from platform.openai.com → API Keys
After configuring chunking and embedding, click Continue to finalize the model and give it a name. This model will be referenced in Step 4 when creating the sync.

Step 4 — Create and Run the Sync

In UNIFI: Syncs → New Sync → select your model and destination

Follow these sub-steps in order to configure and execute the sync:

  1. Select the model created in Step 3 (e.g. drive invoices to knowledge base sync model) as the sync source
  2. Select the PostgreSQL destination configured in Step 2 as the sync destination
  3. In the sync configuration, locate the Stream Name dropdown — select synthetic_invoices (the target table)
  4. Set Sync Mode to Incremental to process only new or changed files on each run
  5. Click Refresh to load the current schema from your PostgreSQL destination — this populates the available column names for field mapping
  6. Map each GoogleDrive output field to the corresponding PostgreSQL column using the field mapping interface (see table below)
  7. Click Save Changes to persist the sync configuration
  8. Click Run Now to execute the first sync run — monitor progress under the Sync Runs tab

4.1  Field Mapping Reference

GoogleDrive Field (Source)PostgreSQL Column (Destination)
texttext
filenamefilename
filetypefiletype
element_idelement_id
created_datecreated_at
modified_dateupdated_at
Note: The id column is auto-populated by the Postgres sequence and does not need to be mapped. The text field carries the extracted and chunked document content.

Quick Reference — Workflow Summary

StepActionKey Detail
1Create Google Drive SourceData Format: Unstructured; credentials from GCP JSON key; share folder with client_email
2Create PostgreSQL DestinationData Format: Vector fields; target table: synthetic_invoices in public schema
3Create Knowledge Base ModelChunk: 1000/250; Provider: OpenAI; Model: text-embedding-3-small
4Create & Run SyncMap 6 fields; Incremental mode; Refresh schema before mapping; Run Now

Measure Your AI Readiness

See where your organization stands today across data, security, governance, workflows, adoption, and improvement.