IPL Cricket Rules Q&A Chat Bot RAG Implementation - n8n Workflow

Build a cricket rules Q&A bot using this advanced n8n workflow. It combines RAG, Google Gemini, and an n8n trigger for accurate, document-grounded answers.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • AI/ML Developers: Users interested in implementing sophisticated Retrieval-Augmented Generation (RAG) models within the n8n automation framework.

  • Sports Analysts/Journalists: Professionals needing quick, verifiable answers to complex cricket regulations.

  • n8n Automation Specialists: Individuals seeking advanced examples of building conversational AI agents using n8n templates and the n8n workflow structure.

Overview

This powerful n8n workflow demonstrates how to create a highly accurate, document-grounded chatbot, specifically designed here for answering questions about IPL cricket rules. By leveraging the RAG pattern, the chatbot ensures that its responses are strictly limited to the official documentation, preventing common LLM hallucination issues. The implementation uses Google Gemini for both embeddings and the chat model, making this a cutting-edge n8n template. The automation is split into two phases: a one-time setup to ingest and vectorize the knowledge base, and the live chat interface, initiated by an n8n trigger. This structure is essential for anyone looking to build professional, verifiable Q&A systems using n8n.

How it Works

This n8n workflow operates in two distinct steps:

Step 1: Knowledge Base Creation (Run Once)


  1. Data Ingestion: The process starts with the 'When clicking ‘Execute workflow’' n8n trigger, which initiates an HTTP Request to download the official IPL 'Match Playing Conditions' PDF file.

  2. Text Preparation: The Default Data Loader extracts the text from the binary PDF. The Recursive Character Text Splitter then breaks this large document into smaller, overlapping chunks, optimizing them for retrieval.

  3. Vectorization: The Embeddings Google Gemini n8n node converts these text chunks into numerical vector representations.

  4. Storage: The Simple Vector Store (Insert Mode) saves these vectors into an in-memory knowledge base, keyed for later retrieval in Step 2. This preparation ensures the RAG component is ready.

Step 2: Live Chat Q&A


  1. Chat Trigger: The 'When chat message received' n8n trigger activates the workflow when a user interacts with the n8n native chat interface, capturing the user's query.

  2. Context and Memory: The Simple Memory n8n node maintains the last 20 turns of conversation, providing conversational context to the AI Agent.

  3. RAG Retrieval: The Simple Vector Store (Retrieve-as-tool Mode) acts as the RAG tool. It receives the user's query, finds the top 10 most relevant document chunks from the IPL rules, and supplies them to the agent.

  4. Orchestration and Response: The AI Agent n8n node orchestrates the entire process. It utilizes the Google Gemini Chat Model, adhering to a strict system prompt that mandates answering only based on the retrieved documents. This highly configured n8n node delivers the final, accurate response back to the user.

Installation Guide

To deploy this powerful n8n workflow, follow these steps:


  1. Import: Copy the provided n8n workflow JSON code and import it into your n8n instance using the 'New' -> 'Import from JSON' function.

  2. Credentials: You must set up a Google Gemini API credential (often listed as Google Gemini or Google PaLM) within your n8n instance. Both the Embeddings and the Chat Model n8n node components require this API key.

  3. Initialization (Step 1): Locate the 'When clicking ‘Execute workflow’' n8n trigger node. Run the workflow manually once by clicking 'Execute workflow'. This action downloads the PDF, embeds the data, and builds the in-memory vector store.

  4. Activation (Step 2): After Step 1 completes, ensure the main 'When chat message received' n8n trigger is active. Save and activate the entire n8n workflow. The chat bot is now ready to take queries through its dedicated chat endpoint.

Node Details

This n8n workflow relies heavily on specific nodes to manage RAG and conversational flow:

When chat message received (n8n trigger): This specialized n8n trigger listens for incoming messages on the dedicated n8n chat interface, initiating the real-time Q&A process.
HTTP Request: Downloads the IPL rules PDF document from the specified URL (https://documents.iplt20.com/bcci/documents/1742707993986MatchPlaying_Conditions.pdf).
Recursive Character Text Splitter: Configured with an overlap of 200, it prepares the raw text for optimal embedding by segmenting the document intelligently.
Embeddings Google Gemini: This n8n node converts the document chunks into vectors, enabling semantic search and retrieval.
Simple Vector Store (Insert Mode / Retrieve-as-tool Mode): Used in two configurations: first, to insert the vectors (Step 1), and second, to retrieve the top 10 relevant chunks for RAG grounding (Step 2).
Simple Memory: A buffer memory n8n node that maintains the conversation history (last 20 turns), allowing the AI Agent to understand context.
Google Gemini Chat Model: The underlying LLM, configured with parameters like Top P (0.3) for controlling randomness in responses.
AI Agent: The central orchestration n8n node. It is given a system message defining its role as a strict cricket expert, ensuring responses are always based on the data retrieved by the RAG tool. This flexible n8n node manages the complex interaction between the memory, tools, and the LLM.

Related n8n Workflows

Free

Nodes: 11 Nodes
Updated: December 26 2025
View all
Created by
Sidd
Sidd

Featured*