{"product_id":"chat-with-local-documents-in-n8n-ollama-mariadb-vector-cache","title":"Chat with Local Documents in n8n: Ollama + MariaDB Vector Cache","description":"\u003ch3\u003eChat with your own files locally in n8n—using Ollama embeddings + a MariaDB vector cache\u003c\/h3\u003e\n\u003cp\u003eThis n8n workflow ingests documents from an FTP server into a MariaDB vector store, then lets users ask questions through an n8n chat trigger. Answers are generated with Ollama from retrieved document context—and repeated questions are automatically cached in MariaDB for fast, cost-saving responses.\u003c\/p\u003e\n\n\u003ch3\u003eWhat this workflow does\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eManual document ingestion via FTP:\u003c\/strong\u003e Lists and downloads a file from an FTP server, extracts its text, and prepares it for indexing.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eSummarize \u0026amp; categorize:\u003c\/strong\u003e Sends extracted text to an \u003cstrong\u003eOllama\u003c\/strong\u003e chat model to produce a short summary and assign a category from an allowed list.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eCreate a vector index in MariaDB:\u003c\/strong\u003e Splits the document into chunks, generates \u003cstrong\u003eOllama embeddings\u003c\/strong\u003e for each chunk, and inserts chunk text, vectors, and metadata into the MariaDB \u003cstrong\u003edocuments\u003c\/strong\u003e table (including a VECTOR column).\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eChat with retrieval-augmented generation (RAG):\u003c\/strong\u003e Receives a question via an \u003cstrong\u003en8n Chat trigger\u003c\/strong\u003e, normalizes it, and checks the MariaDB \u003cstrong\u003eqa_cache\u003c\/strong\u003e for a matching cached answer.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eRetrieve context \u0026amp; answer strictly from it:\u003c\/strong\u003e If not cached, embeds the question, retrieves the top similar chunks from MariaDB by vector distance, builds a context-cited prompt, and asks an Ollama chat model to answer \u003cem\u003estrictly from that retrieved context\u003c\/em\u003e.\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eCache new answers:\u003c\/strong\u003e Stores the new response back into \u003cstrong\u003eqa_cache\u003c\/strong\u003e and returns either the cached or newly generated answer.\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eUse cases\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003eInternal “chat with documents” for operators who receive files over FTP\u003c\/li\u003e\n  \u003cli\u003eFaster Q\u0026amp;A for frequently asked support questions via MariaDB caching\u003c\/li\u003e\n  \u003cli\u003ePrivate RAG setups where you want control over embeddings and storage (MariaDB + Ollama)\u003c\/li\u003e\n\u003c\/ul\u003e\n\n\u003ch3\u003eTechnical details\u003c\/h3\u003e\n\u003cul\u003e\n  \u003cli\u003e\n\u003cstrong\u003eIntegrations \/ nodes:\u003c\/strong\u003e if, ftp, set, code, MySQL\/MariaDB, sticky note\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eData storage:\u003c\/strong\u003e MariaDB 11.7+ with \u003cstrong\u003edocuments\u003c\/strong\u003e (VECTOR column) and \u003cstrong\u003eqa_cache\u003c\/strong\u003e\n\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eModeling:\u003c\/strong\u003e Ollama chat model for summary\/categorization and embeddings generation for vector retrieval\u003c\/li\u003e\n  \u003cli\u003e\n\u003cstrong\u003eKey configuration:\u003c\/strong\u003e MariaDB credentials, Ollama base URL, and embedding\/chat model names, plus FTP credentials\u003c\/li\u003e\n\u003c\/ul\u003e","brand":"N8N Commerce","offers":[{"title":"Default Title","offer_id":46289128751283,"sku":"N8N-21639","price":2.99,"currency_code":"GBP","in_stock":true}],"thumbnail_url":"\/\/cdn.shopify.com\/s\/files\/1\/0749\/6279\/6723\/files\/VR8H2I2TkEALOMGx-KeTP_Ccgc189R.png?v=1793006349","url":"https:\/\/buyflowscripts.com\/products\/chat-with-local-documents-in-n8n-ollama-mariadb-vector-cache","provider":"N8N Commerce","version":"1.0","type":"link"}