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.
- Go to console.cloud.google.com → IAM & Admin → Service Accounts
- Select or create a service account with Google Drive API access enabled
- Click the Keys tab → Add Key → Create new key → select JSON
- Download the .json file — it contains all credentials needed below
- 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.
| Column | Type | Default | Constraints |
|---|---|---|---|
| id | integer | sequence (auto) | PRIMARY KEY |
| text | text | — | |
| created_at | timestamp | now() | NOT NULL |
| updated_at | timestamp | now() | NOT NULL |
| filename | varchar(255) | — | |
| filetype | varchar(50) | — | |
| element_id | text | — |
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.
| Parameter | Value | Description |
|---|---|---|
| Chunk Size | 1000 | Number of tokens or characters per chunk |
| Chunk Overlap | 250 | Overlapping tokens between consecutive chunks — preserves context across boundaries |
3.2 Embedding Configuration
Embeddings convert text chunks into vector representations for semantic search and retrieval.
| Parameter | Value | Notes |
|---|---|---|
| Embedding Provider | open_ai | OpenAI embeddings API |
| Embedding Model | text-embedding-3-small | Cost-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:
- Select the model created in Step 3 (e.g. drive invoices to knowledge base sync model) as the sync source
- Select the PostgreSQL destination configured in Step 2 as the sync destination
- In the sync configuration, locate the Stream Name dropdown — select synthetic_invoices (the target table)
- Set Sync Mode to Incremental to process only new or changed files on each run
- Click Refresh to load the current schema from your PostgreSQL destination — this populates the available column names for field mapping
- Map each GoogleDrive output field to the corresponding PostgreSQL column using the field mapping interface (see table below)
- Click Save Changes to persist the sync configuration
- 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) |
|---|---|---|
| text | → | text |
| filename | → | filename |
| filetype | → | filetype |
| element_id | → | element_id |
| created_date | → | created_at |
| modified_date | → | updated_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
| Step | Action | Key Detail |
|---|---|---|
| 1 | Create Google Drive Source | Data Format: Unstructured; credentials from GCP JSON key; share folder with client_email |
| 2 | Create PostgreSQL Destination | Data Format: Vector fields; target table: synthetic_invoices in public schema |
| 3 | Create Knowledge Base Model | Chunk: 1000/250; Provider: OpenAI; Model: text-embedding-3-small |
| 4 | Create & Run Sync | Map 6 fields; Incremental mode; Refresh schema before mapping; Run Now |