Hybrid RAG Chatbot with Multi-Agent Architecture & Automated Data Pipeline

Was $20 Now $15
Sale

This template creates a sophisticated, multi-agent hybrid RAG (Retrieval-Augmented Generation) chatbot that can handle diverse user queries by routing them to a “Supervisor AI agent”. The Supervisor agent will then send the request to “Expert AI agents”, agents specializing in specific domains. In addition, this system automates data ingestion from various sources (including websites and Google Drive), processes and stores the information in a vector database, and interacts with users through Telegram in multiple languages.

N8N Hybrid RAG Chatbot with Multiple AI Agents

This template creates a sophisticated, multi-agent hybrid RAG (Retrieval-Augmented Generation) chatbot that can handle diverse user queries by routing them to a “Supervisor AI agent”. The Supervisor agent will then send the request to “Expert AI agents”, agents specializing in specific domains. In addition, this system automates data ingestion from various sources (including websites and Google Drive), processes and stores the information in a vector database, and interacts with users through Telegram in multiple languages.

Who’s it for?

This template is ideal for:

  • Developers and Businesses looking to build a powerful, knowledge-based chatbot for customer support, internal knowledge management, or lead generation.
  • AI Enthusiasts who want to explore advanced concepts like multi-agent systems, RAG, and automated data pipelines.
  • n8n Users who want to build a scalable and customizable AI solution that integrates multiple services.

Key Features

  • Multi-Agent Architecture: Utilizes a supervisor agent to route queries to specialized agents for different domains (e.g., Products, News, Academy).
  • Automated Data Ingestion: Automatically scrapes data from websites and syncs new or updated files from Google Drive.
  • Retrieval-Augmented Generation (RAG): Enriches the chatbot’s knowledge by retrieving relevant information from a Supabase vector store and a Postgres database.
  • Telegram Integration: Provides a seamless, multi-language chat interface for users to interact with the bot.
  • Dynamic Data Handling: Automatically processes and embeds data from various sources like Google Docs, PDFs, and Word documents.
  • Data Management: Keeps the knowledge base up-to-date by automatically handling document creation, updates, and deletions.

How it works

The workflow is divided into three main parts: data ingestion, data management, and the chat interface.

  1. Data Ingestion & Processing:
  • Web Scraping: The workflow fetches URLs from a Google Sheet, scrapes the content using Crawl4ai, cleans it with an AI agent, and saves it to a Google Doc.
  • Google Drive Sync: It monitors specific Google Drive folders for new or updated files (Google Docs, PDFs, Word documents).
  • Embedding & Storage: The content from these sources is then chunked, converted into vector embeddings using OpenAI, and stored in a Supabase vector database for efficient retrieval.
  1. Data Deletion:
  • A scheduled trigger periodically checks a Google Sheet for records marked as “deleted.”
  • It then removes the corresponding data from the Supabase vector store and deletes the file from Google Drive to ensure the chatbot’s knowledge remains current.
  1. Chat Interface & Logic (Telegram):
  • User Input: The chatbot receives user messages via a Telegram trigger.
  • Language Detection: It first detects the language of the query and translates it to English if necessary.
  • Supervisor Agent: A central “Supervisor” AI agent analyzes the user’s query.
  • Agent Routing: Based on the query, the Supervisor delegates the task to the most appropriate specialized agent:
  • News AI Agent: Handles questions about current events.
  • Product AI Agent: Answers queries about product details from a Postgres database.
  • Academy AI Agent: Responds to questions about courses and educational content.
  • Response Generation: The selected agent processes the query, retrieves the necessary information using RAG, generates a response, and translates it back to the user’s original language before sending it via Telegram.

Requirements

To use this template, you will need accounts and credentials for the following services:

  • n8n
  • OpenAI
  • Supabase (for vector storage)
  • Google Workspace (Google Drive, Google Sheets, Google Docs)
  • Telegram Bot
  • Postgres Database
  • Crawl4AI

Step-by-step Setup

  1. Configure Credentials: Add your API keys and credentials for all the required services (OpenAI, Supabase, Google, Telegram, Postgres) in the n8n Credentials section.
  2. Set up Google Drive: Create two folders in your Google Drive: one for documents scraped from websites and another for manual document uploads. Note the folder IDs.
  3. Set up Google Sheets:
  • Clone the Google Sheet template, or create a Google Sheet with two tabs: Website Links and Manual Documents.
  • In the Website Links tab, add columns for Link, Category Code, Is Scraped, and Is Deleted.
  • In the Manual Documents tab, add columns for Document ID, Title, Category Code, and Is Deleted.
  1. Set up Supabase:
  • Create a new project in Supabase.
  • Run the provided SQL script to create the documents table for vector storage.
-- Enable the pgvector extension to work with embedding vectors
create extension vector;

-- Create a table to store your documents
create table documents (
  id bigserial primary key,
  content text, -- corresponds to Document.pageContent
  metadata jsonb, -- corresponds to Document.metadata
  embedding vector(1536) -- 1536 works for OpenAI embeddings, change if needed
);

