Build a Knowledge Base Chatbot using Jotform, RAG, and Gemini - n8n Workflow

Deploy a robust RAG knowledge base chatbot using this advanced n8n workflow. Integrates Jotform document uploads, Supabase vector DB, Together AI embeddings, and Google Gemini for precise Q&A.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Automation developers looking for advanced n8n templates integrating vector databases.
Businesses needing an automated way to turn uploaded documents (via Jotform) into searchable knowledge bases.
Support teams aiming to deploy a highly accurate, context-aware chatbot using Google Gemini and Together AI.
Users looking for a production-ready RAG system implemented using an n8n workflow.

Overview

This comprehensive n8n workflow is designed to create, maintain, and interact with a Retrieval-Augmented Generation (RAG) knowledge base. It solves the common problem of grounding Large Language Models (LLMs) in specific, internal documentation, drastically reducing hallucinations. The process is divided into two parts: document ingestion and real-time chat.

By leveraging the JotForm n8n trigger for uploads, Together AI for high-quality embeddings, Supabase for vector storage, and the powerful Google Gemini model via an n8n node, this solution offers a seamless and highly accurate way to answer user queries based solely on your uploaded source material. This specific n8n workflow demonstrates best practices for building scalable AI automation and utilizing powerful n8n templates.

How it Works

This n8n workflow operates in two distinct logical branches, orchestrated by different n8n triggers:

A. Knowledge Base Ingestion (Librarian Mode)


  1. JotForm Trigger: The n8n workflow initiates when a new file submission is received via the JotForm n8n trigger node.

  2. Document Retrieval: Subsequent HTTP Request n8n nodes download the submission details and the actual PDF document linked in the form.

  3. Extraction and Chunking: The Extract Text from PDF File n8n node converts the PDF into raw text. A custom Code n8n node, "Splitting into Chunks," divides this text into manageable 1000-character segments.

  4. Embedding Generation: Each text chunk is sent to the Together AI API via an HTTP Request n8n node, using the BAAI/bge-large-en-v1.5 model to generate semantic embeddings.

  5. Storage: The final Supabase n8n node saves the original text chunk and its corresponding embedding vector into the RAG table, completing the knowledge ingestion process of this n8n workflow.

B. Real-Time Chat Query (Researcher Mode)


  1. Chat Trigger: The process starts when a user sends a message, activating the specialized Chat Trigger n8n node, which acts as the n8n trigger for the query flow.

  2. Query Embedding: The user's chatInput is sent to Together AI to generate a semantic embedding for the query, using the same model.

  3. Vector Search: An HTTP Request n8n node interacts with the Supabase database to execute a Remote Procedure Call (RPC) named matchembeddings1. This function uses the query embedding to find the top 5 most relevant stored text chunks (RAG context).

  4. Context Aggregation: The Aggregate n8n node collects the retrieved chunks into a single context block.

  5. AI Response Generation: The AI Agent n8n node receives the user query, the aggregated context, and a specific system prompt instructing it to act as a helpful support agent.

  6. LLM Execution: The AI Agent utilizes the Google Gemini Chat Model n8n node to generate a friendly, constrained response based only on the provided context. This ensures accuracy and relevant output from the n8n workflow, leveraging the power of n8n templates for advanced AI tasks.

Installation Guide


  1. Import: Copy the provided n8n workflow JSON data and paste it directly into your n8n instance using the "Import from JSON" feature.

  2. Credentials Setup:

Together AI: Set up a Generic Credential Type (HTTP Bearer Auth) for Together AI API access, needed by the embedding n8n nodes.
Supabase: Configure a Supabase API credential. This is required for saving embeddings and the vector search. Ensure your Supabase RAG table and matchembeddings1 RPC function are correctly configured for vector search.
JotForm: Create a JotForm API credential and update the form ID in the "JotForm Trigger" n8n trigger.
Google Gemini: Set up the Google Gemini API credentials for the Google Gemini Chat Model n8n node.

  1. Configuration: Update the API keys and URLs within the "Grab New knowledgebase" n8n node and the "Search Embeddings" n8n node (replace placeholders like enter-your-supabase-host and API key placeholders).

  2. Activation: Ensure both the "JotForm Trigger" and the "When chat message received" n8n trigger nodes are active to manage both ingestion and query processes in this n8n workflow.

Node Details

JotForm Trigger (n8n trigger):
Function: Starts the knowledge ingestion process upon a new file submission.
Key Configuration: Configured to watch a specific form ID.
Extract Text from PDF File (n8n node):
Function: Converts the downloaded binary PDF file into extractable raw text, preparing it for RAG processing.
Splitting into Chunks (Code n8n node):
Function: A custom n8n node that splits the extracted text into 1000-character chunks, necessary for effective embedding and vector search.
Embedding Uploaded document / Embend User Message (HTTP Request n8n nodes):
Function: Sends text (document chunk or user query) to Together AI for embedding generation using the BAAI/bge-large-en-v1.5 model.
Save the embedding in DB (Supabase n8n node):
Function: Stores the text chunk and its generated embedding vector in the Supabase RAG table.
When chat message received (Chat Trigger n8n trigger):
Function: Initializes the chat response process when a user sends a query, serving as the main n8n trigger for the chat portion of the n8n workflow.
Search Embeddings (HTTP Request n8n node):
Function: Executes a vector similarity search in Supabase by calling the matchembeddings1 RPC, retrieving the top 5 most relevant document chunks.
AI Agent (Langchain n8n node):
Function: Orchestrates the final response generation. It combines the retrieved context, the user query, and a strict system prompt to ensure the LLM stays on topic and follows formatting rules.
Google Gemini Chat Model (Langchain n8n node):
* Function: The Large Language Model utilized by the AI Agent to generate the final, context-grounded response for the user. This is a critical n8n node in the generation phase.

Related n8n Workflows

Free

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

Featured*