Opening Problem Statement
Meet Sarah, a finance analyst in a mid-sized company, who spends countless hours manually organising and reviewing bank statements stored on her local workstation to respond to frequent queries from her management team. Every time a new bank statement file arrives or an existing one is updated or deleted, Sarah needs to cross-reference the data, update her records, and respond to questions—leading to lost time, human error, and delayed decisions.
Imagine how tedious it is for Sarah to keep track of all these local files and simultaneously provide accurate answers to daily financial questions. With hundreds of files changing regularly, manual effort isn’t just exhausting; it’s error-prone and inefficient.
What This Automation Does
This n8n workflow offers Sarah a powerful solution that automates continuous monitoring, indexing, and querying of her local bank statements using modern AI and vector search technologies. Here’s how it works:
- Monitors a specified folder on her machine for any added, updated, or deleted bank statement files, triggering the workflow instantly when changes occur.
- Automatically reads and processes these files to create semantic embeddings using Mistral AI, converting bank statement text into meaningful vector data.
- Synchronizes these vectors with Qdrant vector database—automatically adding, updating, or deleting records to ensure data reflects the current state of files.
- Creates an AI-powered Question & Answer agent using Mistral Language Model combined with Qdrant vector retrieval, enabling Sarah to ask insightful questions about her entire bank statement archive.
- Provides fast, precise AI answers to queries without manual searching through files, saving hours of effort daily.
- Keeps the vector database and AI knowledge fresh and relevant in real-time by handling file system events intelligently.
This workflow reduces Sarah’s manual work drastically, slashing hours wasted on data retrieval and boosting accuracy of her finance insights.
Prerequisites ⚙️
- n8n Automation Platform account (cloud or self-hosted) 🔌
- Access to local file system where bank statement files are stored 📁
- Mistral Cloud API credentials for AI embeddings and chat models 🔑
- Qdrant vector database instance and API credentials 🔐
- Ability to mount or map local folders if using Docker setup 📁
If opting for self-hosting n8n with local folder access, you might consider reliable hosting from providers like Hostinger for consistent uptime and storage mounting.
Step-by-Step Guide
Step 1: Select the Target Folder with Local File Trigger
Navigate to the Local File Trigger node configuration.
Set the path to the bank statement folder, e.g., /home/node/host_mount/local_file_search. This path must reference the mounted folder accessible by n8n.
Choose the events to monitor: add, change, unlink to catch when files are added, updated, or deleted.
Enable the awaitWriteFinish option to ensure file writes complete before triggering.
After saving, this node will watch your folder continuously, ready to activate your workflow when needed.
Common mistake: Using an inaccessible path or forgetting to mount the folder when running n8n in Docker will result in no triggers.
Step 2: Set Variables for File and Collection Metadata
After the trigger, the Set node called Set Variables extracts and assigns several variables:
– directory: Local path to the bank statement files
– file_added, file_changed, file_deleted: Path strings linked to the respective file events
– qdrant_collection: Name of the Qdrant collection where vector points are managed (e.g., local_file_search)
This simplifies downstream logic by centralizing the file paths and collection info.
Step 3: Handle File Event Routing with Switch Node
Use the Handle File Event Switch node to direct the workflow based on what type of file event occurred.
Set conditions to check for non-empty strings in file_deleted, file_changed, and file_added, producing outputs routed accordingly.
This branching allows precise, event-specific workflow branches: deleting, updating, or adding vector entries.
Step 4: Manage Deleted Files by Removing Vector Points
On the file deleted path, the workflow calls Qdrant’s REST API via HTTP Request node named Search For Existing Point to find vector points matching the deleted file’s filename filtered via metadata.
If a point exists, the Delete Existing Point HTTP Request node sends a DELETE command to remove vector points from Qdrant.
This ensures that your vector store remains accurate and free of references to removed documents.
Step 5: Manage Updated Files by Removing Old Vector Points
On the file changed track, the workflow similarly checks for an existing vector point using Search For Existing Point1.
If found, it deletes the existing vector point using Delete Existing Point1.
After deletion, it continues to reload and re-embed the updated file to insert fresh vector data (covered in the next step).
Step 6: Process Added or Changed Files by Reading the File
On the file added or changed branch (remapped), the Read File node reads the actual file from the path passed down.
The file content is then passed to the Prepare Embedding Document Set node, which formats the document with metadata and decodes the file content from base64.
This step constructs a detailed document string that later turns into vector embeddings.
Step 7: Generate Embeddings with Mistral AI
The workflow passes the prepared document to the Embeddings Mistral Cloud node which leverages Mistral’s AI embedding services to convert the bank statement text into high-dimensional vectors.
Embedding documents make it easy to search semantically rather than simple keyword matches.
Step 8: Insert or Update Vector Points in Qdrant Vector Store
Using the Qdrant Vector Store node, the workflow inserts the newest embeddings into the Qdrant collection specified earlier.
This makes your vector database up-to-date with all current bank statement files.
Step 9: Split Text and Load Data for AI Agent
The Recursive Character Text Splitter breaks down long texts into manageable chunks.
The Default Data Loader then loads this segmented data into the workflow for the AI agent’s use.
Step 10: Setup the AI-Powered Question & Answer Agent
A webhook node named Chat Trigger awaits input queries.
When triggered, it routes the input question through a Question and Answer Chain node which uses the Mistral Cloud Chat Model paired with the Vector Store Retriever that accesses Qdrant vectors.
This mechanism enables real-time AI-powered answers about the bank statement files.
Customizations ✏️
- Change monitored folder path: In the Local File Trigger node, update the
pathparameter to monitor any other local folder storing documents. - Switch AI models: Edit the Embeddings Mistral Cloud and Mistral Cloud Chat Model nodes to use a different Mistral model or API key to leverage more advanced AI capabilities.
- Adjust vector store collection: Modify
qdrant_collectionin the Set Variables node to target a different Qdrant collection for various document types. - Customize metadata filters: Extend the Search For Existing Point HTTP Request nodes’ JSON body filter to include additional document metadata for more refined vector management.
- Enable additional file events: Include other events in the Local File Trigger like ‘rename’ if you want to track all file system changes.
Troubleshooting 🔧
Problem: No workflow trigger when files change
Cause: Folder path not accessible or not properly mounted in n8n Docker.
Solution: Double-check folder mount points and permissions in your Docker run configurations. Use absolute paths accessible by n8n.
Problem: Vector points not updating after file changes
Cause: HTTP requests to Qdrant API failing or not deleting old points correctly.
Solution: Test Qdrant API endpoints independently with curl or Postman. Verify credentials and JSON payload formats are correct in the HTTP Request nodes.
Problem: AI agent returns irrelevant answers
Cause: Vector store not properly updated or embeddings not aligned.
Solution: Ensure text splitting and embedding generation nodes are functioning by inspecting intermediate node outputs. Confirm vector points exist for your documents.
Pre-Production Checklist ✅
- Verify local folder path and Docker volume mappings.
- Test Mistral API credentials for embeddings and chat separately.
- Check Qdrant collection exists and credentials allow insert, delete, and query operations.
- Run manual tests by adding, updating, and deleting sample files in the target folder.
- Examine workflow executions for correct branching and error-free HTTP requests.
Deployment Guide
Activate your workflow by turning on the Local File Trigger node to continuously monitor your folder.
Ensure your n8n environment has consistent access to the required APIs and local files.
Configure webhook URLs and secure your Mistral and Qdrant API credentials.
Monitor workflow run logs in n8n to troubleshoot unexpected errors or performance issues.
FAQs
- Can I use another vector database instead of Qdrant?
Yes, but you will need to adjust API calls and possibly use different nodes compatible with your chosen vector store. - Does this workflow consume a lot of API credits?
API usage depends on frequency of file changes and query volume. Monitor your Mistral and Qdrant plans accordingly. - Is my data safe in this automation?
Yes, your data remains local except for vector embeddings sent to Qdrant and AI prompt data to Mistral. Ensure secure API key storage.
Conclusion
By setting up this workflow, Sarah has transformed tedious manual bank statement management into an automated, AI-powered system. She now spends minutes instead of hours retrieving financial insights and answering queries with accuracy.
This workflow showcases the synergy of n8n’s local file triggers, Mistral AI embedding/chat models, and Qdrant vector storage to create a smart document Q&A assistant.
Next, consider expanding this automation to support other document types like invoices or contracts, or integrate Slack notifications for real-time query alerts.
With this system running, you too can unlock great efficiency and AI-driven insights from your local documents.