-- Create a function to search for documents
create function match_documents (
  query_embedding vector(1536),
  match_count int default null,
  filter jsonb DEFAULT '{}'
) returns table (
  id bigint,
  content text,
  metadata jsonb,
  similarity float
)
language plpgsql
as $$
#variable_conflict use_column
begin
  return query
  select
    id,
    content,
    metadata,
    1 - (documents.embedding <=> query_embedding) as similarity
  from documents
  where metadata @> filter
  order by documents.embedding <=> query_embedding
  limit match_count;
end;
$$;
```

SQL Script 2:
```sql
create table public.products (
  id bigint generated by default as identity not null,
  created_at timestamp with time zone not null default now(),
  name character varying null,
  type character varying null,
  sku character varying null,
  price real null,
  description text null,
  constraint products_pkey primary key (id)
) TABLESPACE pg_default;
  1. Set up Postgres:
  • Set up a Postgres database (in Supabase).
  • Run the provided SQL script to create the products table to store product details.
create table public.products (
  id bigint generated by default as identity not null,
  created_at timestamp with time zone not null default now(),
  name character varying null,
  type character varying null,
  sku character varying null,
  price real null,
  description text null,
  constraint products_pkey primary key (id)
) TABLESPACE pg_default;
  1. Configure the Main Workflow:
  • Open the AIAutomationPro Ultimate RAG Chatbot main workflow.
  • Update the Google Drive, Google Sheets, Supabase, and Postgres nodes with your specific Folder IDs, Sheet Names, and table names.
  • Link the three sub-workflows (News AI Agent, Product AI Agent, Academy AI Agent) in the corresponding Workflow Tool nodes.
  1. Activate Workflows: Activate the main workflow and all three sub-flow workflows.
  2. Start Chatting: Send a message to your Telegram bot to start interacting with your new RAG chatbot.

How to Customize the Workflow

  • Add More Agents: You can create new sub-workflows with specialized agents for different topics (e.g., a “Finance AI Agent”). Simply add a new Workflow Tool node in the main flow and update the Supervisor Agent’s system prompt to include the new agent’s capabilities.
  • Change Data Sources: Modify the data ingestion part of the workflow to pull data from other sources like Notion, HubSpot, or a CRM by adding the relevant n8n nodes.
  • Adjust the AI Model: You can switch to a different LLM by replacing the OpenAI Chat Model nodes.
  • Modify Prompts: Fine-tune the system prompts in the Agent nodes to alter the personality, instructions, or output format of the chatbot and its specialized agents.

FAQ – Frequently Asked Questions

1. Who is this workflow intended for?
This workflow is designed for users who have a basic understanding of n8n and are capable of troubleshooting issues on their own. If you’re familiar with optimizing prompts and handling minor issues, this product is a great fit for you.


2. How is the workflow installed and used?
The workflow comes pre-configured by default, which means you can import and run it immediately. However, to achieve optimal performance for your specific use case or business needs, you may need to customize and optimize the prompts.


3. What should I keep in mind during testing?
During testing, we recommend using low-cost models (such as mini or flash) and generating low-resolution images to save on costs. The primary goal is to ensure the workflow operates reliably before making any further optimizations. Note that the low-cost models may cause error to the workflow.


4. What are the default and alternative AI models?
By default, the workflow uses the GPT-4o model due to its stability and excellent ability to return data in the required JSON format. If you encounter any issues, you can try switching to ChatGPT-4o. Note that some other models (like Gemini Flash) may not return results in JSON format or support tool calls, which could cause the workflow to malfunction.


5. How do I troubleshoot if the workflow fails to run?
Please try the following steps:

  • Run the workflow in an incognito window with all plugins disabled.
  • Try using a different browser (for example, switch from Chrome to Safari).
  • Test on another computer or in a different network environment/ server.
    Keep in mind that issues can stem from various sources, including limitations of the AI model, your self-hosted n8n server, the n8n platform itself, or even your local device/ network/ server settings.

6. How can I submit feedback or report a bug?
You can contact us to submit your suggestions, comments, or bug reports related to the workflow and documentation. Every piece of feedback is carefully reviewed to address bugs or incorporate quality improvements in future versions.


7. Is technical support included after purchase?
At present, purchasing the workflow provides you with the file only, without any technical support. In the future, we plan to offer additional support packages, including tutorial videos, technical consulting, and customization services based on customer needs.


8. Can I share or resell the workflow?
Please do not share or resell the workflow without obtaining prior permission from us. The product is protected by copyright, and unauthorized sharing or resale is strictly prohibited.


9. How do I submit feedback on my purchasing experience?
If you have any comments or suggestions regarding your purchasing experience, please send us a message. Your input is valuable to us and will help improve our services and product quality.


10. What is the refund policy?
Due to the nature of the workflow product, our shop does not currently offer refunds for purchases. In the future, we plan to sell our products on platforms that support refund policies. However, please note that the prices on those platforms will be significantly higher compared to purchasing directly from our shop.


If you have any further questions or need additional information, please feel free to contact us through our contact form.

Truly,
AI Automation Pro

Review Your Cart
0
Add Coupon Code
Subtotal