ChatGPTWorkDocumentsAI score · PendingAI-assisted edit · no obvious prompt-injection riskn8n.io

n8n RAG Document Chatbot: Google Drive + Gemini + Qdrant

Auto-chunk, embed, and store Google Drive documents in Qdrant, then converse via a Gemini-powered AI Agent with retrieval augmentation

ExperiencedStepsWorkflowPrompt
Who
Operators or developers who need to build a Q&A bot over private document repositories
You get
Documents from a Google Drive folder are processed and stored in a vector database; users get answers through a chat interface grounded in retrieved context
You need
n8n · google-drive · qdrant · gemini · telegram · google-docs

Constraints

Prerequisites: accessible n8n instance; configured credentials for googleDriveOAuth2Api, googleDocsOAuth2Api, googlePalmApi (Gemini), openAiApi (embeddings and delete node), qdrantApi, telegramApi. Prepare a Google Drive folder ID, Qdrant collection name, and Telegram Chat ID environment variable. Note: some nodes retain stale Nostr-specific hardcoded names that should be updated for a document-centric use case.

What they did

Author joe published a dual-branch workflow on the n8n template gallery: Branch one pulls documents from Google Drive via manual trigger or Webhook, extracts metadata with Gemini, embeds with OpenAI, and writes to Qdrant. Branch two receives user messages via Chat Trigger, and a Gemini-powered AI Agent calls a Qdrant retrieval tool to generate grounded answers, logging history to Google Docs. A separate Telegram-confirmed vector deletion branch is also included.

How it went

The template has 86,580 views on n8n.io (author_report). Document processing, RAG retrieval, chat memory, Telegram notifications, and human-in-the-loop deletion are all configured at the node level.

Worth knowing

The AI Agent's systemMessage and Qdrant tool name are hardcoded to a Nostr/Damus scenario ('nostr_damus_user_profiles'), inconsistent with the Google Drive document chatbot described in the template title—manual update required after import. The Qdrant collection name is similarly hardcoded to 'nostr-damus-user-profiles'. The OpenAI Chat Model (gpt-4o-mini) node is disabled in workflow.json; actual chat uses Gemini. The Google Docs node contains a placeholder '1ej_YOUR_AWS_SECRET_KEY_HERE' that is actually a Google Docs ID placeholder. Webhook and Google Drive createFromText nodes are also disabled. The deletion script defaults to Qdrant at localhost:6333, which must be changed for production.

n8n workflow template

Structure checked · Not run-tested

Use “Import from File” in n8n, or copy the JSON and paste it into the editor. Connect your own accounts, then try test data. The template is inactive by default.

Setup and test checklist

Credentials to connect

  • Qdrant Vector Store node: connect qdrantApi credentials.
  • Google Gemini Chat Model node: connect Google Gemini/PaLM API credentials.
  • Download File From Google Drive node: connect Google Drive OAuth2 credentials.
  • Find File Ids in Google Drive Folder node: connect Google Drive OAuth2 credentials.
  • text-embeddings-3-large node: connect OpenAI API credentials.
  • gpt-4o-mini1 node: connect OpenAI API credentials.
  • Confirm Qdrant Delete Points node: connect Telegram API credentials.
  • Send Declined Message node: connect Telegram API credentials.
  • Google Gemini Chat Model1 node: connect Google Gemini/PaLM API credentials.
  • text-embeddings-3-large1 node: connect OpenAI API credentials.
  • Google Drive node: connect Google Drive OAuth2 credentials.
  • Update Chat History node: connect googleDocsOAuth2Api credentials.
  • Qdrant Vector Store Tool node: connect qdrantApi credentials.
  • OpenAI Chat Model node: connect OpenAI API credentials.
  • Send Completed Message node: connect Telegram API credentials.

Configuration to replace

  • Source template is n8n public workflow #2982 (~50 nodes). Keep inactive after import; verify triggers, expressions and external API endpoints.
  • Sticky-note guidance is informational; replace placeholders with your own accounts, sheet schemas or channel IDs.

Test input and expected output

  • Manually run the main path once in a test workspace and confirm credentialed nodes authenticate without errors.
  • Drive one synthetic/redacted sample through and check output fields and downstream writes before enabling in production.

Template changes

  • Author credential bindings, webhookId and execution data are removed; the workflow is inactive. Nodes, connections and original prompts are preserved. Not run-tested in n8n.
  • No business-logic edits; verify keys, quotas and privacy compliance before use.

Template retrieved: 2026-10-25

