ドキュメントベースのAIチャットボット:RAG、OpenAI、Cohereリランカー

上級

これはInternal Wiki, AI RAG分野の自動化ワークフローで、18個のノードを含みます。主にGoogleDrive, ManualTrigger, Agent, ExtractFromFile, ChatTriggerなどのノードを使用。 RAG搭載AIチャットボット:OpenAIとCohereリランカー

前提条件
  • Google Drive API認証情報
  • OpenAI API Key
  • Supabase URL と API Key
ワークフロープレビュー
ノード接続関係を可視化、ズームとパンをサポート
ワークフローをエクスポート
以下のJSON設定をn8nにインポートして、このワークフローを使用できます
{
  "meta": {
    "instanceId": "6052a1b29f061469e8139dae44556603650099c3365d7598798f132ae827fa1c"
  },
  "nodes": [
    {
      "id": "a8afd8c2-2bfd-49f3-9687-0d68c83db4ad",
      "name": "チャットインターフェース",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        80,
        100
      ],
      "webhookId": "de210796-2512-4c20-97eb-87b7f05298cb",
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "00c21cda-1193-4cf5-9681-bf21ac2b269c",
      "name": "RAGエージェント",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        300,
        100
      ],
      "parameters": {
        "options": {
          "systemMessage": "You are an intelligent assistant with access to a knowledge base. Always search for relevant information before answering questions. Be helpful, accurate, and cite your sources when providing information from the knowledge base."
        }
      },
      "typeVersion": 2
    },
    {
      "id": "c74d3fac-14ef-4809-b290-d0344db04c79",
      "name": "AIモデル (OpenAI)",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        180,
        320
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4-mini"
        },
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "e8a473c1-4934-491b-8283-80d48982d604",
      "name": "検索エンベディング",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        540,
        460
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "6fc17058-70f2-4bbe-a8b5-e35116f14853",
      "name": "会話メモリ",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        340,
        320
      ],
      "parameters": {
        "contextWindowLength": 10
      },
      "typeVersion": 1.3
    },
    {
      "id": "ba366390-61e3-4a25-8008-fb172145486a",
      "name": "ドキュメント読み込みトリガー",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        100,
        760
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "f97d305b-3a96-445c-ace2-535c60055a4f",
      "name": "ドライブからのPDFダウンロード",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        320,
        760
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "url",
          "value": "{{GOOGLE_DRIVE_FILE_URL}}"
        },
        "options": {},
        "operation": "download"
      },
      "typeVersion": 3
    },
    {
      "id": "9eec6cb6-f445-4add-8de9-1464b61dfa7a",
      "name": "ドキュメントエンベディング",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        700,
        960
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.2
    },
    {
      "id": "e64b2357-0238-45ca-87bd-10f8deddd6e4",
      "name": "ドキュメントテキスト処理",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        840,
        960
      ],
      "parameters": {
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "source",
                "value": "={{ $node['Download PDF from Drive'].json.name }}"
              },
              {
                "name": "type",
                "value": "pdf"
              }
            ]
          }
        },
        "jsonData": "={{ $json.text }}",
        "jsonMode": "expressionData"
      },
      "typeVersion": 1.1
    },
    {
      "id": "8b0645f9-dbcb-4613-9126-9efa824615bc",
      "name": "ナレッジベース検索",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        540,
        320
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "topK": 10,
        "options": {
          "queryName": "{{MATCH_FUNCTION_NAME}}"
        },
        "tableName": {
          "__rl": true,
          "mode": "id",
          "value": "{{VECTOR_TABLE_NAME}}"
        },
        "useReranker": true,
        "toolDescription": "Use this tool to search for information in the knowledge base. Always use this before answering questions to ensure accurate, up-to-date responses."
      },
      "credentials": {
        "supabaseApi": {
          "id": "PgMEWpeDY6PHLFXp",
          "name": "Supabase Zenithon Suporte IA"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "4cb8869a-de07-44f5-8f79-9b3c1207d21c",
      "name": "ベクトルデータベース保存",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreSupabase",
      "position": [
        700,
        760
      ],
      "parameters": {
        "mode": "insert",
        "options": {
          "queryName": "{{MATCH_FUNCTION_NAME}}"
        },
        "tableName": {
          "__rl": true,
          "mode": "id",
          "value": "{{VECTOR_TABLE_NAME}}"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "c8d8674d-ebe7-42fa-918e-ea9c5dc56b98",
      "name": "PDFコンテンツ抽出",
      "type": "n8n-nodes-base.extractFromFile",
      "position": [
        500,
        760
      ],
      "parameters": {
        "options": {
          "maxPages": 500
        },
        "operation": "pdf"
      },
      "typeVersion": 1
    },
    {
      "id": "c5af8b70-bbda-4138-9598-dfd6c44a0eb5",
      "name": "Cohereリランカー",
      "type": "@n8n/n8n-nodes-langchain.rerankerCohere",
      "position": [
        700,
        460
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c3af22b6-830c-43a6-9a8f-0f38f3dec647",
      "name": "注記: チャットトリガー",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        20,
        -40
      ],
      "parameters": {
        "color": 5,
        "width": 200,
        "height": 120,
        "content": "### 1️⃣ Chat Trigger\nReceives messages from users through the chat interface"
      },
      "typeVersion": 1
    },
    {
      "id": "c3655d77-d3ee-4c21-8166-da08b15175d3",
      "name": "注記: RAGエージェント",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        300,
        -40
      ],
      "parameters": {
        "color": 5,
        "width": 200,
        "height": 120,
        "content": "### 2️⃣ RAG Agent\nOrchestrates the conversation using tools and memory"
      },
      "typeVersion": 1
    },
    {
      "id": "ba9f02ea-6def-433a-9ccc-6f0ec1a1792b",
      "name": "注記: ナレッジ検索",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        560,
        180
      ],
      "parameters": {
        "color": 5,
        "width": 200,
        "height": 100,
        "content": "### 3️⃣ Knowledge Search\nSearches the vector database for relevant information"
      },
      "typeVersion": 1
    },
    {
      "id": "ba558d29-fa87-4a2d-a63f-64a768bb2efb",
      "name": "注記: リランカー",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        820,
        440
      ],
      "parameters": {
        "color": 5,
        "width": 200,
        "height": 100,
        "content": "### 4️⃣ Reranker\nImproves search quality by reordering results"
      },
      "typeVersion": 1
    },
    {
      "id": "0ff39f38-d67e-4517-8f5b-834c032383dd",
      "name": "注記: 設定",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        880,
        0
      ],
      "parameters": {
        "color": 4,
        "width": 260,
        "height": 180,
        "content": "### Configuration Variables\n\nReplace these in the workflow:\n- **GOOGLE_DRIVE_FILE_URL**\n- **VECTOR_TABLE_NAME**\n- **MATCH_FUNCTION_NAME**"
      },
      "typeVersion": 1
    }
  ],
  "pinData": {},
  "connections": {
    "a8afd8c2-2bfd-49f3-9687-0d68c83db4ad": {
      "main": [
        [
          {
            "node": "00c21cda-1193-4cf5-9681-bf21ac2b269c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "c5af8b70-bbda-4138-9598-dfd6c44a0eb5": {
      "ai_reranker": [
        [
          {
            "node": "8b0645f9-dbcb-4613-9126-9efa824615bc",
            "type": "ai_reranker",
            "index": 0
          }
        ]
      ]
    },
    "c74d3fac-14ef-4809-b290-d0344db04c79": {
      "ai_languageModel": [
        [
          {
            "node": "00c21cda-1193-4cf5-9681-bf21ac2b269c",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "e8a473c1-4934-491b-8283-80d48982d604": {
      "ai_embedding": [
        [
          {
            "node": "8b0645f9-dbcb-4613-9126-9efa824615bc",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "6fc17058-70f2-4bbe-a8b5-e35116f14853": {
      "ai_memory": [
        [
          {
            "node": "00c21cda-1193-4cf5-9681-bf21ac2b269c",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "9eec6cb6-f445-4add-8de9-1464b61dfa7a": {
      "ai_embedding": [
        [
          {
            "node": "4cb8869a-de07-44f5-8f79-9b3c1207d21c",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "c8d8674d-ebe7-42fa-918e-ea9c5dc56b98": {
      "main": [
        [
          {
            "node": "4cb8869a-de07-44f5-8f79-9b3c1207d21c",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "8b0645f9-dbcb-4613-9126-9efa824615bc": {
      "ai_tool": [
        [
          {
            "node": "00c21cda-1193-4cf5-9681-bf21ac2b269c",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "e64b2357-0238-45ca-87bd-10f8deddd6e4": {
      "ai_document": [
        [
          {
            "node": "4cb8869a-de07-44f5-8f79-9b3c1207d21c",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "ba366390-61e3-4a25-8008-fb172145486a": {
      "main": [
        [
          {
            "node": "f97d305b-3a96-445c-ace2-535c60055a4f",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "f97d305b-3a96-445c-ace2-535c60055a4f": {
      "main": [
        [
          {
            "node": "c8d8674d-ebe7-42fa-918e-ea9c5dc56b98",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
よくある質問

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

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

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

上級 - 内部Wiki, AI RAG検索拡張

有料ですか?

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

関連ワークフロー

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

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

外部リンク
n8n.ioで表示

このワークフローを共有

カテゴリー

カテゴリー: 34