AI Document Chat Agent for Nextcloud Knowledge Retrieval - n8n Workflow

Deploy an advanced RAG AI agent using this n8n workflow. Connect Nextcloud files, process PDFs/DOCX, and enable natural language chat for instant knowledge retrieval.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?


  1. Teams needing internal knowledge management solutions.

  2. Developers looking for advanced n8n templates for RAG implementation.

  3. Users who store documentation in Nextcloud and require a natural language interface.

  4. n8n users specializing in complex LLM and data ingestion pipelines.

Overview

This sophisticated n8n workflow solves the problem of inaccessible organizational knowledge locked away in files. It transforms your Nextcloud folder documentation (including PDF, Markdown, and DOCX files) into an actionable knowledge base. By utilizing the power of a LangChain AI Agent, this n8n template allows users to ask questions directly via a chat interface. The AI agent intelligently identifies the folder path mentioned in the query, triggers a subworkflow to retrieve and process the relevant documents using the Nextcloud n8n node, and then uses that information to generate accurate, context-aware responses. This provides a highly efficient and modern approach to document retrieval within the n8n platform.

How it Works

This system operates as a primary workflow (the AI Chat Agent) connected to a secondary subworkflow (the Nextcloud File Reader tool).


  1. Trigger & Query: The process starts when the "When chat message received" n8n trigger receives a user message.

  2. Agent Action: The LangChain Agent ("AI Nextcloud" n8n node) receives the query. It uses the OpenAI Chat Model and Simple Memory for conversation context.

  3. Tool Use: If the user asks about file contents (e.g., "What is in the /docs folder?"), the agent recognizes the need to execute the Nextcloud Tool n8n node, which calls the subworkflow.

  4. Subworkflow Trigger: The subworkflow is executed via its "When Executed by Another Workflow" n8n trigger, receiving the path variable (e.g., /docs).

  5. File Retrieval: The subworkflow uses the Nextcloud n8n node to list and then download files from that path.

  6. Data Processing: An If statement checks if the file is readable (PDF, DOCX, Markdown). A subsequent Switch n8n node routes the files to the appropriate data extraction node (PDF, Markdown, DOCX).

  7. Data Consolidation: The extracted text data is aggregated and returned to the main n8n workflow.

  8. Response Generation: The AI Agent receives the extracted text (the retrieved knowledge) and uses it to formulate a final, context-grounded response to the user via the initial n8n trigger. This complete n8n workflow loop ensures accurate Q&A.

Installation Guide

To deploy this advanced n8n workflow, follow these steps:


  1. Import: Copy the provided JSON and import it into your n8n instance as a new workflow. Note that this architecture requires two linked workflows (the main agent and the tool workflow).

  2. Nextcloud Credentials: Configure the NextCloud account credential in the subworkflow's "Get Files" and "Download File" n8n node setups.

  3. OpenAI/LLM Credentials: Configure the required API key credential in the "OpenAI Chat Model" n8n node.

  4. Tool Linking: In the main n8n workflow, ensure the "Nextcloud Tool" n8n node is correctly linked to the ID of the subworkflow you just imported. This connection is critical for the n8n workflow logic.

  5. Community Node: This n8n workflow uses the community package n8n-nodes-word2text for DOCX processing. You must install this package on your n8n instance before execution.

  6. Activation: Activate both the main chat agent workflow and the subworkflow. The chat agent is now listening via its n8n trigger.

Node Details

When chat message received (LangChain Chat Trigger): The initiating n8n trigger for user interaction, providing a live chat endpoint. It starts the main n8n workflow.
OpenAI Chat Model (LangChain LM Chat OpenAI): Connects to the LLM backend (configured for Qwen) used for generating responses.
Simple Memory (LangChain Memory Buffer Window): Stores recent conversation history, allowing the AI to maintain context throughout the chat session.
AI Nextcloud (LangChain Agent): The core intelligence orchestrator. It decides whether to use the Nextcloud Tool n8n node or answer directly.
Nextcloud Tool (LangChain Tool Workflow): A specialized n8n node that connects the AI Agent to the subworkflow, defining how the agent can call the Nextcloud file reader. This is key to the overall n8n workflow.
When Executed by Another Workflow (Execute Workflow Trigger): The n8n trigger for the subworkflow, enabling it to be called programmatically by the main n8n workflow.
Get Files / Download File (NextCloud n8n node): Handles authentication and interaction with Nextcloud to list and retrieve files based on the path provided by the AI agent.
Switch n8n node: Routes the downloaded file based on its contentType (PDF, Markdown, DOCX) to the appropriate extraction method.
PDF / Markdown (ExtractFromFile n8n node): Extracts readable text content from the file buffers.
DOCX (Word2text n8n node): Uses a dedicated community node to handle complex DOCX file extraction, crucial for this RAG n8n workflow.


  • Aggregate n8n node: Combines all extracted text outputs before sending the collective knowledge back to the main n8n workflow.

Related n8n Workflows

Free

Nodes: 15 Nodes
Updated: December 26 2025
View all
Created by
johappel
johappel

Featured*