Steps

  1. Configure API Credentials

    Create and link the following credentials in n8n: Google Drive OAuth2, Google Docs OAuth2, Google Gemini (googlePalmApi), OpenAI API (for text-embedding-3-large and the delete script), Qdrant API, and Telegram Bot. Enter the OpenAI API Key in the 'Delete Qdrant Points by File ID' code node configuration.

  2. Configure Document Sources and Collection

    Enter the target Google Drive folder ID in the 'Google Folder ID' node. Define the collection name in the 'Qdrant Collection Name' node (currently hardcoded as 'nostr-damus-user-profiles' in the template; update to match your document scenario).

  3. Batch Retrieve and Download Documents

    Run the 'Find File Ids in Google Drive Folder' node to list files, aggregate via 'File Id List', then process in batches through 'Loop Over Items'. Each batch is downloaded via 'Download File From Google Drive' as binary data.

  4. Extract Metadata and Split

    'Get File Contents' converts files to text, then 'Extract Meta Data' uses Gemini to extract structured attributes (theme, pain points, keywords, etc.). 'Token Splitter' chunks at chunkSize=3000, and 'Data Loader' attaches extracted metadata to document metadata.

    Execution prompt · Source text。Extract Meta Data node's systemPromptTemplate field

    You are an expert extraction algorithm.
    Only extract relevant information from the text.
    If you do not know the value of an attribute asked to extract, you may omit the attribute's value.
  5. Embed and Write to Qdrant

    'text-embeddings-3-large' generates vectors, which are written with chunked documents via 'Qdrant Vector Store' in insert mode. A 'Wait' node paces batch processing, and 'Send Completed Message' notifies via Telegram.

  6. Start the Chat Trigger

    Enable the 'When chat message received' Chat Trigger node as the conversation entry point. It passes user input to the AI Agent.

  7. RAG Conversation and History Logging

    The 'AI Agent' calls 'Qdrant Vector Store Tool' in retrieve-as-tool mode (topK=20) to fetch relevant snippets, then generates answers via 'Google Gemini Chat Model1'. 'Window Buffer Memory' maintains a 40-turn context window. Final output returns through 'Respond to User', while 'Update Chat History' appends Q&A to a Google Doc.

    Execution prompt · Source text。AI Agent node's systemMessage field (promptType=define)

    =You are an intelligent assistant specialized in answering user questions using Nostr user profiles. Your primary goal is to provide precise, contextually relevant, and concise answers based on the tools and resources available.
    
    ### TOOL
    Use the "nostr_damus_user_profiles" tool to:
    - perform semantic similarity searches and retrieve information from Nostr user profiles relevant to the user's query.
    - access detailed information about Nostr and/or Damus users when additional context or specifics are required.
    
    ### Key Instructions
    1. **Response Guidelines**:
       - Clearly explain how the retrieved information addresses the user's query, if applicable.
       - If no relevant information is found, respond with: "I cannot find the answer in the available resources."
    
    2. **Focus and Relevance**:
       - Ensure all responses are directly aligned with the user's question.
       - Avoid including extraneous details or relying solely on internal knowledge.
  8. Secure Vector Deletion (Optional)

    To clean up data, run the deletion branch: 'Confirm Qdrant Delete Points' sends a Telegram confirmation request; upon approval, 'Delete Qdrant Points by File ID' executes code to delete vector points matching the file_id. Decline triggers 'Send Declined Message'.

    Execution prompt · Source text。Delete Qdrant Points by File ID code node's execute.code field

    const { QdrantVectorStore } = require("@langchain/qdrant");
    const { OpenAIEmbeddings } = require("@langchain/openai");
    
    // Qdrant connection details
    const url = "http://localhost:6333/";
    const apiKey = "";
    
    // OpenAI API configuration
    const openAIApiKey = "[Your-OpenAI-API-Key]";
    
    // Get input data
    const items = this.getInputData()[0];
    // console.log(items)
    
    const collectionName =  items.json.qdrant_collection_name;
    // console.log(collectionName)
    
    async function deleteDocumentsFromQdrant() {
      try {
        // Initialize OpenAI embeddings
        const embeddings = new OpenAIEmbeddings({
          model: "text-embedding-3-large",
          openAIApiKey: openAIApiKey
        });
    
        // Connect to existing Qdrant collection
        const vectorStore = await QdrantVectorStore.fromExistingCollection(embeddings, {
          url: url,
          apiKey: apiKey,
          collectionName: collectionName,
        });
    
        const fileIds = items.json.appended_id.map(item => item);
    
        console.log(fileIds)
    
        // Delete points by fileId
        const deletionResults = await Promise.all(fileIds.map(async (file_id) => {
          const filter = {
            must: [
              {
                key: "metadata.file_id",
                match: { value: file_id }
              }
            ]
          };
    
          try {
            // Access the underlying Qdrant client to perform the deletion
            await vectorStore.client.delete(collectionName, { filter });
            return { file_id, status: "deleted" };
          } catch (error) {
            console.error(`Error deleting documents for fileId ${file_id}:`, error);
            return { file_id, status: "error", message: error.message };
          }
        }));
    
        return deletionResults;
      } catch (error) {
        console.error("An error occurred during the deletion process:", error);
        return error.message;
      }
    }
    
    // Execute the deletion process
    try {
      const result = await deleteDocumentsFromQdrant();
      console.log("Deletion process completed:", result);
      return [];
    } catch (error) {
      console.error("Failed to execute deletion process:", error);
      return [{ json: { error } }];
    }

Prompt you can copy

Setup guidance · Editorial suggestion。Hand to setup assistant to confirm inputs and permissions first

This block is the prompt. Ads are never placed here.

You are setting up an n8n RAG document chatbot. First confirm these inputs and permissions: 1) Google Drive folder ID and OAuth2 credentials; 2) Qdrant instance URL and API Key; 3) Gemini (googlePalmApi) and OpenAI embedding API Key; 4) Telegram Bot Token and Chat ID; 5) Google Docs document ID for chat history. If importing this template, check whether the AI Agent's systemMessage and Qdrant collection name still contain stale Nostr hardcoding and update them for your document scenario.

After importing the template, prioritize updating hardcoded collection names and Agent role descriptions

Source

🤖 AI powered RAG chatbot for your docs + Google Drive + Gemini + Qdrant · joe · n8n.io · 2025-02-23

Comments & feedback

Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.

Loading…

    Related