Bitrix24 Open Line Retrieval-Augmented Generation (RAG) Chatbot - n8n Workflow

Deploy a powerful RAG chatbot for Bitrix24 Open Line channels using this n8n workflow. Integrates Google Gemini, Ollama embeddings, and Qdrant vector storage for context-aware responses.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  • Companies using Bitrix24 Open Channels who need immediate, accurate customer support.

  • Technical users looking for a sophisticated n8n templates example combining AI, vector databases (Qdrant), and custom APIs.

  • Developers needing an n8n workflow to automate knowledge retrieval based on internal documents (PDFs, etc.).

Overview

Customer service inquiries often require access to extensive, internal documentation. This advanced n8n workflow solves the problem of providing instant, document-based answers within the Bitrix24 Open Line environment. It establishes a Retrieval-Augmented Generation (RAG) system where documents stored in Bitrix24 Disk are vectorized using Ollama embeddings and stored in Qdrant. When a user asks a question, the workflow retrieves relevant context and uses the Google Gemini AI model to generate a precise, informed response. This robust n8n node combination ensures high accuracy and reduces the load on human operators, providing a seamless customer experience directly from the Bitrix24 Open Channel system. This comprehensive n8n workflow acts as a complete solution for deploying sophisticated chat functionality.

How it Works

The core of this n8n workflow is driven by a webhook and organized into two main logical parts: the Main Handler and the RAG Knowledge Ingestion Sub-workflow.

Main Chat Handler Flow


  1. Trigger and Setup: The automation starts with the Bitrix24 Handler n8n trigger, which receives POST requests from the Bitrix24 Open Channel for various events (new message, bot join, install, delete).

  2. Authentication: The Credentials n8n node extracts critical API tokens and domain information from the payload. The Validate Token n8n node ensures the request is authorized.

  3. Event Routing: The Route Event n8n node directs the flow based on the event type (ONIMBOTMESSAGEADD, ONIMBOTJOINCHAT, ONAPPINSTALL, etc.).

  4. Message Processing (RAG): For incoming messages (ONIMBOTMESSAGEADD), the flow extracts the user query. The Vector Store Retriever queries the bitrix-docs collection in Qdrant, retrieving relevant document chunks based on context embedding (using Ollama embeddings).

  5. AI Generation: The retrieved context, along with the original question, is passed to the Question and Answer Chain n8n node, which utilizes the Google Gemini Chat Model to formulate a final, contextually accurate response. This n8n node is configured to strictly maintain Bitrix24 response parameters.

  6. Response: The Send Message n8n node uses the extracted parameters to post the AI-generated reply back to the specific Bitrix24 dialog.

Document Ingestion Sub-workflow

This secondary n8n workflow path handles preparing the RAG knowledge base:

  1. File Retrieval: It uses multiple HTTP Request n8n node steps to locate and list files (specifically PDFs via Default Data Loader) within the designated Bitrix24 Disk folder.

  2. Vectorization: Files are downloaded, processed by the Default Data Loader (PDF), and split into chunks by the Recursive Character Text Splitter.

  3. Embedding and Storage: The Embeddings Ollama n8n node generates vector embeddings, which are then inserted into the Qdrant Vector Store (collection: bitrix-docs).

  4. Cleanup: Finally, processed files are moved to a different folder to prevent re-ingestion, completing the RAG setup process for this n8n templates example.

Installation Guide

To implement this n8n workflow, follow these steps:


  1. Import the n8n Workflow: Copy the provided JSON and import it into your n8n instance as a new workflow.

  2. Bitrix24 App Setup: You must have a registered Bitrix24 application to obtain CLIENTID and CLIENTSECRET.

  3. Webhook Configuration: Activate the Bitrix24 Handler n8n node to generate the unique webhook URL. Copy this URL.

  4. Bitrix24 Application Webhook: When installing your bot application in Bitrix24, ensure this n8n workflow webhook URL is registered as the handler URL for the relevant Open Channel events (like ONIMBOTMESSAGEADD and ONAPPINSTALL). The Register Bot n8n node step handles API registration upon the first ONAPPINSTALL event.

  5. AI and Vector DB Credentials: Configure connections for the LangChain nodes:

Google Gemini: Ensure your n8n instance has valid credentials for the Google Gemini Chat Model.
Qdrant: Configure the Qdrant Vector Store connection, specifying the host, port, and API key. The collection used here is bitrix-docs.
* Ollama: Ensure your Ollama server is accessible to your n8n instance to run the nomic-embed-text:latest model for vector embeddings.

  1. RAG Folder Setup: Modify the Credentials n8n node to specify the exact storageName (e.g., 'Shared drive') and folderName where your source documents are located within Bitrix24 Disk.

  2. Initial RAG Run: Manually execute the file ingestion path (starting from Execute Workflow Trigger or running the registration flow) to load your documents into Qdrant before testing the chatbot.

Node Details

Bitrix24 Handler (Webhook Trigger): The starting n8n trigger. Configured to listen for POST requests at /bitrix24/openchannel-rag-bothandler.php, initiating the n8n workflow upon any Open Channel event.
Credentials (Set): Extracts authentication details (accesstoken, domain) from the incoming Bitrix24 payload and sets environment variables required for the RAG sub-workflow (storageName, folderName).
Route Event (Switch): Essential flow control n8n node that routes processing based on the body.event parameter, handling registration, joins, and messages separately.
Process Message (Function): Custom code n8n node responsible for parsing the user's message (MESSAGE
ORI) and ensuring essential Bitrix24 session and auth details are available for subsequent RAG steps.
Qdrant Vector Store & Vector Store Retriever (LangChain): The database component. Used during ingestion to store vectors in the bitrix-docs collection, and during the chat, the Retriever pulls relevant context.
Embeddings Ollama (LangChain): Uses the nomic-embed-text:latest model to convert document chunks and user queries into vector embeddings for similarity searching.
Google Gemini Chat Model (LangChain): The large language model (LLM) n8n node used for generating coherent and contextualized answers based on the retrieved data.
Question and Answer Chain (LangChain): The core RAG orchestration n8n node, combining the Retriever and the LLM according to a carefully structured system prompt.


  • Register Bot & Send Message (HTTP Request): These n8n node elements handle API communication back to Bitrix24, either registering the bot or sending the final AI response to the user dialog.

Related n8n Workflows

Free

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

With 30+ years in IT and 20+ years in leadership, I specialize in no-code automation with n8n, optimizing workflows and integrating systems efficiently. As an Agile Coach and Project Manager, I’ve led teams, managed R&D, and driven IT transformations. Skilled in n8n, Java, Node.js, and cloud solutions, I help businesses streamline operations. Let’s connect if you need an n8n expert for automation!

Featured*