AutomationFlowsAI & RAG › Google Drive to PGVector Embeddings

Google Drive to PGVector Embeddings

Original n8n title: 📥 Transform Google Drive Documents Into Vector Embeddings

ByAlex Kim @alexk1919 on n8n.io

Automatically convert documents from Google Drive into vector embeddings using OpenAI, LangChain, and PGVector — fully automated through n8n.

Event trigger★★★★☆ complexityAI-powered15 nodesDocument Default Data LoaderText Splitter Recursive Character Text SplitterVector Store PgvectorGoogle DriveOpenAI Embeddings
AI & RAG Trigger: Event Nodes: 15 Complexity: ★★★★☆ AI nodes: yes Added:
Google Drive to PGVector Embeddings — n8n workflow card showing Document Default Data Loader, Text Splitter Recursive Character Text Splitter, Vector Store Pgvector integration

This workflow corresponds to n8n.io template #3647 — we link there as the canonical source.

This workflow follows the Documentdefaultdataloader → OpenAI Embeddings recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "WceMkVib0VLlF1BZ",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Vector DB Loader from Google Drive",
  "tags": [
    {
      "id": "6rb8rVhKZj4t0Kne",
      "name": "Current",
      "createdAt": "2025-02-04T18:13:17.427Z",
      "updatedAt": "2025-02-04T18:13:17.427Z"
    }
  ],
  "nodes": [
    {
      "id": "6652e41a-d14a-4e17-9dcd-34df114d219a",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1240,
        1100
      ],
      "parameters": {
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "filename",
                "value": "={{ $('Download File').item.json.name }}"
              },
              {
                "name": "id",
                "value": "={{ $('Download File').item.json.id }}"
              },
              {
                "name": "gold",
                "value": "false"
              }
            ]
          }
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8ae38b72-52fd-46bc-ab47-50bebe5ac4ee",
      "name": "Recursive Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1320,
        1300
      ],
      "parameters": {
        "options": {},
        "chunkOverlap": 50
      },
      "typeVersion": 1
    },
    {
      "id": "e6bed8bc-f629-41fd-aa6e-9158b1cbc323",
      "name": "Postgres PGVector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStorePGVector",
      "position": [
        1140,
        880
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "collection": {
            "values": {
              "useCollection": true,
              "collectionName": "workflow_generator",
              "collectionTableName": "embedding_collections"
            }
          }
        },
        "tableName": "collection_vectors"
      },
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "96fbc1f3-920d-44c9-9314-742efa3a698a",
      "name": "When clicking \u2018Test workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -500,
        740
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "4cd7a934-04cc-47b5-a771-db554680ba77",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        100,
        740
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "778593d8-fe1c-4eb9-865a-e6ce9ed5f900",
      "name": "Move File",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        1700,
        1280
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Loop Over Items').item.json.id }}"
        },
        "driveId": {
          "__rl": true,
          "mode": "list",
          "value": "My Drive"
        },
        "folderId": {
          "__rl": true,
          "mode": "list",
          "value": "1Re6vg-PZxBoUU6sTRDbGs-77bAJ40u8F",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1Re6vg-PZxBoUU6sTRDbGs-77bAJ40u8F",
          "cachedResultName": "vectorized"
        },
        "operation": "move"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "3a6584f5-ed86-4900-9177-40ffe82d0ad3",
      "name": "Download File",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        320,
        680
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "e1931ab6-4391-46c3-9d7d-22cbfbf90327",
      "name": "Search Folder",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -280,
        740
      ],
      "parameters": {
        "filter": {
          "folderId": {
            "__rl": true,
            "mode": "list",
            "value": "1mBHrP8UzUnfn3dj_3QS1r0XhQQyVPAGX",
            "cachedResultUrl": "https://drive.google.com/drive/folders/1mBHrP8UzUnfn3dj_3QS1r0XhQQyVPAGX",
            "cachedResultName": "n8n Workflow JSON Files"
          },
          "whatToSearch": "files"
        },
        "options": {
          "fields": [
            "name",
            "id"
          ]
        },
        "resource": "fileFolder",
        "returnAll": true
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "95134ab4-806f-4c47-96a6-e261b3176ebf",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -500,
        940
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 4
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0fe604ed-e886-4aa3-856f-c46fb79ce0de",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -520,
        1180
      ],
      "parameters": {
        "color": 7,
        "width": 380,
        "height": 240,
        "content": "## Creative Commons License\n*License*: **Creative Commons Attribution-ShareAlike 4.0 International** (CC BY-SA 4.0)\n\n*Author*: **AlexK1919**\nYou are free to use, adapt, and share this workflow\u2014even commercially\u2014under the terms of this license.\n\nFull license details: https://creativecommons.org/licenses/by-sa/4.0/"
      },
      "typeVersion": 1
    },
    {
      "id": "f8055452-b487-46c7-92fe-14b3c88d193f",
      "name": "Switch",
      "type": "n8n-nodes-base.switch",
      "position": [
        500,
        680
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "pdf",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "7b4e792b-ab6d-4b9b-88a1-d8e51bea6853",
                    "operator": {
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$binary[\"data\"].mimeType}}",
                    "rightValue": "application/pdf"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "text",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "09b7d7c5-5353-4719-b4e2-072e4da39948",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$binary[\"data\"].mimeType}}",
                    "rightValue": "text/plain"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "json",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "strict"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "d2763a45-a592-47c8-868f-59dfcd17a71c",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{$binary[\"data\"].mimeType}}",
                    "rightValue": "application/json"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {}
      },
      "typeVersion": 3.2
    },
    {
      "id": "c704f48e-a1f5-4539-bde2-545862d21bc6",
      "name": "Extract from PDF",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        780,
        480
      ],
      "parameters": {
        "options": {},
        "operation": "pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "63b3a751-5726-4821-8379-72af15226584",
      "name": "Extract from Text",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        780,
        680
      ],
      "parameters": {
        "options": {},
        "operation": "text"
      },
      "typeVersion": 1
    },
    {
      "id": "44a5980a-17aa-4a09-8040-a7d9804c7998",
      "name": "Extract from JSON",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        780,
        880
      ],
      "parameters": {
        "options": {},
        "operation": "fromJson"
      },
      "typeVersion": 1
    },
    {
      "id": "435f8016-43d1-4a2c-b507-50480867946b",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1060,
        1100
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "active": true,
  "settings": {
    "timezone": "America/Los_Angeles",
    "callerPolicy": "workflowsFromSameOwner",
    "errorWorkflow": "lYgdNzdEapw2W8gK",
    "executionOrder": "v1"
  },
  "versionId": "2d091814-9c7a-47ad-9339-e52089797c75",
  "connections": {
    "Switch": {
      "main": [
        [
          {
            "node": "Extract from PDF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract from Text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Extract from JSON",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Move File": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Download File": {
      "main": [
        [
          {
            "node": "Switch",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search Folder": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Download File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from PDF": {
      "main": [
        [
          {
            "node": "Postgres PGVector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Search Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Postgres PGVector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Extract from JSON": {
      "main": [
        [
          {
            "node": "Postgres PGVector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract from Text": {
      "main": [
        [
          {
            "node": "Postgres PGVector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Postgres PGVector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Postgres PGVector Store": {
      "main": [
        [
          {
            "node": "Move File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Test workflow\u2019": {
      "main": [
        [
          {
            "node": "Search Folder",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Automatically convert documents from Google Drive into vector embeddings using OpenAI, LangChain, and PGVector — fully automated through n8n.

Source: https://n8n.io/workflows/3647/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

RAG AI Agent Template V5. Uses lmChatOpenAi, documentDefaultDataLoader, embeddingsOpenAi, googleDrive. Event-driven trigger; 56 nodes.

OpenAI Chat, Document Default Data Loader, OpenAI Embeddings +12
AI & RAG

This powerful AI automation add-on upgrades your Telegram Bot Starter Template by integrating a fully functional AI chatbot and a context-aware AI agent that answers user questions using your internal

OpenAI Chat, Document Default Data Loader, OpenAI Embeddings +10
AI & RAG

Contextual Retrieval. Uses lmChatOpenAi, documentDefaultDataLoader, embeddingsOpenAi, googleDrive. Event-driven trigger; 24 nodes.

OpenAI Chat, Document Default Data Loader, OpenAI Embeddings +9
AI & RAG

Vector DB Loader from Google Drive. Uses documentDefaultDataLoader, textSplitterRecursiveCharacterTextSplitter, embeddingsOpenAi, vectorStorePGVector. Event-driven trigger; 15 nodes.

Document Default Data Loader, Text Splitter Recursive Character Text Splitter, OpenAI Embeddings +2
AI & RAG

Your AI workforce is ready. Are you?

Google Sheets Tool, Mcp Trigger, Google Drive +29