AutomationFlowsAI & RAG › AI Reranker for Google Drive Files

AI Reranker for Google Drive Files

Original n8n title: Reranks #1

Reranks #1. Uses googleDrive, vectorStoreSupabase, embeddingsOpenAi, documentDefaultDataLoader. Event-driven trigger; 48 nodes.

Event trigger★★★★★ complexityAI-powered48 nodesGoogle DriveSupabase Vector StoreOpenAI EmbeddingsDocument Default Data LoaderText Splitter Recursive Character Text SplitterAgentOpenAI ChatMemory Postgres Chat
AI & RAG Trigger: Event Nodes: 48 Complexity: ★★★★★ AI nodes: yes Added:

This workflow follows the Agent → Chat Trigger 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
{
  "name": "Reranks #1",
  "nodes": [
    {
      "parameters": {
        "resource": "fileFolder",
        "returnAll": true,
        "filter": {
          "folderId": {
            "__rl": true,
            "value": "1dh1Rr2yrhSdoSYpiR8s1yXiSWLYxpoLJ",
            "mode": "list",
            "cachedResultName": "Company",
            "cachedResultUrl": "https://drive.google.com/drive/folders/1dh1Rr2yrhSdoSYpiR8s1yXiSWLYxpoLJ"
          }
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        3680,
        580
      ],
      "id": "f0678325-baee-4210-886b-72d4e4fcc4ce",
      "name": "Search File",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "operation": "download",
        "fileId": {
          "__rl": true,
          "value": "={{ $json.id }}",
          "mode": "id"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        3840,
        580
      ],
      "id": "52a98bc4-4364-49cd-b7dc-5ea77024473e",
      "name": "Get Data",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "insert",
        "tableName": {
          "__rl": true,
          "value": "documents",
          "mode": "list",
          "cachedResultName": "documents"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.1,
      "position": [
        4080,
        380
      ],
      "id": "13e41f0e-c890-4e8c-8fc0-76615187c1db",
      "name": "Supabase Vector Store",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        4060,
        560
      ],
      "id": "739dd64e-9493-41de-b5aa-f0a376e8ce85",
      "name": "Embeddings OpenAI",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "dataType": "binary",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1,
      "position": [
        4200,
        580
      ],
      "id": "6674cbfc-c0e0-48e1-b044-d7ee693dfc83",
      "name": "Default Data Loader"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "typeVersion": 1,
      "position": [
        4240,
        720
      ],
      "id": "b3c042bb-4c0b-4dd3-ac7e-be7a99d792df",
      "name": "Recursive Character Text Splitter"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.splitInBatches",
      "typeVersion": 3,
      "position": [
        3860,
        380
      ],
      "id": "13cff178-5db2-478e-97de-dee175b62a8f",
      "name": "Loop Over Items"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{ $json.payload._data.key.id }}",
        "options": {
          "systemMessage": "=You are a business intelligence assistant for Company with access to:\n\n1. **company knowledge based** - General business documents and guides\n2. **Restaurant Leads Database** - Potential restaurant clients with ratings, contact info, and business details\n\nYou can help with:\n- Finding high-potential restaurant leads by location, rating, or category\n- Analyzing restaurant market opportunities  \n- Providing restaurant recommendations and insights\n- Preparing cold outreach strategies with personalized data\n- Business intelligence from collected restaurant data\n\nAlways use both knowledge sources to provide comprehensive answers."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        2380,
        740
      ],
      "id": "a077fb5d-f2c5-40c4-9dd5-6abc28a21311",
      "name": "AI Agent"
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        2320,
        900
      ],
      "id": "ef8f5cec-f189-4d46-b5b3-7a07b201f942",
      "name": "OpenAI Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "sessionIdType": "customKey",
        "sessionKey": "={{ $('WAHA Trigger').item.json.payload._data.key.remoteJid }}",
        "contextWindowLength": 20
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        2460,
        900
      ],
      "id": "c054fd37-688b-40ef-86c7-fb7ada0b13ba",
      "name": "Postgres Chat Memory",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        2600,
        1040
      ],
      "id": "482e862f-6592-4d02-9bd1-6b50d1e87e5b",
      "name": "Embeddings OpenAI1",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "hour": 0
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "value": "1dh1Rr2yrhSdoSYpiR8s1yXiSWLYxpoLJ",
          "mode": "list",
          "cachedResultName": "Company A",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1dh1Rr2yrhSdoSYpiR8s1yXiSWLYxpoLJ"
        },
        "event": "fileUpdated",
        "options": {
          "fileType": "all"
        }
      },
      "type": "n8n-nodes-base.googleDriveTrigger",
      "typeVersion": 1,
      "position": [
        3500,
        580
      ],
      "id": "3b6a1f51-882b-4f0c-9e39-2676c08f1e71",
      "name": "Google Drive Trigger",
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "# Company Knowledge Base\n",
        "height": 620,
        "width": 1100,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3420,
        260
      ],
      "typeVersion": 1,
      "id": "91703e9f-78c7-4db3-a58f-b9736379d6f5",
      "name": "Sticky Note"
    },
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        2080,
        180
      ],
      "id": "0ea74b68-0ade-4b9a-9371-38184aac722f",
      "name": "When clicking \u2018Execute workflow\u2019"
    },
    {
      "parameters": {
        "method": "POST",
        "url": "<your apify url>",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\n    \"includeWebResults\": false,\n    \"language\": \"id\",\n    \"locationQuery\": \"{{ $json.lokasi }}\",\n    \"maxCrawledPlacesPerSearch\": 500,\n    \"maxImages\": 0,\n    \"maximumLeadsEnrichmentRecords\": 0,\n    \"scrapeContacts\": false,\n    \"scrapeDirectories\": false,\n    \"scrapeImageAuthors\": false,\n    \"scrapePlaceDetailPage\": false,\n    \"scrapeReviewsPersonalData\": true,\n    \"scrapeTableReservationProvider\": false,\n    \"searchStringsArray\": [\n        \"Restoran\"\n    ],\n    \"skipClosedPlaces\": false\n}",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2520,
        180
      ],
      "id": "9150f04a-1201-41e8-902d-dcf18c7a6bb2",
      "name": "Scrape Maps"
    },
    {
      "parameters": {
        "jsCode": "// Bersihkan dan format data dari spreadsheet\nconst cleanData = $input.all().map(item => {\n  const data = item.json;\n  \n  // Parse JSON strings jadi array yang mudah dibaca\n  function parseJsonField(field) {\n    try {\n      if (!field || field === 'not found') return [];\n      const parsed = JSON.parse(field);\n      if (Array.isArray(parsed)) {\n        return parsed.map(item => {\n          if (typeof item === 'object') {\n            return Object.keys(item).filter(key => item[key] === true);\n          }\n          return item;\n        }).flat();\n      }\n      return [];\n    } catch {\n      return [];\n    }\n  }\n  \n  // Parse opening hours jadi format mudah dibaca\n  function parseOpeningHours(hoursString) {\n    try {\n      if (!hoursString) return 'Jam buka tidak tersedia';\n      const hours = JSON.parse(hoursString);\n      return hours.map(h => `${h.day}: ${h.hours}`).join(', ');\n    } catch {\n      return 'Jam buka tidak tersedia';\n    }\n  }\n  \n  // Ekstrak data bersih\n  const keunggulan = parseJsonField(data.Keunggulan);\n  const fasilitas = parseJsonField(data.Fasilitas);\n  const pembayaran = parseJsonField(data.Pembayaran);\n  const allCategories = parseJsonField(data['All Categories']);\n  const openingHours = parseOpeningHours(data['Opening Hours']);\n  \n  // Buat deskripsi lengkap untuk AI\n  const businessDescription = `\n${data.Title} adalah ${data.Category} yang berlokasi di ${data.Neighborhood}. \nRating: ${data.Rating}/5 dengan ${data.Reviews} review. \nHarga: ${data.Price || 'Tidak diketahui'}.\n${data.Description || ''}\n\nKeunggulan: ${keunggulan.join(', ') || 'Tidak ada info keunggulan'}\nFasilitas: ${fasilitas.join(', ') || 'Tidak ada info fasilitas'}  \nMetode Pembayaran: ${pembayaran.join(', ') || 'Tidak ada info pembayaran'}\nKategori: ${allCategories.join(', ') || data.Category}\nJam Buka: ${openingHours}\n\nKontak: ${data.Phone || 'Tidak ada nomor telepon'}\nWebsite: ${data.Website !== 'not found' ? data.Website : 'Tidak ada website'}\nAlamat Lengkap: ${data.Address}\n`.trim();\n\n  // Hitung lead score\n  let leadScore = 0;\n  if (data.Rating >= 4.5) leadScore += 30;\n  if (data.Rating >= 4.0) leadScore += 20;\n  if (data.Reviews >= 1000) leadScore += 25;\n  if (data.Reviews >= 100) leadScore += 15;\n  if (data.Phone) leadScore += 20;\n  if (data.Website && data.Website !== 'not found') leadScore += 20;\n  if (keunggulan.length > 0) leadScore += 10;\n\n  return {\n    // Data utama\n    restaurant_name: data.Title,\n    category: data.Category,\n    description: data.Description || '',\n    location: data.Neighborhood,\n    full_address: data.Address,\n    phone: data.Phone,\n    website: data.Website !== 'not found' ? data.Website : '',\n    rating: data.Rating,\n    total_reviews: data.Reviews,\n    price_range: data.Price || 'Tidak diketahui',\n    \n    // Data terformat\n    keunggulan_list: keunggulan.join(', '),\n    fasilitas_list: fasilitas.join(', '),\n    pembayaran_list: pembayaran.join(', '),\n    kategori_lengkap: allCategories.join(', '),\n    jam_operasional: openingHours,\n    \n    // Untuk AI analysis\n    business_summary: businessDescription,\n    lead_score: leadScore,\n    lead_quality: leadScore >= 70 ? 'High' : leadScore >= 40 ? 'Medium' : 'Low',\n    \n    // Metadata\n    scraped_date: new Date().toLocaleString('id-ID'),\n    data_source: 'Google Maps via Apify'\n  };\n});\n\nreturn cleanData;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        2520,
        380
      ],
      "id": "ee02f5bb-be98-4344-b9d3-1637e923d7e2",
      "name": "Clean Data"
    },
    {
      "parameters": {
        "authentication": "serviceAccount",
        "operation": "update",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/1DKXYqpb0EWNYsbq2x8h5xqUWXy772toNDVrl8d-8nfA/edit?usp=sharing",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Restaurant",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1DKXYqpb0EWNYsbq2x8h5xqUWXy772toNDVrl8d-8nfA/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Title": "={{ $json.restaurant_name }}",
            "Category": "={{ $json.category }}",
            "Description": "={{ $json.description }}",
            "Address": "={{ $json.full_address }}",
            "Phone": "={{ $json.phone }}",
            "Rating": "={{ $json.rating }}",
            "Reviews": "={{ $json.total_reviews }}",
            "Price": "={{ $json.price_range }}",
            "Website": "={{ $json.website }}",
            "Neighborhood": "={{ $json.location }}",
            "Opening Hours": "={{ $json.jam_operasional }}",
            "All Categories": "={{ $json.kategori_lengkap }}",
            "Keunggulan": "={{ $json.keunggulan_list }}",
            "Fasilitas": "={{ $json.fasilitas_list }}",
            "Pembayaran": "={{ $json.pembayaran_list }}",
            "Lead Score": "={{ $json.lead_score }}",
            "Lead Quality": "={{ $json.lead_quality }}",
            "row_number": "={{ $('Get Leads').item.json.row_number }}"
          },
          "matchingColumns": [
            "row_number"
          ],
          "schema": [
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Description",
              "displayName": "Description",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Category",
              "displayName": "Category",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Address",
              "displayName": "Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "displayName": "Phone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Rating",
              "displayName": "Rating",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Reviews",
              "displayName": "Reviews",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Price",
              "displayName": "Price",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website",
              "displayName": "Website",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Neighborhood",
              "displayName": "Neighborhood",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Opening Hours",
              "displayName": "Opening Hours",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "All Categories",
              "displayName": "All Categories",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Keunggulan",
              "displayName": "Keunggulan",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Fasilitas",
              "displayName": "Fasilitas",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Pembayaran",
              "displayName": "Pembayaran",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Lead Score",
              "displayName": "Lead Score",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Lead Quality",
              "displayName": "Lead Quality",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "row_number",
              "displayName": "row_number",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "readOnly": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        2740,
        380
      ],
      "id": "93664ba7-c18c-4064-b984-f592791cb731",
      "name": "Update Data",
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "path": "<your webhook>",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        2080,
        380
      ],
      "id": "51681e42-74ca-4fe8-9254-40f150c0a2aa",
      "name": "Webhook",
      "disabled": true
    },
    {
      "parameters": {
        "url": "<your webhook>",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        3180,
        180
      ],
      "id": "e0fea0f5-7281-439f-bf90-841a80646590",
      "name": "HTTP Request1",
      "disabled": true
    },
    {
      "parameters": {
        "url": "<your apify get>",
        "options": {}
      },
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        2740,
        180
      ],
      "id": "92aa2a7f-c626-4a60-99e4-b5712ba9a1c1",
      "name": "Get Result"
    },
    {
      "parameters": {
        "authentication": "serviceAccount",
        "operation": "append",
        "documentId": {
          "__rl": true,
          "value": "https://docs.google.com/spreadsheets/d/1DKXYqpb0EWNYsbq2x8h5xqUWXy772toNDVrl8d-8nfA/edit?usp=sharing",
          "mode": "url"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Restaurant",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1DKXYqpb0EWNYsbq2x8h5xqUWXy772toNDVrl8d-8nfA/edit#gid=0"
        },
        "columns": {
          "mappingMode": "defineBelow",
          "value": {
            "Title": "={{ $json.title }}",
            "Phone": "={{ $json.phone ? $json.phone.replace(/[-\\s]/g, '') : '' }}",
            "Rating": "={{ $json.totalScore }}",
            "Category": "={{ $json.categoryName }}",
            "Description": "={{ $json.description }}",
            "Address": "={{ $json.address }}",
            "Reviews": "={{ $json.reviewsCount }}",
            "Price": "={{ $json.price }}",
            "Website": "={{ $json.website || \"not found\" }}",
            "Opening Hours": "={{ $json.openingHours }}",
            "All Categories": "={{ $json.categories }}",
            "Neighborhood": "={{ $json.neighborhood }}",
            "Pembayaran": "={{ $json.additionalInfo.Pembayaran }}",
            "Fasilitas": "={{ $json.additionalInfo.Fasilitas }}",
            "Keunggulan": "={{ $json.additionalInfo.Keunggulan }}"
          },
          "matchingColumns": [],
          "schema": [
            {
              "id": "Title",
              "displayName": "Title",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Description",
              "displayName": "Description",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Category",
              "displayName": "Category",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Address",
              "displayName": "Address",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Phone",
              "displayName": "Phone",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Rating",
              "displayName": "Rating",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Reviews",
              "displayName": "Reviews",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Price",
              "displayName": "Price",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Website",
              "displayName": "Website",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Neighborhood",
              "displayName": "Neighborhood",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Opening Hours",
              "displayName": "Opening Hours",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "All Categories",
              "displayName": "All Categories",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true
            },
            {
              "id": "Keunggulan",
              "displayName": "Keunggulan",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Fasilitas",
              "displayName": "Fasilitas",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            },
            {
              "id": "Pembayaran",
              "displayName": "Pembayaran",
              "required": false,
              "defaultMatch": false,
              "display": true,
              "type": "string",
              "canBeUsedToMatch": true,
              "removed": false
            }
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        2960,
        180
      ],
      "id": "412a7be8-66ec-484c-b539-583dbe531f73",
      "name": "Append Leads",
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "authentication": "serviceAccount",
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": ""
        },
        "sheetName": {
          "__rl": true,
          "value": "",
          "mode": "list",
          "cachedResultName": "",
          "cachedResultUrl": ""
        }
      },
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.6,
      "position": [
        2300,
        380
      ],
      "id": "93eefe61-c614-4f52-8d3e-2bcc268628bc",
      "name": "Get Leads",
      "credentials": {
        "googleApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "# Scrapping and data Cleaning\n",
        "height": 520,
        "width": 1360,
        "color": 7
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2020,
        80
      ],
      "typeVersion": 1,
      "id": "d666e66e-a749-4484-8564-a136e54a4dd2",
      "name": "Sticky Note1"
    },
    {
      "parameters": {
        "mode": "insert",
        "tableName": {
          "__rl": true,
          "value": "restaurant_leads",
          "mode": "list",
          "cachedResultName": "restaurant_leads"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.3,
      "position": [
        4080,
        1060
      ],
      "id": "3b072239-fc03-4208-b2c6-2a8dc9dd4bed",
      "name": "Supabase Vector Store2",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        4060,
        1280
      ],
      "id": "1237145e-e64e-4f52-880c-07a7acd58bb3",
      "name": "small3",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "typeVersion": 1,
      "position": [
        4200,
        1220
      ],
      "id": "7beea738-09bb-44c2-80eb-405ea9bca15b",
      "name": "Default Data Loader2"
    },
    {
      "parameters": {
        "chunkOverlap": 200,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "typeVersion": 1,
      "position": [
        4200,
        1360
      ],
      "id": "88ae6f60-796c-4507-8c5e-c71ed7232533",
      "name": "Recursive Character Text Splitter1"
    },
    {
      "parameters": {
        "pollTimes": {
          "item": [
            {
              "mode": "everyHour"
            }
          ]
        },
        "documentId": {
          "__rl": true,
          "value": "1DKXYqpb0EWNYsbq2x8h5xqUWXy772toNDVrl8d-8nfA",
          "mode": "list",
          "cachedResultName": "Database Company A",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1DKXYqpb0EWNYsbq2x8h5xqUWXy772toNDVrl8d-8nfA/edit?usp=drivesdk"
        },
        "sheetName": {
          "__rl": true,
          "value": "gid=0",
          "mode": "list",
          "cachedResultName": "Restaurant",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1DKXYqpb0EWNYsbq2x8h5xqUWXy772toNDVrl8d-8nfA/edit#gid=0"
        },
        "options": {}
      },
      "type": "n8n-nodes-base.googleSheetsTrigger",
      "typeVersion": 1,
      "position": [
        3480,
        1060
      ],
      "id": "ab1ca886-dad6-4cc5-83a7-da5d2c6f0fd4",
      "name": "Google Sheets Trigger",
      "credentials": {
        "googleSheetsTriggerOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "jsCode": "// Transform data yang baru ditambah dari spreadsheet\nconst newData = $input.all().map(item => {\n  const data = item.json;\n  \n  // Skip jika data kosong\n  if (!data.Title || data.Title.trim() === '') {\n    return null;\n  }\n  \n  // Buat business summary untuk embedding\n  const businessSummary = `\n${data.Title} adalah ${data.Category || 'restoran'} yang berlokasi di ${data.Neighborhood || 'lokasi tidak diketahui'}. \nRating: ${data.Rating || 'belum ada rating'}/5 dengan ${data.Reviews || 0} review. \nHarga: ${data.Price || 'Tidak diketahui'}.\n${data.Description || ''}\n\nKeunggulan: ${data['Keunggulan Clean'] || 'Tidak ada info keunggulan'}\nFasilitas: ${data['Fasilitas Clean'] || 'Tidak ada info fasilitas'}  \nMetode Pembayaran: ${data['Pembayaran Clean'] || 'Tidak ada info pembayaran'}\nJam Operasional: ${data['Jam Operasional'] || 'Tidak tersedia'}\n\nKontak: ${data.Phone || 'Tidak ada nomor telepon'}\nWebsite: ${data.Website !== 'not found' ? data.Website : 'Tidak ada website'}\nAlamat: ${data.Address || 'Alamat tidak lengkap'}\n`.trim();\n\n  return {\n    // Content untuk embedding\n    business_summary: businessSummary,\n    \n    // Metadata\n    metadata: {\n      restaurant_name: data.Title,\n      category: data.Category,\n      location: data.Neighborhood,\n      phone: data.Phone,\n      rating: data.Rating,\n      total_reviews: data.Reviews,\n      lead_score: data['Lead Score'] || 0,\n      lead_quality: data['Lead Quality'] || 'Unknown',\n      keunggulan: data['Keunggulan Clean'] || '',\n      fasilitas: data['Fasilitas Clean'] || '',\n      pembayaran: data['Pembayaran Clean'] || '',\n      website: data.Website !== 'not found' ? data.Website : '',\n      price_range: data.Price || 'Tidak diketahui',\n      full_address: data.Address,\n      jam_operasional: data['Jam Operasional'] || 'Tidak tersedia',\n      row_number: data.row_number,\n      last_updated: new Date().toISOString(),\n      data_type: \"restaurant_lead\",\n      source: \"google_sheets_auto\"\n    }\n  };\n}).filter(item => item !== null);\n\nreturn newData;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3660,
        1060
      ],
      "id": "5a8f4c25-e22f-40f0-b139-50088dfeb8e4",
      "name": "Transform for Vector"
    },
    {
      "parameters": {
        "jsCode": "// Check dan handle existing data di Supabase vector database\nconst inputData = $input.all();\nconst processedData = [];\n\nfor (const item of inputData) {\n  const data = item.json;\n  \n  // Skip jika data kosong atau tidak valid\n  if (!data.Title || data.Title.trim() === '') {\n    console.log(`Skipping empty data for row ${data.row_number}`);\n    continue;\n  }\n  \n  // Buat unique identifier berdasarkan kombinasi nama + alamat\n  const uniqueId = `${data.Title}_${data.Address}`.replace(/[^a-zA-Z0-9]/g, '_').toLowerCase();\n  \n  // Buat business summary untuk embedding\n  const businessSummary = `\nNama Restoran: ${data.Title}\nKategori: ${data.Category || 'Restoran'}\nLokasi: ${data.Neighborhood || 'Tidak diketahui'}\nAlamat: ${data.Address || 'Alamat tidak lengkap'}\nRating: ${data.Rating || 'Belum ada rating'}/5 (${data.Reviews || 0} reviews)\nHarga: ${data.Price || 'Tidak diketahui'}\nDeskripsi: ${data.Description || 'Tidak ada deskripsi'}\n\nDetail Bisnis:\n- Keunggulan: ${data.Keunggulan || 'Tidak ada info keunggulan'}\n- Fasilitas: ${data.Fasilitas || 'Tidak ada info fasilitas'}\n- Metode Pembayaran: ${data.Pembayaran || 'Tidak ada info pembayaran'}\n- Jam Operasional: ${data['Opening Hours'] || 'Tidak tersedia'}\n\nKontak:\n- Telepon: ${data.Phone || 'Tidak ada nomor telepon'}\n- Website: ${data.Website && data.Website !== 'not found' ? data.Website : 'Tidak ada website'}\n\nLead Score: ${data['Lead Score'] || 0}\nLead Quality: ${data['Lead Quality'] || 'Unknown'}\n`.trim();\n\n  // Prepare data untuk vector store\n  const vectorData = {\n    // Text content untuk embedding\n    pageContent: businessSummary,\n    \n    // Metadata untuk filtering dan searching\n    metadata: {\n      unique_id: uniqueId,\n      restaurant_name: data.Title,\n      category: data.Category || 'Restoran',\n      location: data.Neighborhood || 'Tidak diketahui',\n      full_address: data.Address || '',\n      phone: data.Phone || '',\n      website: data.Website && data.Website !== 'not found' ? data.Website : '',\n      rating: parseFloat(data.Rating) || 0,\n      total_reviews: parseInt(data.Reviews) || 0,\n      price_range: data.Price || 'Tidak diketahui',\n      lead_score: parseInt(data['Lead Score']) || 0,\n      lead_quality: data['Lead Quality'] || 'Unknown',\n      \n      // Additional business info\n      keunggulan: data.Keunggulan || '',\n      fasilitas: data.Fasilitas || '',\n      pembayaran: data.Pembayaran || '',\n      jam_operasional: data['Opening Hours'] || '',\n      \n      // System metadata\n      row_number: data.row_number,\n      data_source: 'google_sheets',\n      data_type: 'restaurant_lead',\n      last_updated: new Date().toISOString(),\n      \n      // Status tracking\n      contact_status: 'not_contacted',\n      is_active: true\n    },\n    \n    // Original row data untuk reference\n    original_data: data\n  };\n  \n  // Add flag untuk indicate ini adalah update atau insert baru\n  vectorData.metadata.is_update = !!data.row_number;\n  \n  processedData.push(vectorData);\n  \n  console.log(`Processed: ${data.Title} (ID: ${uniqueId})`);\n}\n\nconsole.log(`Total processed: ${processedData.length} items`);\n\nreturn processedData;"
      },
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        3880,
        1060
      ],
      "id": "d0223130-8df1-4f3b-9800-3ead95a29c5f",
      "name": "Check Existing Data"
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolName": "CompanyDocuments",
        "toolDescription": "Search CompanyDocument knowledge base and business documents",
        "tableName": {
          "__rl": true,
          "value": "documents",
          "mode": "list",
          "cachedResultName": "documents"
        },
        "topK": 20,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.1,
      "position": [
        2600,
        920
      ],
      "id": "5793e2f7-4cd9-47d4-a54c-ca426a606204",
      "name": "RAG",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolName": "RestaurantLeads",
        "toolDescription": "=Search restaurant leads and potential clients data",
        "tableName": {
          "__rl": true,
          "value": "restaurant_leads",
          "mode": "list",
          "cachedResultName": "restaurant_leads"
        },
        "topK": 20,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.1,
      "position": [
        2880,
        920
      ],
      "id": "4d621157-f7c5-40f3-b074-9b291834d502",
      "name": "Leads",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        2880,
        1060
      ],
      "id": "a0d34cae-29ed-4bcc-960f-1c32187ed7ac",
      "name": "Embeddings OpenAI2",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "# Potential Leads Knowledge Base\n",
        "height": 600,
        "width": 1100,
        "color": 5
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        3420,
        940
      ],
      "typeVersion": 1,
      "id": "92a0a539-b14a-4b12-9bdf-3f6d1b4baf5f",
      "name": "Sticky Note2"
    },
    {
      "parameters": {
        "content": "# Respond as a chatbot",
        "height": 560,
        "width": 1360
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2020,
        640
      ],
      "typeVersion": 1,
      "id": "ebf1d8e0-f7a2-4303-97be-07f70f4430c2",
      "name": "Sticky Note3"
    },
    {
      "parameters": {},
      "type": "@devlikeapro/n8n-nodes-waha.wahaTrigger",
      "typeVersion": 202502,
      "position": [
        1700,
        340
      ],
      "id": "23ea6d0b-c66a-4d74-8b42-b09065abeace",
      "name": "WAHA Trigger",
      "disabled": true
    },
    {
      "parameters": {
        "options": {
          "systemMessage": "=# Company Business Intelligence Assistant\n\nYou are \"MinCharge\", a specialized business intelligence assistant for the company. Your primary responsibility is to provide answers exclusively based on the available knowledge sources.\n\n## Knowledge Sources\nYou have access to two critical knowledge bases:\n1. **CompanyDocuments** - Contains business documents, service guides, company information, and operational procedures\n2. **RestaurantLeads** - Contains potential restaurant client data including ratings, contact information, business details, and market insights\n\n## \ud83d\udea8 CRITICAL: Tool Selection Protocol\n\n### MANDATORY Tool Usage Rules:\n**CompanyDocuments tool MUST be used for:**\n- ANY question about company services, capabilities, or offerings\n- Pricing inquiries (\"how much\", \"cost\", \"price\", \"fee\")\n- Company information (\"about the company\", \"what is the company\", \"company details\")\n- Business processes (\"how does the company work\", \"process\", \"procedure\")\n- Service features and benefits\n- Any question containing keywords: company, service, price, cost, business, how to, process, capability, offering\n\n**RestaurantLeads tool MUST be used for:**\n- Lead generation and prospecting requests\n- Restaurant recommendations and listings\n- Market analysis and competitive intelligence\n- Location-based restaurant queries\n- Rating, review, and business characteristic analysis\n- Contact information and outreach data\n\n### Search Strategy Hierarchy:\n1. **Company-specific queries** \u2192 Use CompanyDocuments FIRST, always\n2. **Restaurant/lead queries** \u2192 Use RestaurantLeads FIRST\n3. **Business intelligence/strategy** \u2192 Use BOTH tools sequentially\n4. **Ambiguous queries** \u2192 Default to CompanyDocuments first, then RestaurantLeads if needed\n\n## Execution Process (Follow Strictly):\n1. **Query Classification**: \n   - Identify if query mentions company, services, pricing, or company info\n   - If YES \u2192 Immediately use CompanyDocuments tool\n   - If restaurant/lead focused \u2192 Use RestaurantLeads tool\n   - If business strategy \u2192 Use both tools\n\n2. **Tool Selection Verification**:\n   - Double-check that you're using the correct tool for the query type\n   - When in doubt about company-related content \u2192 ALWAYS search CompanyDocuments\n\n3. **Search Execution**: \n   - Execute search in identified tool(s) before generating any response\n   - Use specific, relevant keywords from user query\n\n4. **Response Generation**: \n   - Base response entirely on search results\n   - Clearly cite which knowledge base provided the information\n   - Match user's language (Indonesian/English)\n\n## Core Operating Principles\n- **MANDATORY SEARCH**: Never respond without searching appropriate knowledge base first\n- **NO EXTERNAL KNOWLEDGE**: Absolutely no information from outside the knowledge bases\n- **EXPLICIT SOURCE CITATION**: Always state \"Based on CompanyDocuments...\" or \"According to RestaurantLeads...\"\n- **LANGUAGE MATCHING**: Respond in exact same language as user input\n- **ACCURACY OVER COMPLETENESS**: Better to say \"no information found\" than guess\n\n## Quality Assurance Checklist\nBefore every response, verify:\n- \u2705 Did I search the appropriate knowledge base?\n- \u2705 Is my answer based solely on search results?\n- \u2705 Did I cite the correct source?\n- \u2705 Am I responding in the user's language?\n- \u2705 Did I avoid using external knowledge?\n\n## Error Handling\nIf no relevant information found in knowledge bases:\n- **English**: \"I searched [specific knowledge base] but don't have information about [topic]. Could you provide more specific details or rephrase your question?\"\n- **Indonesian**: \"Saya telah mencari di [basis pengetahuan spesifik] tetapi tidak memiliki informasi tentang [topik]. Bisakah Anda memberikan detail yang lebih spesifik atau mengubah pertanyaan Anda?\"\n\n## Debugging Mode\nAlways mention in your response which tool you used:\n- \"After searching CompanyDocuments...\"\n- \"Based on my search in RestaurantLeads...\"\n- \"From both knowledge bases...\"\n\nThis helps identify if tool selection is working correctly.\n\nRemember: Your value comes from providing accurate, source-backed intelligence from the company's specific business context and restaurant lead database. Always search first, cite sources, and match the user's language."
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 2,
      "position": [
        2380,
        1340
      ],
      "id": "07c892fe-1c58-4c1e-943c-700c6bc1926d",
      "name": "AI Agent1"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        2580,
        1660
      ],
      "id": "80997c1f-4ddd-47b0-be81-bc75abd6dbfd",
      "name": "Embeddings OpenAI3",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolName": "CompanyDocuments",
        "toolDescription": "=MANDATORY TOOL for questions about: CompanyDocument services, pricing, company information, business processes, operational procedures, service capabilities, company policies, internal guidelines, and any Company A-specific business inquiries. Always use this tool first when users ask about Company A services or company information.",
        "tableName": {
          "__rl": true,
          "value": "documents",
          "mode": "list",
          "cachedResultName": "documents"
        },
        "topK": 20,
        "useReranker": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.1,
      "position": [
        2600,
        1520
      ],
      "id": "1640e426-2920-4e77-bac4-779cb6081194",
      "name": "RAG1",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "retrieve-as-tool",
        "toolName": "RestaurantLeads",
        "toolDescription": "=Search restaurant leads database containing potential client information, ratings, contact details, business characteristics, location data, and market insights. Use for lead generation, market analysis, and client prospecting.",
        "tableName": {
          "__rl": true,
          "value": "restaurant_leads",
          "mode": "list",
          "cachedResultName": "restaurant_leads"
        },
        "topK": 20,
        "useReranker": true,
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "typeVersion": 1.1,
      "position": [
        2880,
        1520
      ],
      "id": "6c8f2db0-ec5b-4164-9f4a-ea36d33478e6",
      "name": "Leads1",
      "credentials": {
        "supabaseApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "typeVersion": 1.2,
      "position": [
        2900,
        1660
      ],
      "id": "21d6d2c8-1ad3-455e-8171-77ed6f60f5e1",
      "name": "Embeddings OpenAI4",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "content": "# Send Message",
        "height": 580,
        "width": 1360,
        "color": 4
      },
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2020,
        1240
      ],
      "typeVersion": 1,
      "id": "2b711442-2dd0-43b7-b3a0-19a785bc0417",
      "name": "Sticky Note4"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "typeVersion": 1.1,
      "position": [
        2200,
        1340
      ],
      "id": "782a8690-70f8-403f-8d59-13bf96b343d7",
      "name": "When chat message received"
    },
    {
      "parameters": {
        "contextWindowLength": 20
      },
      "type": "@n8n/n8n-nodes-langchain.memoryPostgresChat",
      "typeVersion": 1.3,
      "position": [
        2460,
        1500
      ],
      "id": "c4a980f5-681a-4d5b-bcf7-504d5b832a53",
      "name": "Chat Memory",
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.2,
      "position": [
        2320,
        1500
      ],
      "id": "6faff427-ccc8-4747-801f-e4846460c7c5",
      "name": "Chat Model",
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelName": "rerank-multilingual-v3.0"
      },
      "type": "@n8n/n8n-nodes-langchain.rerankerCohere",
      "typeVersion": 1,
      "position": [
        2720,
        1660
      ],
      "id": "579ac8c8-359b-4297-b93b-4dff7dd41928",
      "name": "Reranker Cohere",
      "credentials": {
        "cohereApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "modelName": "rerank-multilingual-v3.0"
      },
      "type": "@n8n/n8n-nodes-langchain.rerankerCohere",
      "typeVersion": 1,
      "position": [
        3020,
        1660
      ],
      "id": "bf15a02a-a529-4c06-8bc4-7e595cde718b",
      "name": "Reranker Cohere1",
      "credentials": {
        "cohereApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "e80e3961-4f18-4e38-8642-4c35075f13a1",
              "name": "lokasi",
              "value": "Bali",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        2300,
        180
      ],
      "id": "547e4f7d-737c-4819-85af-fa02e3196da9",
      "name": "Set Location"
    }
  ],
  "connections": {
    "Search File": {
      "main": [
        [
          {
            "node": "Get Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Data": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Supabase Vector Store": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Supabase Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Supabase Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        []
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Postgres Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "RAG",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Google Drive Trigger": {
      "main": [
        [
          {
            "node": "Search File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Set Location",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scrape Maps": {
      "main": [
        [
          {
            "node": "Get Result",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Clean Data": {
      "main": [
        [
          {
            "node": "Update Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook": {
      "main": [
        [
          {
            "node": "Get Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Result": {
      "main": [
        [
          {
            "node": "Append Leads",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append Leads": {
      "main": [
        [
          {
            "node": "HTTP Request1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Leads": {
      "main": [
        [
          {
            "node": "Clean Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "small3": {
      "ai_embedding": [
        [
          {
            "node": "Supabase Vector Store2",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader2": {
      "ai_document": [
        [
          {
            "node": "Supabase Vector Store2",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Recursive Character Text Splitter1": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader2",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Google Sheets Trigger": {
      "main": [
        [
          {
            "node": "Transform for Vector",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Transform for Vector": {
      "main": [
        [
          {
            "node": "Check Existing Data",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Existing Data": {
      "main": [
        [
          {
            "node": "Supabase Vector Store2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RAG": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Leads": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI2": {
      "ai_embedding": [
        [
          {
            "node": "Leads",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "WAHA Trigger": {
      "main": [
        [],
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI3": {
      "ai_embedding": [
        [
          {
            "node": "RAG1",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "RAG1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Leads1": {
      "ai_tool": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI4": {
      "ai_embedding": [
        [
          {
            "node": "Leads1",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent1": {
      "main": [
        []
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent1",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Reranker Cohere": {
      "ai_reranker": [
        [
          {
            "node": "RAG1",
            "type": "ai_reranker",
            "index": 0
          }
        ]
      ]
    },
    "Reranker Cohere1": {
      "ai_reranker": [
        [
          {
            "node": "Leads1",
            "type": "ai_reranker",
            "index": 0
          }
        ]
      ]
    },
    "Set Location": {
      "main": [
        [
          {
            "node": "Scrape Maps",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "f96e50a9-3b2c-4de0-a80d-c5bf5cb2b336",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "id": "QIkMJhue2s5le6jM",
  "tags": []
}

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

How this works

This workflow empowers researchers, analysts, and content creators to retrieve and prioritise the most relevant information from Google Drive documents, delivering precise, context-aware results that save hours of manual sifting. It processes files by loading and splitting them into manageable chunks, then uses OpenAI embeddings to generate vector representations stored in Supabase for efficient similarity searches. The key step involves an AI agent that reranks search outputs based on semantic relevance, ensuring the top results align closely with your query's intent.

Use this workflow when handling large document repositories in Google Drive where quick access to nuanced, ranked insights is essential, such as during report preparation or knowledge base queries. Avoid it for simple file retrieval without semantic needs, or when documents are too small for meaningful splitting. Common variations include swapping Supabase for another vector store or integrating additional triggers like scheduled runs for periodic updates.

About this workflow

Reranks #1. Uses googleDrive, vectorStoreSupabase, embeddingsOpenAi, documentDefaultDataLoader. Event-driven trigger; 48 nodes.

Source: https://github.com/khmuhtadin/n8n-template/blob/main/RAG/Reranks__1.json — 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

Your AI workforce is ready. Are you?

Google Sheets Tool, Mcp Trigger, Google Drive +29
AI & RAG

This intelligent chatbot leverages cutting-edge financial APIs and AI-driven analysis to deliver comprehensive stock research reports. Get instant access to professional-grade investment analysis that

Tool Think, Supabase Vector Store, OpenAI Embeddings +15
AI & RAG

RAG_Ingest. Uses httpRequest, vectorStoreSupabase, documentDefaultDataLoader, textSplitterRecursiveCharacterTextSplitter. Event-driven trigger; 73 nodes.

HTTP Request, Supabase Vector Store, Document Default Data Loader +4
AI & RAG

This advanced n8n workflow automates the full lead enrichment, qualification, and personalized outreach process tailored specifically for the B2B real estate sector. Integrating top platforms like Api

N8N Nodes Fillout, OpenAI Chat, Pinecone Vector Store +11
AI & RAG

This n8n template automatically classifies incoming emails (Sales, Support, Internal, Finance, Promotions) and routes them to a dedicated OpenAI LLM Agent for processing. Depending on the category, th

OpenAI, Gmail, Text Classifier +16