Automate Document Q&A with n8n, OpenAI & Supabase

Save hours of manual research by automating Q&A on your documents using n8n with OpenAI embeddings and Supabase vector DB. This workflow enables precise info retrieval from any text file effortlessly.
googleDrive
lmChatOpenAi
vectorStoreSupabase
+9
Workflow Identifier: 2081
NODES in Use: googleDrive, documentDefaultDataLoader, chainRetrievalQa, lmChatOpenAi, retrieverVectorStore, textSplitterRecursiveCharacterTextSplitter, vectorStoreSupabase, embeddingsOpenAi, set, chatTrigger, supabase, stickyNote
Automate Q&A with n8n and OpenAI

Press CTRL+F5 if the workflow didn't load.

Learn how to Build this Workflow with AI:

What This Automation Does

This workflow downloads documents from Google Drive, turns their content into small text pieces, makes special vectors using OpenAI, saves those vectors in Supabase, then answers your questions quickly by searching these vectors.

It helps stop wasting hours manually looking through many files and gives fast, clear answers.

Input files are ePub documents from Google Drive links. The workflow splits these into chunks, creates semantic embeddings, stores them in a vector database, and lets users chat to get specific info from the documents.

The final answer is generated using OpenAI’s chat model after finding the most relevant text parts.


Tools and Services Used


Who Should Use This Workflow

This workflow is useful for anyone who needs to search large sets of documents quickly.

It suits teams with many ebooks or PDFs in Google Drive who want to ask questions and get fast, accurate answers without manual reading.


Step-by-Step Guide to Use This Workflow in n8n

Download and Import

  1. Open this page and click the Download button to get the workflow file.
  2. Go to your n8n editor where you work on automation.
  3. Find the option Import from File and select the downloaded workflow file to load it.

Configure Credentials and Settings

  1. Enter Google Drive credentials so workflow can access and download your files.
  2. Insert your OpenAI API Key to allow embedding generation and chat answers.
  3. Provide Supabase project details including URL, API Key, and ensure the vector table (like Kadampa) is correct.
  4. If needed, update Google Drive file IDs, folders, or Supabase table names to match your data.

Test the Workflow

  1. Run the workflow once with a sample document to check if downloading, text splitting, embedding, and storage succeed.
  2. Use the chat trigger to send a test question and verify a proper answer is returned.

Activate for Production Use

  1. Enable the When chat message received trigger node to listen for real queries publicly.
  2. Share the webhook URL to allow users to interact.
  3. Monitor workflow runs to quickly spot and fix issues.

If running self hosting n8n, consider resources and access controls for production use.


Detailed Workflow Inputs, Processing, and Outputs

Inputs

  • Google Drive file URLs to download.
  • User chat questions sent to the webhook trigger.

Processing Steps

  • Download file binary data from Google Drive.
  • Load ePub text content from file.
  • Split text into small chunks using recursive character splitter.
  • Create vector embeddings for text chunks with OpenAI text-embedding-3-small model.
  • Insert embeddings and metadata into Supabase vector table for efficient search.
  • Embed chat queries and retrieve best matching document chunks from Supabase.
  • Use OpenAI Chat model to make conversational answers based on retrieved text.
  • Output answer text to chat response.

Outputs

  • Fast, relevant answers to questions about the documents.
  • Stored document embeddings for future search queries.

Common Troubles and How to Fix Them

  • Google Drive download fails
    Cause: Incorrect share link or no access permissions.
    Fix: Use direct file links and check file sharing settings.
  • Supabase insert errors
    Cause: Missing vector extension or wrong table setup.
    Fix: Enable pgvector extension and verify table columns embedding VECTOR(1536), metadata JSONB, and content TEXT.
  • Chat gives unrelated answers
    Cause: Different embedding models for storing and querying or poor retrieval settings.
    Fix: Use the same OpenAI text-embedding-3-small model for both insertion and query. Adjust match document function to correct dimensions.

Customization Ideas

  • Switch the embedding model name in Embeddings OpenAI Insertion and Embeddings OpenAI Retrieval nodes for better speed or accuracy.
  • Change the Supabase vector table name if managing multiple document sets.
  • Edit the welcome message in the When chat message received node for topic-specific greetings.
  • Adjust chunk size or overlap values in the Recursive Character Text Splitter1 for finer text segmentation.
  • Add an HTTP Request node to safely delete stored vectors using Supabase REST API when needed.

Final Summary

✓ Saves hours normally spent on manual document search.
✓ Quickly finds and returns very relevant answers from many files.
✓ Easy to configure and run inside any n8n setup.
✓ Works with Google Drive, OpenAI embeddings, and Supabase vector DB.
✓ Helps teams get info faster and reduce errors from missing documents.

→ Setup brings AI-driven Q&A to your document archives.
→ Workflow can expand to more file types, users, and controls.
→ Enables ongoing, fast document ingestion and querying.


Automate Q&A with n8n and OpenAI

Visit through Desktop to Interact with the Workflow.

Frequently Asked Questions

It uses the Google Drive node to download files via direct file URLs with proper permissions.
The workflow uses OpenAI’s text-embedding-3-small model for generating embeddings.
It embeds the question, retrieves similar document chunks from Supabase, then uses OpenAI chat completion to generate answers.
Ensure the pgvector extension is enabled and the table has correct columns: embedding VECTOR(1536), metadata JSONB, and content TEXT.

Promoted by BULDRR AI

Related Workflows

Automate Twist Channel Creation and Messaging with n8n

This workflow automates creating and updating a channel in Twist and sending a personalized message to specific users. It eliminates manual setup errors and saves time managing Twist communications.

Automate Ideogram Image Generation with Google Sheets & Gmail

This workflow automates graphic design image generation via Ideogram AI, storing image data in Google Sheets and Google Drive, with email alerts via Gmail. It saves designers hours by automating image creation, remixing, review, and record-keeping.

Automate IT Support with Slack and OpenAI in n8n

Streamline IT support by automating Slack message handling using n8n and OpenAI. This workflow handles Slack DMs, filters bots, queries a Confluence knowledge base, and delivers AI-generated responses, improving support efficiency and response time.

Automate Crypto Analysis with CoinMarketCap & n8n AI Agent

Discover how this unique n8n workflow leverages CoinMarketCap’s multi-agent AI to deliver precise, real-time cryptocurrency insights directly via Telegram. Manage crypto data analysis efficiently with automated multi-source API integration.

Automate Gumroad to Beehiiv Subscriber Sync with n8n

Learn how to automatically add new Gumroad sales customers as Beehiiv newsletter subscribers using n8n automation. This workflow saves time by syncing sales data to Google Sheets CRM and notifying your Telegram channel instantly.

Generate On-Brand Blog Articles Using n8n and OpenAI

This workflow automates the creation of on-brand blog articles by analyzing existing company content using n8n and OpenAI. It extracts article structures and brand voice to produce consistent draft articles, saving significant content creation time.
1:1 Free Strategy Session
Your competitors are already automating. Are you still paying for it manually?

Do you want to adopt AI Automation?

Every hour your team does repetitive work, you're burning real money.
While you wait, faster businesses are cutting costs and moving quicker.
AI and automations aren't the future anymore — they're the present.

Book a live 1-on-1 session where we show you exactly which of your daily tasks can be automated — and what it’s costing you not to.