AI Exam Question Generator from Google Docs using RAG - n8n Workflow

Use this comprehensive n8n workflow to automate exam question creation. Extracts content from Google Docs, uses Qdrant for RAG, and leverages Google Gemini to generate structured open and closed questions.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

• Educators, teachers, or trainers needing to quickly create assessments.
• Content developers requiring automated quiz generation from source material.
• n8n specialists interested in advanced Retrieval-Augmented Generation (RAG) implementation.
• Users seeking practical n8n templates for AI and document processing.

Overview

Creating high-quality, comprehensive exam questions that align perfectly with source material is time-consuming. This powerful n8n workflow eliminates hours of manual effort by automating the entire assessment creation lifecycle. It starts by extracting raw content from a Google Doc. This content is then prepared and vectorized using OpenAI Embeddings and stored in the Qdrant Vector Store, creating a reliable RAG knowledge base. The core of this n8n workflow involves two parallel AI chains powered by Google Gemini: one generating open-ended questions with definitive answers, and the other generating multiple-choice questions with guaranteed correct options and plausible distractors. Every step, from document parsing via a custom n8n node to final structured output in Google Sheets, demonstrates the power of orchestrated AI automation.

How it Works

This n8n workflow executes a multi-stage process, initiated by the manual n8n trigger:


  1. Preparation and Ingestion: The workflow first runs an HTTP Request to Refresh collection, clearing the Qdrant vector store collection to ensure a clean index. It then uses the Google Docs n8n node to fetch the target document.

  2. Conversion and Chunking: A custom Code n8n node (Converto di MD) converts the document’s complex JSON structure into clean Markdown. The Convert to File n8n node prepares this data, which is then split into chunks by the Token Splitter and vectorized using the Embeddings OpenAI n8n node. These vectors are inserted into the Qdrant Vector Store, establishing the RAG context.

  3. Open Question Generation (Q&A): The Open questions LLM Chain uses Google Gemini to generate 10 open-ended questions based on the full article text. A Loop Over Items n8n node processes these questions individually. For each, the Answer questions Retrieval QA Chain utilizes the RAG mechanism (Qdrant + Gemini Pro) to find and formulate the definitive answer, which is appended to the Google Sheets n8n node called Write open.

  4. Closed Question Generation (Multiple-Choice): In parallel, the Closed questions LLM Chain generates 10 multiple-choice questions (stems and options A-D, without the key). The Loop Over Items1 n8n node iterates through these. The subsequent AI Agent (Answer and create options) uses the RAG tool and a Structured Output Parser n8n node to ensure accuracy, generating four options and explicitly identifying the correct one. This structured data is finally recorded by the Write closed Google Sheets n8n node.

Installation Guide

To set up this advanced n8n workflow, follow these steps:


  1. Import: Import the provided n8n workflow JSON into your n8n instance.

  2. Credentials Setup: You must configure the following credentials for the respective n8n node operations:

Google Docs OAuth2 API: To allow the Get Doc n8n node to read your document.
Qdrant API: Required for connecting the Qdrant Vector Store and HTTP Request nodes (collection management). Note: You must replace QDRANT_URL and COLLECTIONS placeholders in the HTTP Request nodes with your actual Qdrant instance details and collection name.
OpenAI API: Needed for the Embeddings OpenAI n8n node to generate vector embeddings.
Google Gemini (PaLM) API: Required for all Large Language Model (LLM) Chain n8n node operations.
* Google Sheets OAuth2 API: To allow the workflow to write the final questions and answers into your designated spreadsheet. Update the Sheet ID and names in the Write open and Write closed n8n node settings.

  1. Document Configuration: In the Get Doc n8n node, replace the placeholder XXXXXXXXXXXXXXXX with the URL of the Google Doc you want to analyze.

  2. Testing: Execute the n8n workflow using the When clicking ‘Test workflow’ n8n trigger to verify the connection and data flow.

Node Details

When clicking ‘Test workflow’ (Manual Trigger n8n trigger): Initiates the flow execution manually.
Get Doc (Google Docs n8n node): Fetches the content of the specified Google Document, acting as the primary source material.
Converto di MD (Code n8n node): Custom JavaScript code that converts the raw Google Doc content into Markdown, preparing it for AI analysis and RAG ingestion. This is a crucial n8n node for data preprocessing.
Qdrant Vector Store (n8n node): Handles the storage and retrieval of vector embeddings, enabling RAG. Configured to insert data into the aiarticletest collection using Embeddings OpenAI.
Open questions & Closed questions (LLM Chain n8n nodes): Uses the Google Gemini Chat Model (Flash) with highly detailed system prompts to structure and generate 10 open and 10 closed questions directly from the article's Markdown content.
Loop Over Items (Split In Batches n8n node): Iterates over the questions generated by the LLM Chains to process them individually in subsequent steps.
Answer questions (Retrieval QA Chain n8n node): Utilizes the RAG pattern to look up context in Qdrant and generate precise answers for the open questions using the Google Gemini Chat Model1 (Pro).
Answer and create options (Agent n8n node): A sophisticated LangChain agent that uses the RAG tool to verify the correct answer for multiple-choice questions and structure the output using the Structured Output Parser n8n node.


  • Write open / Write closed (Google Sheets n8n node): Appends the final, structured questions and answers to the configured Google Sheet tabs, completing the n8n workflow automation.

Related n8n Workflows

Free

Nodes: 20 Nodes
Updated: December 26 2025
View all
Created by

Full-stack Web Developer based in Italy specialising in Marketing & AI-powered automations. For business enquiries, send me an email at [email protected] or add me on Linkedin.com/in/davideboizza

Featured*