コンテキスト・ハイブリッドRAG AIコピー

上級

これはAI RAG, Multimodal AI分野の自動化ワークフローで、76個のノードを含みます。主にIf, Set, Code, Wait, Cryptoなどのノードを使用。 RAGアプリケーション向けのGoogle DriveからSupabaseコンテキストベクトルデータベースへの同期

前提条件
  • Supabase URL と API Key
  • Google Drive API認証情報
  • ターゲットAPIの認証情報が必要な場合あり
  • OpenAI API Key
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "id": "XwFvFryyo4goPzpd",
  "meta": {
    "instanceId": "00761fd5aea81495387b0889e15912dcc912b73b7bf62f5ca3898afbd7a79723",
    "templateCredsSetupCompleted": true
  },
  "name": "Contextual Hybrid RAG AI copy",
  "tags": [
    {
      "id": "YINdrIOThMQjiVkB",
      "name": "RAG",
      "createdAt": "2025-06-18T21:07:48.174Z",
      "updatedAt": "2025-06-18T21:07:48.174Z"
    },
    {
      "id": "j0SNhalFSbPAhdWo",
      "name": "n8n creator",
      "createdAt": "2025-09-02T01:40:23.866Z",
      "updatedAt": "2025-09-02T01:40:23.866Z"
    }
  ],
  "nodes": [
    {
      "id": "c1422e6a-289f-4499-b19b-62df452010b2",
      "name": "AIエージェント",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -2544,
        -736
      ],
      "parameters": {
        "options": {
          "systemMessage": "Only generate answers based on the results from the connected database. Do no under any circumstance, get answers from anywhere else.\nfor every query check the database to see if you can find an answer. If you can not or are not sure, then say 'Sorry, I don’t know'. Never come up with answers. Only get answers from the database"
        }
      },
      "typeVersion": 2
    },
    {
      "id": "efb0bd4c-0b6d-4b96-8e8d-d1b511174151",
      "name": "チャットメッセージ受信時",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -2784,
        -736
      ],
      "webhookId": "f4516070-1da1-41ad-8320-bd3a31cddf12",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "3c285b17-d4f0-4e8e-809b-38be2a5ede94",
      "name": "シンプルメモリ",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -2544,
        -528
      ],
      "parameters": {
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "8a624394-5019-4a67-a31c-c56fad7b1406",
      "name": "OpenAI チャットモデル",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -2704,
        -528
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "gpt-4.1"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "QsPyEUltWeliSiFb",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "317048f7-1423-4922-ac19-ad1b79152359",
      "name": "Google Drive",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -3536,
        304
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "KZY6CHPvoIbIxMKd",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "27074acb-2256-4b79-a093-df35755ca0e8",
      "name": "レコードマネージャー検索",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -2608,
        304
      ],
      "parameters": {
        "limit": 1,
        "filters": {
          "conditions": [
            {
              "keyName": "gd_file_id",
              "keyValue": "={{ $('Loop Over Items').item.json.id }}",
              "condition": "eq"
            }
          ]
        },
        "tableId": "record_managerhs",
        "operation": "getAll"
      },
      "credentials": {
        "supabaseApi": {
          "id": "bi5dJhIwrvuB6YQA",
          "name": "CHRAG"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "cc825e4c-1f68-4688-8e32-5d08b3aab1ac",
      "name": "レコードマネージャーに行を作成",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -1808,
        48
      ],
      "parameters": {
        "tableId": "record_managerhs",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "gd_file_id",
              "fieldValue": "={{ $('Loop Over Items').item.json.id }}"
            },
            {
              "fieldId": "hash",
              "fieldValue": "={{ $('Generate Hash').item.json.hash }}"
            }
          ]
        }
      },
      "credentials": {
        "supabaseApi": {
          "id": "bi5dJhIwrvuB6YQA",
          "name": "CHRAG"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "39445058-69b3-4bf1-8236-99a4a55e7d86",
      "name": "スイッチ",
      "type": "n8n-nodes-base.switch",
      "position": [
        -2416,
        288
      ],
      "parameters": {
        "rules": {
          "values": [
            {
              "outputKey": "does not exist",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "231bfd13-5f93-4801-b0f5-9ff2d949c165",
                    "operator": {
                      "type": "object",
                      "operation": "empty",
                      "singleValue": true
                    },
                    "leftValue": "={{ $json }}",
                    "rightValue": ""
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "modified",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "b311878c-297f-4d5b-ba2f-f1babb9c9f7b",
                    "operator": {
                      "type": "string",
                      "operation": "notEquals"
                    },
                    "leftValue": "={{ $json.hash }}",
                    "rightValue": "={{ $('Generate Hash').item.json.hash }}"
                  }
                ]
              },
              "renameOutput": true
            },
            {
              "outputKey": "exist",
              "conditions": {
                "options": {
                  "version": 2,
                  "leftValue": "",
                  "caseSensitive": true,
                  "typeValidation": "loose"
                },
                "combinator": "and",
                "conditions": [
                  {
                    "id": "dc26f05e-859a-40a4-b0e3-49abc55397a5",
                    "operator": {
                      "name": "filter.operator.equals",
                      "type": "string",
                      "operation": "equals"
                    },
                    "leftValue": "={{ $('Generate Hash').item.json.hash }}",
                    "rightValue": "={{ $json.hash }}"
                  }
                ]
              },
              "renameOutput": true
            }
          ]
        },
        "options": {},
        "looseTypeValidation": true
      },
      "typeVersion": 3.2
    },
    {
      "id": "10062467-974d-4103-aeb3-bff32d0c6e3f",
      "name": "以前のベクトルを削除",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -2016,
        368
      ],
      "parameters": {
        "tableId": "documentshs",
        "operation": "delete",
        "filterType": "string",
        "filterString": "=metadata->>file_id=eq.{{ $('Loop Over Items').item.json.id }}"
      },
      "credentials": {
        "supabaseApi": {
          "id": "GZCrvWKfz1aQNVve",
          "name": "Supabase - RAG"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "e145b247-04d6-40f9-b3ab-7ad034aa0a31",
      "name": "ハッシュを生成",
      "type": "n8n-nodes-base.crypto",
      "position": [
        -2848,
        304
      ],
      "parameters": {
        "type": "SHA256",
        "value": "={{ $json.text }}",
        "dataPropertyName": "hash"
      },
      "typeVersion": 1
    },
    {
      "id": "40aa27bb-4577-4d2d-abc4-0ed103fc0cbd",
      "name": "レコードマネージャーを更新",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -1600,
        368
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "keyValue": "={{ $('Search Record Manager').item.json.id }}",
              "condition": "eq"
            }
          ]
        },
        "tableId": "record_managerhs",
        "fieldsUi": {
          "fieldValues": [
            {
              "fieldId": "hash",
              "fieldValue": "={{ $('Generate Hash').item.json.hash }}"
            }
          ]
        },
        "operation": "update"
      },
      "credentials": {
        "supabaseApi": {
          "id": "GZCrvWKfz1aQNVve",
          "name": "Supabase - RAG"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "f0c2dcd5-5fe8-4968-a510-0f7d997d3b2f",
      "name": "集約",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -1824,
        368
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "56bc70d8-aba3-4534-be6b-05cce089505a",
      "name": "基本LLMチェーン",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        -1248,
        272
      ],
      "parameters": {
        "text": "=# File Name\n{{ $('Loop Over Items').item.json.name}}\n\n# File Content\n{{ $('Set Text').item.json.text.split(/\\s+/).length > 500\n? $('Set Text').item.json.text.split(/\\s+/).slice(0, 500).join(' ') + '...'\n: $('Set Text').item.json.text}}",
        "batching": {},
        "messages": {
          "messageValues": [
            {
              "message": "=Based on the provided file name and file contents, extract out a 1 sentence description of what the document is about and classify the document based on motorsport category. \n\n Only output JSON in the following format \n\n{ \n\"document_summary\": \"document summary\"\n}\n\nIf you are unsure, just output N/A in the field. \n\n"
            }
          ]
        },
        "promptType": "define",
        "hasOutputParser": true
      },
      "typeVersion": 1.7
    },
    {
      "id": "c99060a8-fe04-44c8-86ad-76ad9c0f2f6c",
      "name": "構造化出力パーサー",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "position": [
        -1072,
        432
      ],
      "parameters": {
        "jsonSchemaExample": "{ \n\"documentSummary\": \"document summary\"\n} "
      },
      "typeVersion": 1.3
    },
    {
      "id": "478f6320-0c37-478c-8321-8083e5d903fe",
      "name": "OpenAI チャットモデル1",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1264,
        432
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "gpt-4.1"
        },
        "options": {
          "responseFormat": "json_object"
        }
      },
      "credentials": {
        "openAiApi": {
          "id": "QsPyEUltWeliSiFb",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3e9028df-ff29-4599-9ae9-c08a3811f047",
      "name": "ファイルから抽出",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        -3344,
        304
      ],
      "parameters": {
        "options": {},
        "operation": "pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "df98c1e9-b29c-4558-bbe4-a8925fd5a2f1",
      "name": "テキストを設定",
      "type": "n8n-nodes-base.set",
      "position": [
        -3104,
        304
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "766bf659-155f-4d60-a033-085b3a752933",
              "name": "text",
              "type": "string",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "258005cc-104e-4e31-96f0-a3fae138da93",
      "name": "アイテムをループ処理1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -2224,
        976
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "84ac45bc-27c8-4fce-8e03-be8c9cf18fe8",
      "name": "レコードマネージャー検索1",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -1936,
        976
      ],
      "parameters": {
        "limit": 1,
        "filters": {
          "conditions": [
            {
              "keyName": "gd_file_id",
              "keyValue": "={{ $('Loop Over Items1').item.json.id }}",
              "condition": "eq"
            }
          ]
        },
        "tableId": "record_managerhs",
        "operation": "getAll"
      },
      "credentials": {
        "supabaseApi": {
          "id": "bi5dJhIwrvuB6YQA",
          "name": "CHRAG"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "81fc8e77-f1fb-4914-87b7-489bdcdf3f9d",
      "name": "条件分岐1",
      "type": "n8n-nodes-base.if",
      "position": [
        -1728,
        976
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "21ca0db4-5ca4-49e8-86c1-9e09c469122d",
              "operator": {
                "type": "object",
                "operation": "exists",
                "singleValue": true
              },
              "leftValue": "={{$json}}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "9561c9dd-0b82-4cdb-bed0-a3307d206394",
      "name": "以前のベクトルを削除1",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -1472,
        976
      ],
      "parameters": {
        "tableId": "documentshs",
        "operation": "delete",
        "filterType": "string",
        "filterString": "=metadata->>file_id=eq.{{ $('Loop Over Items1').item.json.id }}"
      },
      "credentials": {
        "supabaseApi": {
          "id": "bi5dJhIwrvuB6YQA",
          "name": "CHRAG"
        }
      },
      "typeVersion": 1,
      "alwaysOutputData": true
    },
    {
      "id": "31cc03e7-50db-4c6d-b266-136225457218",
      "name": "集約1",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        -1280,
        976
      ],
      "parameters": {
        "options": {},
        "aggregate": "aggregateAllItemData"
      },
      "typeVersion": 1
    },
    {
      "id": "0c76dd9b-be10-4fdd-8536-ea3eb75a6cba",
      "name": "レコードマネージャーからレコードを削除1",
      "type": "n8n-nodes-base.supabase",
      "position": [
        -1072,
        976
      ],
      "parameters": {
        "filters": {
          "conditions": [
            {
              "keyName": "id",
              "keyValue": "={{ $('Search Record Manager1').item.json.id }}",
              "condition": "eq"
            }
          ]
        },
        "tableId": "record_managerhs",
        "operation": "delete"
      },
      "credentials": {
        "supabaseApi": {
          "id": "bi5dJhIwrvuB6YQA",
          "name": "CHRAG"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "c41851a0-ba52-432d-ae00-752bb630cead",
      "name": "Google Drive2",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -848,
        976
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $('Loop Over Items1').item.json.id }}"
        },
        "options": {},
        "operation": "deleteFile"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "KZY6CHPvoIbIxMKd",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "03516980-317e-483d-9471-6cf9e3148415",
      "name": "GDゴミ箱を監視",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -2432,
        976
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1gwf7pIH8X5wU-i0YMw-j7qPSA4MnA40L",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1gwf7pIH8X5wU-i0YMw-j7qPSA4MnA40L",
          "cachedResultName": "Trash"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "KZY6CHPvoIbIxMKd",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "a791c6a2-1311-40cc-837e-c875425774cc",
      "name": "GD RAGファイルを監視",
      "type": "n8n-nodes-base.googleDriveTrigger",
      "position": [
        -3984,
        304
      ],
      "parameters": {
        "event": "fileCreated",
        "options": {},
        "pollTimes": {
          "item": [
            {
              "mode": "everyMinute"
            }
          ]
        },
        "triggerOn": "specificFolder",
        "folderToWatch": {
          "__rl": true,
          "mode": "list",
          "value": "1e1Af14X5nlPq6oVEqbHs4h7pQtYktzAM",
          "cachedResultUrl": "https://drive.google.com/drive/folders/1e1Af14X5nlPq6oVEqbHs4h7pQtYktzAM",
          "cachedResultName": "RAG Files"
        }
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "id": "KZY6CHPvoIbIxMKd",
          "name": "Google Drive account"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3024e04e-86c4-43d6-819d-22f45ef40750",
      "name": "別ワークフローから実行時",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -2016,
        -544
      ],
      "parameters": {
        "workflowInputs": {
          "values": [
            {
              "name": "query"
            }
          ]
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "5da16ea7-5c2c-4326-8069-7228ea20041f",
      "name": "ベクトルストアをクエリ",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        -2272,
        -512
      ],
      "parameters": {
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "XwFvFryyo4goPzpd",
          "cachedResultName": "Contextual Hybrid RAG AI copy"
        },
        "description": "Call this tool to get knowledge from our vector database",
        "workflowInputs": {
          "value": {
            "query": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('query', ``, 'string') }}"
          },
          "schema": [
            {
              "id": "query",
              "type": "string",
              "display": true,
              "required": false,
              "displayName": "query",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "query"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": false
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "467f3d3b-8727-413b-aa8d-7547ac7d8a68",
      "name": "アイテムをループ処理",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -3776,
        304
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "7d2d4e71-ce5f-4e08-a5fb-2ca01d17e6a6",
      "name": "チャンキング用にテキストを設定",
      "type": "n8n-nodes-base.set",
      "position": [
        -864,
        272
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "5fb33f33-8d7f-467e-ab8b-784c411b63b2",
              "name": "content",
              "type": "string",
              "value": "={{ $('Set Text').item.json.text }}"
            },
            {
              "id": "d0fdcb3c-915f-4e39-93de-ac8244415be5",
              "name": "documentSummary",
              "type": "string",
              "value": "={{ $json.output.document_summary }}"
            },
            {
              "id": "5ffe4726-56f1-4478-9f89-ba862efce940",
              "name": "file_id",
              "type": "string",
              "value": "={{ $('Loop Over Items').item.json.id }}"
            },
            {
              "id": "df951786-5196-4590-9e32-fed42ef35200",
              "name": "fileName",
              "type": "string",
              "value": "={{ $('Loop Over Items').item.json.name }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "9a68682b-7a2f-40ca-91a9-e0d935ec7ed3",
      "name": "付箋1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -4016,
        144
      ],
      "parameters": {
        "width": 160,
        "height": 304,
        "content": "### Watch GD folder\n"
      },
      "typeVersion": 1
    },
    {
      "id": "22acc35b-1370-450f-90f2-ff4a2c9f61e4",
      "name": "付箋6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3136,
        144
      ],
      "parameters": {
        "width": 160,
        "height": 300,
        "content": "### Set Text"
      },
      "typeVersion": 1
    },
    {
      "id": "cb0d4e98-3716-4bba-8f33-a1c0ee5224a7",
      "name": "付箋7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2896,
        144
      ],
      "parameters": {
        "width": 172,
        "height": 308,
        "content": " ### Generate Hash based on the text. If text changes we have a different hash"
      },
      "typeVersion": 1
    },
    {
      "id": "6f0493ae-8973-48c8-9338-f62d1b826445",
      "name": "付箋8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2656,
        144
      ],
      "parameters": {
        "width": 188,
        "height": 308,
        "content": "### Search the record manager to see if we have any files in the database, that have the same file id. If it does, it will return the hash"
      },
      "typeVersion": 1
    },
    {
      "id": "6336a34a-fade-435c-b0a7-5257b48c5579",
      "name": "付箋9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2432,
        112
      ],
      "parameters": {
        "width": 180,
        "height": 340,
        "content": "### Compare the Hash from generated hash and (if it exists) hash from record manager search to determine if file exists or not and if modified"
      },
      "typeVersion": 1
    },
    {
      "id": "be85f58e-3cff-42f7-b1ff-d1f22c781961",
      "name": "付箋10",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2080,
        256
      ],
      "parameters": {
        "width": 640,
        "height": 280,
        "content": "### If the doc is modified, we delete all the vectors related to that google id and update record manager id and hash"
      },
      "typeVersion": 1
    },
    {
      "id": "79ee3377-d001-4bd7-8d25-c48e5676aff7",
      "name": "付箋11",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1328,
        176
      ],
      "parameters": {
        "width": 380,
        "height": 220,
        "content": "### Create summary of document for metadata"
      },
      "typeVersion": 1
    },
    {
      "id": "2943dad5-ae6b-4fde-a293-eb8e319bc41b",
      "name": "付箋12",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -896,
        176
      ],
      "parameters": {
        "width": 160,
        "height": 224,
        "content": "### Set text to send to sub-workflow"
      },
      "typeVersion": 1
    },
    {
      "id": "6109b822-9860-4a85-860b-15dd4494bac7",
      "name": "付箋14",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2464,
        864
      ],
      "parameters": {
        "width": 156,
        "height": 280,
        "content": "### Watch GD Trash folder"
      },
      "typeVersion": 1
    },
    {
      "id": "4522d72b-9a92-4614-a2c8-f6a739d2169d",
      "name": "付箋15",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1984,
        864
      ],
      "parameters": {
        "width": 192,
        "height": 264,
        "content": "### Search record manager on corresponding GD file id"
      },
      "typeVersion": 1
    },
    {
      "id": "c57592c9-e02e-4861-a1e3-189f3b24f7cf",
      "name": "付箋16",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1760,
        864
      ],
      "parameters": {
        "width": 160,
        "height": 264,
        "content": "### if records exist for this id or not\n"
      },
      "typeVersion": 1
    },
    {
      "id": "9af264c1-de52-4fd7-9366-7d573499b02a",
      "name": "付箋17",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1520,
        864
      ],
      "parameters": {
        "width": 580,
        "height": 264,
        "content": "### Delete records from supabase"
      },
      "typeVersion": 1
    },
    {
      "id": "0403746d-e354-4d88-93d4-a05f9faa4aea",
      "name": "付箋18",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -880,
        864
      ],
      "parameters": {
        "width": 150,
        "height": 264,
        "content": "### Delete file from GD"
      },
      "typeVersion": 1
    },
    {
      "id": "d48e00db-570d-41b5-a5db-4435059fe3ec",
      "name": "付箋19",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2304,
        -624
      ],
      "parameters": {
        "width": 1020,
        "height": 240,
        "content": "## Query Seach Supabase Database Tool with workflow"
      },
      "typeVersion": 1
    },
    {
      "id": "1af9acb3-e6a8-435d-9d91-cb84c5fd608b",
      "name": "付箋20",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        192
      ],
      "parameters": {
        "width": 150,
        "height": 248,
        "content": "### Set up data\n"
      },
      "typeVersion": 1
    },
    {
      "id": "936e7ead-1a8c-4337-b784-5732ef2784ac",
      "name": "付箋",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -6000,
        -16
      ],
      "parameters": {
        "width": 752,
        "height": 800,
        "content": "## Setting up Supabase\n\n\n### Create a project, and fill in the details as guided by Supabase.  On the left hand side, you will find the Project Overview section. Scroll down to connecting your project section and you will find the url and api key, which you can place in the credentials section or in the create new credentials in a supabase node.\n\n\n\n\n\n## Setting up the Hybrid Search in Supabase\n### You can learn more about hybrid search here: https://supabase.com/docs/guides/ai/hybrid-search\n\n### Go to the SQL Editor tab, and delete the existing code. First we will create the documents for the Hybrid Search called documentsHS. Find the code in a note in this workflow to the left of this sticky note. Copy & paste the code in the SQL Editor and click run. You will get a message saying pg_notify. The documentsHS is complete. Now delete the code and copy paste the code for the record manager called record_managerHS in the sticky note on the left. You will get a message saying Success. No Rows Returned. You have now created the tables for the hybrid search. \n\n## To call the hybrid search, we will use the edge function.\n### To create the edge function, go to the edge function (left hand side bar), click deploy a new function, and select Via AI Assistant.  Paste \"Create a new edge function that calls on the match_documentshs_hybrid so it can be called through API\". This will create your edge function and you can click on deploy to deploy it. In the details section, you will find the endpoint URL that you can paste into the URL in the HTTP Request (called Edge Function). Make sure to copy the Bearer YOUR_API_KEY as well and create a Header Auth to store it. You will find that in the Generic Auth Type under Header Auth. That will go in the Value section and the word 'Authorization' in the Name. You have now successfully completed the setup for the hybrid search."
      },
      "typeVersion": 1
    },
    {
      "id": "76cf1951-f712-4d05-ab00-c5201a4bdf15",
      "name": "付箋2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -7456,
        -784
      ],
      "parameters": {
        "width": 656,
        "height": 2416,
        "content": "# documentHS\n\n\n-- Extensions\ncreate extension if not exists vector;\ncreate extension if not exists pg_trgm;\n\n-- Table\ncreate table if not exists documentsHS (\n  id bigserial primary key,\n  content text,\n  metadata jsonb,\n  embedding vector(1536),\n  tokens tsvector generated always as (\n    to_tsvector('english', coalesce(content, ''))\n  ) stored\n);\n\n-- Indexes\ncreate index if not exists documentsHS_tokens_gin\n  on documentsHS using gin (tokens);\n\ncreate index if not exists documentsHS_embedding_ivfflat\n  on documentsHS using ivfflat (embedding vector_cosine_ops) with (lists = 100);\n\ncreate index if not exists documentsHS_metadata_gin\n  on documentsHS using gin (metadata);\n\n-- ==========================================\n-- Single HYBRID function exposed via RPC\n-- ==========================================\ncreate or replace function public.match_documentshs_hybrid(\n  query_embedding float4[],           -- required; send as JSON array\n  query_text text,                    -- required\n  match_count int default 10,\n  semantic_weight float default 0.5,  -- 0..1 (higher = more semantic)\n  filter jsonb default '{}'           -- optional structured filter\n)\nreturns table (\n  id bigint,\n  content text,\n  metadata jsonb,\n  similarity double precision,\n  keyword_rank double precision,\n  hybrid_score double precision\n)\nlanguage sql\nstable\nas $$\n  with base as (\n    select\n      d.id,\n      d.content,\n      d.metadata,\n      (1 - (d.embedding <=> (query_embedding::vector(1536)))) as sim,\n      ts_rank(d.tokens, plainto_tsquery('english', query_text)) as kw_rank\n    from documentsHS d\n    where d.metadata @> filter\n  ),\n  stats as (\n    select max(sim) as max_sim, max(kw_rank) as max_kw from base\n  )\n  select\n    b.id,\n    b.content,\n    b.metadata,\n    b.sim as similarity,\n    b.kw_rank as keyword_rank,\n    (\n      coalesce(case when s.max_sim > 0 then b.sim / s.max_sim else 0 end, 0) * semantic_weight\n      +\n      coalesce(case when s.max_kw  > 0 then b.kw_rank / s.max_kw else 0 end, 0) * (1 - semantic_weight)\n    ) as hybrid_score\n  from base b cross join stats s\n  where (b.sim > 0) or (b.kw_rank > 0)\n  order by hybrid_score desc\n  limit match_count;\n$$;\n\n-- Optional helpers\ncreate or replace function public.match_documentshs_vector_only(\n  query_embedding float4[],\n  match_count int default 10,\n  filter jsonb default '{}'\n)\nreturns table (\n  id bigint,\n  content text,\n  metadata jsonb,\n  similarity double precision\n)\nlanguage sql\nstable\nas $$\n  select\n    d.id, d.content, d.metadata,\n    (1 - (d.embedding <=> (query_embedding::vector(1536)))) as similarity\n  from documentsHS d\n  where d.metadata @> filter\n  order by d.embedding <=> (query_embedding::vector(1536))\n  limit match_count;\n$$;\n\ncreate or replace function public.match_documentshs_keyword_only(\n  query_text text,\n  match_count int default 10,\n  filter jsonb default '{}'\n)\nreturns table (\n  id bigint,\n  content text,\n  metadata jsonb,\n  keyword_rank double precision\n)\nlanguage sql\nstable\nas $$\n  select\n    d.id, d.content, d.metadata,\n    ts_rank(d.tokens, plainto_tsquery('english', query_text)) as keyword_rank\n  from documentsHS d\n  where d.metadata @> filter\n    and plainto_tsquery('english', query_text) @@ d.tokens\n  order by keyword_rank desc\n  limit match_count;\n$$;\n\n-- Reload API schema\nselect pg_notify('pgrst', 'reload schema');"
      },
      "typeVersion": 1
    },
    {
      "id": "ae127c8a-15e8-485a-913b-932e7a3f0f15",
      "name": "付箋3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -6784,
        -784
      ],
      "parameters": {
        "width": 592,
        "height": 224,
        "content": "# record_managerHS code\n\ncreate table public.record_managerHS (\n  id bigint generated by default as identity not null,\n  created_at timestamp with time zone not null default now(),\n  gd_file_id text not null,\n  hash text not null,\n  constraint record_managerHS_pkey primary key (id)\n) TABLESPACE pg_default;"
      },
      "typeVersion": 1
    },
    {
      "id": "4e8a1b14-2fd5-4dfc-89f4-73898134d384",
      "name": "エッジ関数",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1552,
        -544
      ],
      "parameters": {
        "url": "Your Edge Function URL Here",
        "method": "POST",
        "options": {
          "redirect": {
            "redirect": {}
          }
        },
        "jsonBody": "={\n    \"query_text\":       \"{{ $('When Executed by Another Workflow').item.json.query }}\",\n    \"query_embedding\":  [{{ $json.data[0].embedding }}],\n    \"match_count\":      5, \n    \"full_text_weight\": 1.0,\n    \"semantic_weight\": 1.0,\n    \"rrf_k\":            50\n  } ",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "T59KJDlDMiYYary2",
          "name": "Supabase CHRAG"
        }
      },
      "typeVersion": 4.2,
      "alwaysOutputData": true
    },
    {
      "id": "cf18ef2b-6044-4526-9f0f-b1ec4d7a547d",
      "name": "サブワークフローを呼び出し",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        -656,
        336
      ],
      "parameters": {
        "options": {},
        "workflowId": {
          "__rl": true,
          "mode": "list",
          "value": "OB2T8YYdXtHcujuT",
          "cachedResultName": "My Sub-workflow"
        },
        "workflowInputs": {
          "value": {
            "content": "={{ $json.content }}",
            "file_id": "={{ $json.file_id }}",
            "fileName": "={{ $json.fileName }}",
            "documentSummary": "={{ $json.documentSummary }}"
          },
          "schema": [
            {
              "id": "content",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "content",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "documentSummary",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "documentSummary",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "file_id",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "file_id",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            },
            {
              "id": "fileName",
              "display": true,
              "removed": false,
              "required": false,
              "displayName": "fileName",
              "defaultMatch": false,
              "canBeUsedToMatch": true
            }
          ],
          "mappingMode": "defineBelow",
          "matchingColumns": [
            "content",
            "documentSummary",
            "file_id",
            "fileName"
          ],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "61e693a0-bebc-4f32-8531-67110fc08e38",
      "name": "Supabase ベクトルストア1",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        1440,
        336
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "tableName": {
          "__rl": true,
          "mode": "list",
          "value": "documentshs",
          "cachedResultName": "documentshs"
        }
      },
      "credentials": {
        "supabaseApi": {
          "id": "GZCrvWKfz1aQNVve",
          "name": "Supabase - RAG"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "7588feea-e4d2-4a67-91a8-2a35d4439293",
      "name": "OpenAI埋め込み1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        1440,
        512
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "QsPyEUltWeliSiFb",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "db23a77d-2805-421d-a3c0-43de5a78e0a5",
      "name": "デフォルトデータローダー",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        1568,
        528
      ],
      "parameters": {
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "file_id",
                "value": "={{ $('Metadata').item.json.file_id }}"
              },
              {
                "name": "motorsport_category",
                "value": "={{ $('Metadata').item.json.motorsportCategory }}"
              },
              {
                "name": "file_name",
                "value": "={{ $('Metadata').item.json.fileName }}"
              },
              {
                "name": "file_summary",
                "value": "={{ $('Metadata').item.json.documentSummary }}"
              }
            ]
          }
        },
        "textSplittingMode": "custom"
      },
      "typeVersion": 1.1
    },
    {
      "id": "fa1ce78e-ef3c-45e9-9b89-b6afa3e3a119",
      "name": "再帰的文字テキスト分割器",
      "type": "@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter",
      "position": [
        1536,
        656
      ],
      "parameters": {
        "options": {},
        "chunkSize": 1400
      },
      "typeVersion": 1
    },
    {
      "id": "c4771f8f-dabe-4815-8fe2-d862234cbec7",
      "name": "再帰的分割器2",
      "type": "n8n-nodes-base.code",
      "position": [
        -80,
        336
      ],
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const chunkSize = 1000;\nconst chunkOverlap = 200;\nconst text = $input.item.json.content.replace(/\\n/, '');\n\nconst chunks = [];\nlet remainingText = text;\n\nwhile (remainingText.length > 0) {\n    let splitPoint;\n\n    // Try splitting at paragraph level first\n    splitPoint = remainingText.lastIndexOf(\"\\n\\n\", chunkSize);\n    \n    // If no paragraph split, try splitting at sentence level\n    if (splitPoint === -1) {\n        splitPoint = remainingText.lastIndexOf(\". \", chunkSize);\n    }\n\n    // If no sentence split, try splitting at word level\n    if (splitPoint === -1) {\n        splitPoint = remainingText.lastIndexOf(\" \", chunkSize);\n    }\n\n    // If still no split point, force cut at chunkSize\n    if (splitPoint === -1 || splitPoint < chunkSize * 0.5) {  \n        splitPoint = chunkSize; // Hard split if no good split point\n    }\n\n    // Extract chunk and adjust remaining text with overlap\n    let chunk = remainingText.substring(0, splitPoint).trim();\n    chunks.push(chunk);\n\n    // Move the pointer forward while keeping the overlap\n    remainingText = remainingText.substring(Math.max(0, splitPoint - chunkOverlap)).trim();\n\n    // Break if remaining text is too small to form another chunk\n    if (remainingText.length < chunkSize * 0.2) {\n        chunks.push(remainingText);\n        break;\n    }\n}\n\nreturn { chunks };"
      },
      "typeVersion": 2
    },
    {
      "id": "0969dc28-0e90-47ad-9dde-b4425978a6eb",
      "name": "分割出力",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        128,
        336
      ],
      "parameters": {
        "options": {},
        "fieldToSplitOut": "chunks"
      },
      "typeVersion": 1
    },
    {
      "id": "b279aabb-d27f-44d4-9290-e0bf9abca567",
      "name": "埋め込み用にチャンクを設定",
      "type": "n8n-nodes-base.set",
      "position": [
        912,
        336
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "caed5bb3-bd1e-475f-94ad-db0b73cdedf0",
              "name": "text",
              "type": "string",
              "value": "={{ $json.text }} \n"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "2f58e5f1-afe1-4e34-8cf1-e02f932a2e99",
      "name": "メタデータ",
      "type": "n8n-nodes-base.set",
      "position": [
        -288,
        336
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "93527bdc-6f91-4942-b5da-d7d5f1a67f9d",
              "name": "content",
              "type": "string",
              "value": "={{ $json.content }}"
            },
            {
              "id": "15ac4402-e7a1-40fc-a45d-bafd8302358a",
              "name": "documentSummary",
              "type": "string",
              "value": "={{ $json.documentSummary }}"
            },
            {
              "id": "79781e9e-8d64-4ebb-b96a-5d9954e62939",
              "name": "motorsportCategory",
              "type": "string",
              "value": "={{ $json.motorsportCategory }}"
            },
            {
              "id": "ca42a5a1-d11b-4a1e-a9f1-b696d31b4251",
              "name": "file_id",
              "type": "string",
              "value": "={{ $json.file_id }}"
            },
            {
              "id": "97242570-a638-454d-8d5e-62a1eb6c8376",
              "name": "fileName",
              "type": "string",
              "value": "={{ $json.fileName }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "02d36503-b3ad-451b-8f90-9ee50d9e3c53",
      "name": "待機",
      "type": "n8n-nodes-base.wait",
      "position": [
        1104,
        336
      ],
      "webhookId": "9ddc5ae1-c2d9-4031-aa38-dafc7cdda091",
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "f0e1c571-d615-4942-a9cc-2529aa401cef",
      "name": "コンテキストを追加",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "position": [
        576,
        336
      ],
      "parameters": {
        "text": "=<document> \n{{ $('Metadata').item.json.content}}\n</document> \n\nHere is the chunk we want to situate within the overall document:\n\n<chunk> \n{{ $('Loop Over Items2').item.json.chunks }}\n</chunk> \n\nPlease:\n- Provide a short and succinct **context** to situate this chunk within the document for improved search retrieval.\n- Return the **original chunk** exactly as provided unless a correction is necessary.\n- If the chunk contains an **incomplete number, percentage, or entity**, correct it using the full document.\n- If part of a **sentence is cut off**, reconstruct the missing words only if necessary for clarity.\n- If the chunk is part of a table, include the complete table entry to maintain data integrity\n- Do not add any additional explanations or formatting beyond the required output.\n\nFill in the following format:\n[succinct context] : [original chunk or corrected version if necessary]\n\nYour response should contain only the text that replaces these placeholders, without including the placeholder labels themselves.",
        "promptType": "define"
      },
      "typeVersion": 1.5
    },
    {
      "id": "9153a959-d4a9-4392-a072-8db62ecd4008",
      "name": "OpenAI チャットモデル2",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        576,
        544
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-nano",
          "cachedResultName": "gpt-4.1-nano"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "id": "QsPyEUltWeliSiFb",
          "name": "OpenAi account"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "25cb00db-559f-4eb0-baf6-3118fc6c6bf0",
      "name": "アイテムをループ処理2",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        352,
        336
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "756c06ae-1b66-44a0-b4a6-076856cf01b5",
      "name": "集約2",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        544,
        80
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {}
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "1b2f5f20-f2f3-49c4-900a-d63d297b3fc2",
      "name": "付箋5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        224
      ],
      "parameters": {
        "width": 176,
        "height": 280,
        "content": "### Set up data\n"
      },
      "typeVersion": 1
    },
    {
      "id": "a321d862-fcb5-4895-bb44-2f1d038c4614",
      "name": "付箋13",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        224
      ],
      "parameters": {
        "width": 356,
        "height": 280,
        "content": "### Chuck document into multiple chunks based chunk size"
      },
      "typeVersion": 1
    },
    {
      "id": "dfb50197-9be2-4189-ab3c-0f11de6b62c1",
      "name": "付箋21",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        544,
        224
      ],
      "parameters": {
        "width": 264,
        "height": 280,
        "content": "### Add context to each chunk\n"
      },
      "typeVersion": 1
    },
    {
      "id": "48bbb8a8-56de-4e68-acf2-beb25a583145",
      "name": "付箋22",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        832,
        224
      ],
      "parameters": {
        "width": 420,
        "height": 284,
        "content": "### Set up text chunks and add timer so create limits are not reached"
      },
      "typeVersion": 1
    },
    {
      "id": "044811b8-f03e-4954-a6b0-1522030aa109",
      "name": "付箋23",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1344,
        224
      ],
      "parameters": {
        "width": 472,
        "height": 576,
        "content": "### Upsert into vector database."
      },
      "typeVersion": 1
    },
    {
      "id": "57986be6-d5b8-47d8-8e14-f9be28282e59",
      "name": "付箋24",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -352,
        64
      ],
      "parameters": {
        "color": 3,
        "width": 2192,
        "height": 752,
        "content": "# This is the Call My Sub-Workflow "
      },
      "typeVersion": 1
    },
    {
      "id": "f28c07f0-e1d7-482f-bacc-bd2bc3ba011b",
      "name": "付箋4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -6000,
        -784
      ],
      "parameters": {
        "width": 752,
        "height": 752,
        "content": "# Workflow Summary\n\n### This automation keeps your Supabase vector database synchronized with documents stored in Google Drive, while also making the data contextual and vector based for better retrieval.\n\n### When a file is added or modified, the workflow extracts its text, splits it into smaller chunks, and enriches each chunk with contextual metadata (such as summaries and document details). It then generates embeddings using OpenAI and stores both the vector data and metadata in Supabase. If a file changes, the old records are replaced with updated, contextualized content.\n\n### The result is a continuously updated and context-aware vector database, enabling highly accurate hybrid search and retrieval. \n\n\n# To setup\n\n## 1. Connect Google Drive\n•\tCreate a Google Drive folder to watch.\n•\tConnect your Google Drive account in n8n and authorize access.\n•\tPoint the Google Drive Trigger node to this folder (new/modified files trigger the flow).\n\n## 2. Configure Supabase\n•\tPlease refer to the Setting Up Supabase Sticky Note. \n\n## 3. Connect OpenAI (or your embedding model)\n•\tAdd your OpenAI API key in n8n credentials.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7c719413-7945-4e8e-9db2-02c6f3ee49c2",
      "name": "付箋26",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3808,
        144
      ],
      "parameters": {
        "width": 150,
        "height": 304,
        "content": "### Loop over each item, as more than 1 file can be placed in the Google Drive"
      },
      "typeVersion": 1
    },
    {
      "id": "f5d30b0f-d7cc-4574-9939-9a53e7b02d12",
      "name": "付箋28",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3568,
        144
      ],
      "parameters": {
        "width": 160,
        "height": 304,
        "content": "### Download file"
      },
      "typeVersion": 1
    },
    {
      "id": "f9c3a219-dbf0-470a-a54a-2c5775da45c4",
      "name": "付箋29",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -3376,
        144
      ],
      "parameters": {
        "width": 160,
        "height": 304,
        "content": "### Extract text from pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "aced0ee1-a1d5-40fd-b866-c2640136802e",
      "name": "付箋30",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1840,
        -96
      ],
      "parameters": {
        "width": 176,
        "height": 304,
        "content": "### Create new record in record manager since file is new and doesn't exist in database"
      },
      "typeVersion": 1
    },
    {
      "id": "ae132431-fb89-45b5-9849-96812a46dcfd",
      "name": "付箋25",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -2592,
        -832
      ],
      "parameters": {
        "width": 336,
        "height": 208,
        "content": "## AI Agent to communicate with the database"
      },
      "typeVersion": 1
    },
    {
      "id": "c8d17104-e110-453d-97ca-e8e79bf589c1",
      "name": "埋め込み",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1792,
        -544
      ],
      "parameters": {
        "url": "https://api.openai.com/v1/embeddings",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "authentication": "genericCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "input",
              "value": "={{ $json.query }}"
            },
            {
              "name": "model",
              "value": "text-embedding-3-small"
            }
          ]
        },
        "genericAuthType": "httpHeaderAuth"
      },
      "credentials": {
        "httpHeaderAuth": {
          "id": "IZ2NWEGrJPwf73xf",
          "name": "Openai"
        }
      },
      "typeVersion": 4.2
    }
  ],
  "active": false,
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "60d22f47-01bc-4326-b282-0d742ef48480",
  "connections": {
    "81fc8e77-f1fb-4914-87b7-489bdcdf3f9d": {
      "main": [
        [
          {
            "node": "9561c9dd-0b82-4cdb-bed0-a3307d206394",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "02d36503-b3ad-451b-8f90-9ee50d9e3c53": {
      "main": [
        [
          {
            "node": "61e693a0-bebc-4f32-8531-67110fc08e38",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "39445058-69b3-4bf1-8236-99a4a55e7d86": {
      "main": [
        [
          {
            "node": "cc825e4c-1f68-4688-8e32-5d08b3aab1ac",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "10062467-974d-4103-aeb3-bff32d0c6e3f",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "467f3d3b-8727-413b-aa8d-7547ac7d8a68",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "2f58e5f1-afe1-4e34-8cf1-e02f932a2e99": {
      "main": [
        [
          {
            "node": "c4771f8f-dabe-4815-8fe2-d862234cbec7",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "df98c1e9-b29c-4558-bbe4-a8925fd5a2f1": {
      "main": [
        [
          {
            "node": "e145b247-04d6-40f9-b3ab-7ad034aa0a31",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f0c2dcd5-5fe8-4968-a510-0f7d997d3b2f": {
      "main": [
        [
          {
            "node": "40aa27bb-4577-4d2d-abc4-0ed103fc0cbd",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c8d17104-e110-453d-97ca-e8e79bf589c1": {
      "main": [
        [
          {
            "node": "4e8a1b14-2fd5-4dfc-89f4-73898134d384",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0969dc28-0e90-47ad-9dde-b4425978a6eb": {
      "main": [
        [
          {
            "node": "25cb00db-559f-4eb0-baf6-3118fc6c6bf0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "31cc03e7-50db-4c6d-b266-136225457218": {
      "main": [
        [
          {
            "node": "0c76dd9b-be10-4fdd-8536-ea3eb75a6cba",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f0e1c571-d615-4942-a9cc-2529aa401cef": {
      "main": [
        [
          {
            "node": "b279aabb-d27f-44d4-9290-e0bf9abca567",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "317048f7-1423-4922-ac19-ad1b79152359": {
      "main": [
        [
          {
            "node": "3e9028df-ff29-4599-9ae9-c08a3811f047",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "e145b247-04d6-40f9-b3ab-7ad034aa0a31": {
      "main": [
        [
          {
            "node": "27074acb-2256-4b79-a093-df35755ca0e8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c41851a0-ba52-432d-ae00-752bb630cead": {
      "main": [
        [
          {
            "node": "258005cc-104e-4e31-96f0-a3fae138da93",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3c285b17-d4f0-4e8e-809b-38be2a5ede94": {
      "ai_memory": [
        [
          {
            "node": "c1422e6a-289f-4499-b19b-62df452010b2",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "03516980-317e-483d-9471-6cf9e3148415": {
      "main": [
        [
          {
            "node": "258005cc-104e-4e31-96f0-a3fae138da93",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "56bc70d8-aba3-4534-be6b-05cce089505a": {
      "main": [
        [
          {
            "node": "7d2d4e71-ce5f-4e08-a5fb-2ca01d17e6a6",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "467f3d3b-8727-413b-aa8d-7547ac7d8a68": {
      "main": [
        [],
        [
          {
            "node": "317048f7-1423-4922-ac19-ad1b79152359",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "258005cc-104e-4e31-96f0-a3fae138da93": {
      "main": [
        [],
        [
          {
            "node": "84ac45bc-27c8-4fce-8e03-be8c9cf18fe8",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "25cb00db-559f-4eb0-baf6-3118fc6c6bf0": {
      "main": [
        [
          {
            "node": "756c06ae-1b66-44a0-b4a6-076856cf01b5",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "f0e1c571-d615-4942-a9cc-2529aa401cef",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "3e9028df-ff29-4599-9ae9-c08a3811f047": {
      "main": [
        [
          {
            "node": "df98c1e9-b29c-4558-bbe4-a8925fd5a2f1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8a624394-5019-4a67-a31c-c56fad7b1406": {
      "ai_languageModel": [
        [
          {
            "node": "c1422e6a-289f-4499-b19b-62df452010b2",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "7588feea-e4d2-4a67-91a8-2a35d4439293": {
      "ai_embedding": [
        [
          {
            "node": "61e693a0-bebc-4f32-8531-67110fc08e38",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "478f6320-0c37-478c-8321-8083e5d903fe": {
      "ai_languageModel": [
        [
          {
            "node": "56bc70d8-aba3-4534-be6b-05cce089505a",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "9153a959-d4a9-4392-a072-8db62ecd4008": {
      "ai_languageModel": [
        [
          {
            "node": "f0e1c571-d615-4942-a9cc-2529aa401cef",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "5da16ea7-5c2c-4326-8069-7228ea20041f": {
      "ai_tool": [
        [
          {
            "node": "c1422e6a-289f-4499-b19b-62df452010b2",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "a791c6a2-1311-40cc-837e-c875425774cc": {
      "main": [
        [
          {
            "node": "467f3d3b-8727-413b-aa8d-7547ac7d8a68",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "db23a77d-2805-421d-a3c0-43de5a78e0a5": {
      "ai_document": [
        [
          {
            "node": "61e693a0-bebc-4f32-8531-67110fc08e38",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "c4771f8f-dabe-4815-8fe2-d862234cbec7": {
      "main": [
        [
          {
            "node": "0969dc28-0e90-47ad-9dde-b4425978a6eb",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cf18ef2b-6044-4526-9f0f-b1ec4d7a547d": {
      "main": [
        [
          {
            "node": "467f3d3b-8727-413b-aa8d-7547ac7d8a68",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "27074acb-2256-4b79-a093-df35755ca0e8": {
      "main": [
        [
          {
            "node": "39445058-69b3-4bf1-8236-99a4a55e7d86",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "7d2d4e71-ce5f-4e08-a5fb-2ca01d17e6a6": {
      "main": [
        [
          {
            "node": "cf18ef2b-6044-4526-9f0f-b1ec4d7a547d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "40aa27bb-4577-4d2d-abc4-0ed103fc0cbd": {
      "main": [
        [
          {
            "node": "56bc70d8-aba3-4534-be6b-05cce089505a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "84ac45bc-27c8-4fce-8e03-be8c9cf18fe8": {
      "main": [
        [
          {
            "node": "81fc8e77-f1fb-4914-87b7-489bdcdf3f9d",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "61e693a0-bebc-4f32-8531-67110fc08e38": {
      "main": [
        [
          {
            "node": "25cb00db-559f-4eb0-baf6-3118fc6c6bf0",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "10062467-974d-4103-aeb3-bff32d0c6e3f": {
      "main": [
        [
          {
            "node": "f0c2dcd5-5fe8-4968-a510-0f7d997d3b2f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "9561c9dd-0b82-4cdb-bed0-a3307d206394": {
      "main": [
        [
          {
            "node": "31cc03e7-50db-4c6d-b266-136225457218",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c99060a8-fe04-44c8-86ad-76ad9c0f2f6c": {
      "ai_outputParser": [
        [
          {
            "node": "56bc70d8-aba3-4534-be6b-05cce089505a",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "efb0bd4c-0b6d-4b96-8e8d-d1b511174151": {
      "main": [
        [
          {
            "node": "c1422e6a-289f-4499-b19b-62df452010b2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "b279aabb-d27f-44d4-9290-e0bf9abca567": {
      "main": [
        [
          {
            "node": "02d36503-b3ad-451b-8f90-9ee50d9e3c53",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "cc825e4c-1f68-4688-8e32-5d08b3aab1ac": {
      "main": [
        [
          {
            "node": "56bc70d8-aba3-4534-be6b-05cce089505a",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "fa1ce78e-ef3c-45e9-9b89-b6afa3e3a119": {
      "ai_textSplitter": [
        [
          {
            "node": "db23a77d-2805-421d-a3c0-43de5a78e0a5",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "3024e04e-86c4-43d6-819d-22f45ef40750": {
      "main": [
        [
          {
            "node": "c8d17104-e110-453d-97ca-e8e79bf589c1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "0c76dd9b-be10-4fdd-8536-ea3eb75a6cba": {
      "main": [
        [
          {
            "node": "c41851a0-ba52-432d-ae00-752bb630cead",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

このワークフローの使い方は?

上記のJSON設定コードをコピーし、n8nインスタンスで新しいワークフローを作成して「JSONからインポート」を選択、設定を貼り付けて認証情報を必要に応じて変更してください。

このワークフローはどんな場面に適していますか?

上級 - AI RAG検索拡張, マルチモーダルAI

有料ですか?

このワークフローは完全無料です。ただし、ワークフローで使用するサードパーティサービス(OpenAI APIなど)は別途料金が発生する場合があります。

ワークフロー情報
難易度
上級
ノード数76
カテゴリー2
ノードタイプ28
難易度説明

上級者向け、16ノード以上の複雑なワークフロー

作成者
Michael Taleb

Michael Taleb

@michaeltaleb

n8n developer helping businesses save time and scale by automating complex business processes with n8n and smart integrations.

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34