8
n8n 한국어amn8n.com

Gemini와 Supabase를 사용하여 Google Drive 문서에서 RAG 벡터 데이터베이스 생성

고급

이것은Document Extraction, AI RAG분야의자동화 워크플로우로, 16개의 노드를 포함합니다.주로 Code, Postgres, GoogleDrive, SplitInBatches, ExecuteWorkflowTrigger 등의 노드를 사용하며. Gemini와 Supabase를 사용하여 Google Drive 문서에서 RAG 벡터 데이터베이스 생성

사전 요구사항
  • PostgreSQL 데이터베이스 연결 정보
  • Google Drive API 인증 정보
  • Supabase URL과 API Key
워크플로우 미리보기
노드 연결 관계를 시각적으로 표시하며, 확대/축소 및 이동을 지원합니다
워크플로우 내보내기
다음 JSON 구성을 복사하여 n8n에 가져오면 이 워크플로우를 사용할 수 있습니다
{
  "meta": {
    "instanceId": "a243f35537ecbb3a29ba49c4cf2200720075b362bcc7d02523f79748238bcfd6"
  },
  "nodes": [
    {
      "id": "97927b62-d8b9-4c98-b3d1-160c81c524e5",
      "name": "임베딩 Google Gemini4",
      "type": "@n8n/n8n-nodes-langchain.embeddingsGoogleGemini",
      "position": [
        208,
        320
      ],
      "parameters": {},
      "credentials": {
        "googlePalmApi": {
          "id": "VCZQfcHNj0rHxcNf",
          "name": "GEMINI_API_KUDDUS"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a9afa4ed-5e53-423c-9521-a79b17dbdde1",
      "name": "기본 데이터 로더2",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        384,
        304
      ],
      "parameters": {
        "options": {},
        "dataType": "binary"
      },
      "typeVersion": 1.1
    },
    {
      "id": "478d1053-af37-451e-9baf-7708f43653fa",
      "name": "SQL 쿼리 실행",
      "type": "n8n-nodes-base.postgres",
      "position": [
        -624,
        48
      ],
      "parameters": {
        "query": "DROP TABLE IF EXISTS documents CASCADE;\n\nCREATE EXTENSION IF NOT EXISTS vector;\n\nCREATE TABLE IF NOT EXISTS documents (\n  id bigserial PRIMARY KEY,\n  content text,\n  metadata jsonb,\n  embedding vector(768)\n);\n\nCREATE OR REPLACE FUNCTION match_documents(\n  query_embedding vector(768),\n  match_count int DEFAULT NULL,\n  filter jsonb DEFAULT '{}'::jsonb\n)\nRETURNS TABLE (\n  id bigint,\n  content text,\n  metadata jsonb,\n  similarity double precision\n)\nLANGUAGE sql\nAS $$\n  SELECT\n    d.id,\n    d.content,\n    d.metadata,\n    1 - (d.embedding <=> query_embedding) AS similarity\n  FROM documents d\n  WHERE (filter = '{}'::jsonb OR d.metadata @> filter)\n  ORDER BY d.embedding <=> query_embedding\n  LIMIT match_count;\n$$;\n",
        "options": {},
        "operation": "executeQuery"
      },
      "credentials": {
        "postgres": {
          "id": "KbYSAyR6T3ljhFKn",
          "name": "Postgres account"
        }
      },
      "typeVersion": 2.6
    },
    {
      "id": "7e4395b7-b822-41b6-aac3-0d4c2e3a749b",
      "name": "JavaScript 코드",
      "type": "n8n-nodes-base.code",
      "position": [
        -848,
        48
      ],
      "parameters": {
        "jsCode": "// Get the Drive_Folder_link from the workflow input\nconst driveUrl = $input.first().json.Drive_Folder_link;\n\n// Extract Google Drive folder/file ID from URL\nfunction getDriveId(url) {\n  const folderMatch = url.match(/\\/folders\\/([a-zA-Z0-9_-]+)/);\n  const fileMatch = url.match(/\\/file\\/d\\/([a-zA-Z0-9_-]+)/);\n  return folderMatch ? folderMatch[1] : (fileMatch ? fileMatch[1] : null);\n}\n\n// Process input items\nreturn items.map(item => {\n  const chatInput = item.json.chatInput || driveUrl || '';\n  const driveId = getDriveId(chatInput);\n\n  return {\n    json: {\n      originalInput: chatInput,\n      folderId: driveId,\n      driveId: driveId\n    }\n  };\n});\n"
      },
      "typeVersion": 2
    },
    {
      "id": "3a4041d1-25ac-4ab4-974e-a5460c9a8ffa",
      "name": "다른 워크플로우에 의해 실행 시",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -1056,
        48
      ],
      "parameters": {
        "inputSource": "jsonExample",
        "jsonExample": "{\n  \"Drive_Folder_link\": \"https://drive.google.com/drive/folders/example\"\n}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "92141102-016e-4e8a-b69f-f09d0522924d",
      "name": "스티커 노트1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1504,
        -128
      ],
      "parameters": {
        "color": 5,
        "width": 368,
        "height": 512,
        "content": "# 📁 Drive to Supabase Vector Store for Study RAG\n\nProcesses Google Drive folder files into Supabase vector embeddings for RAG applications.\n\n**Flow:** Drive URL → Parse ID → Init DB → Fetch Files → Loop → Download → Embed → Store\n\n**Requirements:**\n- Google Drive OAuth2\n- Supabase + Postgres credentials\n- Google Gemini API key\n\n**Input:** `{\"Drive_Folder_link\": \"your_drive_url\"}`\n**Output:** Vector embeddings in Supabase documents table\n"
      },
      "typeVersion": 1
    },
    {
      "id": "6960ace8-fd01-4f9e-acfc-05185a0b197f",
      "name": "스티커 노트",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1104,
        208
      ],
      "parameters": {
        "width": 176,
        "height": 128,
        "content": "**Trigger Node** - Starts workflow when called from another n8n workflow. Accepts Drive folder URL as input.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "2befa4d1-ded3-4eeb-93ec-acdc9a9e22fb",
      "name": "스티커 노트2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -864,
        208
      ],
      "parameters": {
        "width": 150,
        "height": 128,
        "content": "**Extract Folder ID** - Parses Google Drive URL using regex to extract folder/file ID for API calls.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "e71b4968-43de-477f-9de6-474cd471c405",
      "name": "스티커 노트3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -656,
        208
      ],
      "parameters": {
        "width": 176,
        "content": "**Initialize Database** - Creates Supabase vector table with pgvector extension and match_documents search function. ⚠️ Drops existing table!\n"
      },
      "typeVersion": 1
    },
    {
      "id": "4ac27951-096f-44ba-8e66-be73b3c0d380",
      "name": "항목 루프 처리",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -192,
        48
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "d556d5eb-6216-4e39-bf8f-07a948fcbb0d",
      "name": "파일 및 폴더 검색",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -416,
        48
      ],
      "parameters": {
        "filter": {
          "folderId": {
            "__rl": true,
            "mode": "id",
            "value": "={{ $('Code in JavaScript').item.json.folderId }}"
          }
        },
        "options": {},
        "resource": "fileFolder"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "CVN95k3ctbjWs60e",
          "name": "Google_Drive_gaming"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "db2f57b6-1aa9-4926-a211-7362d5d4533e",
      "name": "Supabase 벡터스토어에 삽입",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        256,
        48
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "queryName": "match_documents"
        },
        "tableName": {
          "__rl": true,
          "mode": "list",
          "value": "documents",
          "cachedResultName": "documents"
        }
      },
      "credentials": {
        "supabaseApi": {
          "id": "OweRv8RLSfhKJyfg",
          "name": "Supabase account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "09addf62-6c1a-4af4-a5d5-6b2323f64886",
      "name": "파일 다운로드",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        48,
        64
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {
          "googleFileConversion": {
            "conversion": {
              "docsToFormat": "text/plain"
            }
          }
        },
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "CVN95k3ctbjWs60e",
          "name": "Google_Drive_gaming"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "0c929411-a2d2-49ff-ab92-09aeece9d892",
      "name": "스티커 노트4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -432,
        224
      ],
      "parameters": {
        "width": 176,
        "height": 128,
        "content": "**List Drive Files** - Retrieves all files from the specified Google Drive folder using extracted folder ID.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b2b6df82-5145-4719-b3bc-a5501e31ed08",
      "name": "스티커 노트5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        16,
        -112
      ],
      "parameters": {
        "width": 150,
        "content": "**List Drive Files** - Retrieves all files from the specified Google Drive folder using extracted folder ID.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "0d6c2252-f11a-4a12-978c-b121c68c8663",
      "name": "스티커 노트6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        240,
        -208
      ],
      "parameters": {
        "color": 7,
        "height": 240,
        "content": "**Store Embeddings** - Generates 768-dim vectors via Gemini and inserts documents into Supabase for semantic search.\n**AI Embeddings** - Converts text to 768-dimensional vectors using Google Gemini text-embedding-004 model.\n**Document Loader** - Extracts and formats text from binary files for the embedding generator.\n"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "09addf62-6c1a-4af4-a5d5-6b2323f64886": {
      "main": [
        [
          {
            "node": "db2f57b6-1aa9-4926-a211-7362d5d4533e",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "4ac27951-096f-44ba-8e66-be73b3c0d380": {
      "main": [
        [],
        [
          {
            "node": "09addf62-6c1a-4af4-a5d5-6b2323f64886",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7e4395b7-b822-41b6-aac3-0d4c2e3a749b": {
      "main": [
        [
          {
            "node": "478d1053-af37-451e-9baf-7708f43653fa",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "478d1053-af37-451e-9baf-7708f43653fa": {
      "main": [
        [
          {
            "node": "d556d5eb-6216-4e39-bf8f-07a948fcbb0d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "a9afa4ed-5e53-423c-9521-a79b17dbdde1": {
      "ai_document": [
        [
          {
            "node": "db2f57b6-1aa9-4926-a211-7362d5d4533e",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "d556d5eb-6216-4e39-bf8f-07a948fcbb0d": {
      "main": [
        [
          {
            "node": "4ac27951-096f-44ba-8e66-be73b3c0d380",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "97927b62-d8b9-4c98-b3d1-160c81c524e5": {
      "ai_embedding": [
        [
          {
            "node": "db2f57b6-1aa9-4926-a211-7362d5d4533e",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "db2f57b6-1aa9-4926-a211-7362d5d4533e": {
      "main": [
        [
          {
            "node": "4ac27951-096f-44ba-8e66-be73b3c0d380",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3a4041d1-25ac-4ab4-974e-a5460c9a8ffa": {
      "main": [
        [
          {
            "node": "7e4395b7-b822-41b6-aac3-0d4c2e3a749b",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
자주 묻는 질문

이 워크플로우를 어떻게 사용하나요?

위의 JSON 구성 코드를 복사하여 n8n 인스턴스에서 새 워크플로우를 생성하고 "JSON에서 가져오기"를 선택한 후, 구성을 붙여넣고 필요에 따라 인증 설정을 수정하세요.

이 워크플로우는 어떤 시나리오에 적합한가요?

고급 - 문서 추출, AI RAG

유료인가요?

이 워크플로우는 완전히 무료이며 직접 가져와 사용할 수 있습니다. 다만, 워크플로우에서 사용하는 타사 서비스(예: OpenAI API)는 사용자 직접 비용을 지불해야 할 수 있습니다.

워크플로우 정보
난이도
고급
노드 수16
카테고리2
노드 유형9
난이도 설명

고급 사용자를 위한 16+개 노드의 복잡한 워크플로우

저자
Mantaka Mahir

Mantaka Mahir

@mantakamahir

Al Automation Expert || Al Agents || n8n || Python || LangChain || Helping businesses scale revenue and reduce costs with Al driven automation .

외부 링크
n8n.io에서 보기

이 워크플로우 공유

카테고리

카테고리: 34