Animated data flow diagram

AI Document Q&A Agent with n8n, OpenAI & Qdrant

Version: 1.0.0 | Last Updated: 2025-05-16

Integrates with:

OpenAI Qdrant Google Drive Langchain

Overview

Unlock Instant Answers from Your Documents with this AI Agent

This n8n workflow transforms into a powerful AI Document Q&A Agent. It's designed in two parts: first, it ingests a PDF document from Google Drive, processes its content by splitting it into manageable chunks, generates embeddings using OpenAI, and stores these in a Qdrant vector database. This creates a searchable knowledge base. The second part provides a webhook endpoint. When you send a question (and specify the target document collection) to this endpoint, the agent uses AI to retrieve relevant information from the Qdrant store and an OpenAI chat model to generate a coherent answer. This empowers you to quickly get insights from your documents without manual sifting.

Key Features & Benefits

  • Automated Document Ingestion: Fetches PDFs from Google Drive, processes, and indexes them into a Qdrant vector store.
  • AI-Powered Semantic Search: Leverages OpenAI embeddings for intelligent search within your documents, finding answers based on meaning, not just keywords.
  • Natural Language Q&A: Utilizes OpenAI's chat models (e.g., GPT-3.5-turbo, GPT-4) to understand questions and generate human-like answers based on document content.
  • Dynamic Collection Querying: Allows querying different document collections in Qdrant by specifying a 'company' (or collection identifier) in the webhook request.
  • Webhook Integration: Easily integrate the Q&A functionality into your applications, chatbots, or internal tools.
  • Langchain Powered: Built using Langchain components within n8n for robust retrieval-augmented generation (RAG).

Use Cases

  • B2C E-commerce: Automate customer support by enabling instant answers to product-related questions from user manuals or FAQs ingested by the agent.
  • B2B SaaS: Empower sales teams with quick access to information from extensive product documentation or case studies during client calls.
  • Founders/CTOs: Quickly query research papers, technical specifications, or legal documents without manual searching, speeding up decision-making.
  • Heads of Automation: Streamline internal support by creating a Q&A system for company policies, onboarding materials, or internal knowledge bases.

Prerequisites

  • An n8n instance (Cloud or self-hosted).
  • OpenAI API Key with access to embedding models (e.g., text-embedding-ada-002) and chat models (e.g., gpt-3.5-turbo or gpt-4).
  • Qdrant instance (Cloud or self-hosted) URL and API Key (if required by your Qdrant setup).
  • Google Drive credentials and a PDF document accessible by the Google Drive node.

Setup Instructions

  1. Download the n8n workflow JSON file.
  2. Import the workflow into your n8n instance.
  3. Configure Credentials:
    • In the 'Embeddings OpenAI' node (for ingestion), 'Embeddings OpenAI1' node (for Q&A), and 'OpenAI Chat Model' node, select or create your OpenAI API credentials.
    • In the 'Qdrant Vector Store' node (for ingestion) and 'Qdrant Vector Store1' node (for Q&A), select or create your Qdrant API credentials, providing the URL and API Key if needed.
    • In the 'Google Drive' node, select or create your Google Drive credentials.
  4. Part 1: Document Ingestion (Manual Trigger - 'When clicking "Execute Workflow"'):
    • Select the 'Google Drive' node. In its parameters, specify the File ID of the PDF document you want to ingest (e.g., the example uses '1LZezppYrWpMStr4qJXtoIX-Dwzvgehll' for 'crowdstrike.pdf').
    • Select the 'Qdrant Vector Store' node (connected to 'Google Drive'). In its parameters, set the Qdrant Collection field under qdrantCollection to a unique name for this document's embeddings (e.g., crowd as in the example, or yourcompany_doc_v1). Remember this name.
    • Optionally, adjust chunking parameters in the 'Recursive Character Text Splitter' node if needed.
    • Manually execute the workflow using the 'Execute Workflow' button for the 'When clicking "Execute Workflow"' trigger. This will process and store your document in Qdrant.
  5. Part 2: Q&A Setup (Webhook - 'Webhook1'):
    • The 'Qdrant Vector Store1' node (used in the Q&A flow) is configured to get the collection name dynamically from the webhook request body: {{ $json.body.company }}. This means your webhook request must include this field.
    • Verify the 'OpenAI Chat Model' node is configured with your desired model (e.g., gpt-3.5-turbo).
    • Copy the 'TEST URL' from the 'Webhook1' node. This is your Q&A endpoint.
  6. Ask Questions:
    • Send a POST request to the copied Webhook URL.
    • The request body must be JSON and include two fields: input (your question) and company (the Qdrant collection name you set in step 4.b, e.g., "crowd").
    • Example JSON body: { "input": "What are the key features of CrowdStrike?", "company": "crowd" }
  7. Activate the workflow in n8n to ensure the webhook is live and ready to receive requests.

Tags:

AI AgentOpenAIQdrantDocument Q&AKnowledge BaseNLPAutomationLangchainRAG

Want your own unique AI agent?

Talk to us - we know how to build custom AI agents for your specific needs.

Schedule a Consultation