Skip to main content

Build a tax code assistant with Qdrant, Mistral.ai and OpenAI

Workflow preview

Workflow preview
100%
Build a tax code assistant with Qdrant, Mistral.ai and OpenAI preview
Open on n8n.io

Important notice

This workflow is provided as-is. Please review and test before using in production.

1. Workflow Overview

This n8n workflows builds another example of creating a knowledgebase assistant but demonstrates how a more deliberate and targeted approach to ingesting the data can produce much better results fo...

Best for

  • Internal Wiki automation workflows
  • AI RAG automation workflows
  • advanced n8n builders looking for reusable templates

Tools used

n8n-nodes-base.manualtrigger, @n8n/n8n-nodes-langchain.embeddingsmistralcloud, @n8n/n8n-nodes-langchain.documentdefaultdataloader, @n8n/n8n-nodes-langchain.textsplitterrecursivecharactertextsplitter, n8n-nodes-base.httprequest, n8n-nodes-base.compression, n8n-nodes-base.splitout, n8n-nodes-base.extractfromfile

Source and attribution

This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Jimleuk.

Original n8n.io source

1.1 Workflow description

Title
Build a tax code assistant with Qdrant, Mistral.ai and OpenAI
Workflow name
Build a tax code assistant with Qdrant, Mistral.ai and OpenAI

This n8n workflows builds another example of creating a knowledgebase assistant but demonstrates how a more deliberate and targeted approach to ingesting the data can produce much better results for your chatbot.

In this example, a government tax code policy document is used. Whilst we could split the document into chunks by content length, we often lose the context of chapters and sections which may be required by the user.

Our approach then is to first split the document into chapters and sections before importing into our vector store. Additionally, using metadata correctly is key to allow filtering and scoped queries.

Example

Human: "Tell me about what the tax code says about cargo for intentional commerce?"

AI: "Section 11.25 of the Texas Property Tax Code pertains to "MARINE CARGO CONTAINERS USED EXCLUSIVELY IN INTERNATIONAL COMMERCE." In this section, a person who is a citizen of a foreign country or an en..."

How it works

  • The tax code policy document is downloaded as a zip file from the government website and its pages are extracted as separate chapters.
  • Each chapter is then parsed and split into its sections using data manipulation expressions.
  • Each section is then inserted into our Qdrant vector store tagged with its source, chapter and section numbers as metadata.
  • When our AI Agent needs to retrieve data from our vector store, we use a custom workflow tool to perform the query to Qdrant.
  • Because we're relying on Qdrant's advanced filtering capabilities, we perform the search using the Qdrant API rather than the Qdrant node.
  • When the AI Agent, needs to pull full wording or extracts, we can use Qdrant's scroll API and metadata filtering to do so. This makes Qdrant behave like a key-value store for our document.

Requirements

  • A Qdrant instance is required for the vector store and specifically for it's filtering functionality.
  • Mistral.ai account for Embeddings and AI models.

Customising this workflow

Depending on your use-case, consider returning actual PDF pages (or links) to the user for the extra confirmation and to build trust.

Not using Mistral? You are able to replace but note to match the distance and dimension size of Qdrant collection to your chosen embedding model.

1.2 Logical Blocks

This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.

2. Block-by-Block Analysis

Block 1 - When clicking ‘Test workflow’

Type / Role
n8n-nodes-base.manualTrigger - manualTrigger
Config choices
Version 1

Block 2 - Embeddings Mistral Cloud

Type / Role
@n8n/n8n-nodes-langchain.embeddingsMistralCloud - embeddingsMistralCloud
Config choices
Version 1

Block 3 - Default Data Loader

Type / Role
@n8n/n8n-nodes-langchain.documentDefaultDataLoader - documentDefaultDataLoader
Config choices
Version 1

Block 4 - Recursive Character Text Splitter

Type / Role
@n8n/n8n-nodes-langchain.textSplitterRecursiveCharacterTextSplitter - textSplitterRecursiveCharacterTextSplitter
Config choices
Version 1

Block 5 - Get Tax Code Zip File

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 6 - Extract Zip Files

Type / Role
n8n-nodes-base.compression - compression
Config choices
Version 1.1

Block 7 - Files as Items

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 8 - Extract PDF Contents

Type / Role
n8n-nodes-base.extractFromFile - extractFromFile
Config choices
Version 1

Block 9 - Extract From Chapter

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.3

Block 10 - Map To Sections

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.3

Block 11 - Execute Workflow Trigger

Type / Role
n8n-nodes-base.executeWorkflowTrigger - executeWorkflowTrigger
Config choices
Version 1

Block 12 - Get Mistral Embeddings

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 13 - Content Chunking @ 50k Chars

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.3

Block 14 - Split Out Chunks

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 15 - For Each Section...

Type / Role
n8n-nodes-base.splitInBatches - splitInBatches
Config choices
Version 3

Block 16 - Sections To List

Type / Role
n8n-nodes-base.splitOut - splitOut
Config choices
Version 1

Block 17 - Only Valid Sections

Type / Role
n8n-nodes-base.filter - filter
Config choices
Version 2

Block 18 - Use Qdrant Search API1

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 19 - Use Qdrant Scroll API

Type / Role
n8n-nodes-base.httpRequest - httpRequest
Config choices
Version 4.2

Block 20 - Get Search Response

Type / Role
n8n-nodes-base.set - set
Config choices
Version 3.3

Block 21 - Sticky Note

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 22 - Sticky Note1

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 23 - Sticky Note2

Type / Role
n8n-nodes-base.stickyNote - stickyNote
Config choices
Version 1

Block 24 - Qdrant Vector Store

Type / Role
@n8n/n8n-nodes-langchain.vectorStoreQdrant - vectorStoreQdrant
Config choices
Version 1

Showing the first 24 of 38 workflow blocks. Download the JSON for the full node graph.

3. Summary Table

Workflow Build a tax code assistant with Qdrant, Mistral.ai and OpenAI
Complexity advanced
Nodes 38
Categories Internal Wiki, AI RAG
Author Jimleuk
Published 11 Jul 2024

4. Reproducing the Workflow from Scratch

  1. 1. Download the workflow JSON

    Use the JSON export at /data/workflows/2341/2341.json as the source template for this automation.

  2. 2. Import the template into n8n

    Open n8n, import the downloaded JSON, and review each node before activating the workflow.

  3. 3. Configure credentials and variables

    Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.

  4. 4. Test with sample data

    Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.

  5. 5. Activate and monitor

    Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.

5. General Notes & Resources

Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.

Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.

Frequently asked questions

What does Build a tax code assistant with Qdrant, Mistral.ai and OpenAI do?

This n8n workflows builds another example of creating a knowledgebase assistant but demonstrates how a more deliberate and targeted approach to ingesting the data can produce much better results fo...

What do I need before importing this workflow?

Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.

Can I customize this workflow?

Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Internal Wiki, AI RAG use case.