AutomationFlowsAI & RAG › Save Costs in RAG Workflows with Q&A Tool

Save Costs in RAG Workflows with Q&A Tool

Original n8n title: Save Costs in RAG Workflows Using the Q&a Tool with Multiple Models

ByNiklas Hatje @nik8n on n8n.io

This template shows how to use the Question and Answer tool to save costs in RAG use cases.

Event trigger★★★☆☆ complexityAI-powered13 nodesForm TriggerOpenAI EmbeddingsDocument Default Data LoaderIn-Memory Vector StoreAgentChat TriggerTool Vector StoreOpenAI Chat
AI & RAG Trigger: Event Nodes: 13 Complexity: ★★★☆☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #5011 — we link there as the canonical source.

This workflow follows the Agent → Chat Trigger recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "83ed351e-90e8-458f-a01b-73001ef1800f",
      "name": "Upload your file here",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        220,
        -120
      ],
      "parameters": {
        "options": {},
        "formTitle": "Upload your data to test RAG",
        "formFields": {
          "values": [
            {
              "fieldType": "file",
              "fieldLabel": "Upload your file(s)",
              "requiredField": true,
              "acceptFileTypes": ".pdf, .csv"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "26d63e24-2592-41f9-9b4b-edab81e99f21",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        860,
        460
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "3a69c8a7-bf95-4de2-84b0-ae2cc3d2e4e7",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        660,
        40
      ],
      "parameters": {
        "options": {},
        "dataType": "binary"
      },
      "typeVersion": 1.1
    },
    {
      "id": "0b42832b-c9e8-4627-b36c-94fc5e242b33",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        -180
      ],
      "parameters": {
        "color": 4,
        "width": 440,
        "height": 300,
        "content": "### Readme\nLoad your data into a vector database with the \ud83d\udcda **Load Data** flow, and then use your data as chat context with the \ud83d\udc15 **Retriever** flow.\n\n**Quick start**\n1. Click on the `Execute Workflow` button to run the \ud83d\udcda **Load Data** flow.\n2. Click on `Open Chat` button to run the \ud83d\udc15 **Retriever** flow. Then ask a question about content from your document(s)\n\n\nFor more info, check our [docs on RAG in n8n](https://docs.n8n.io/advanced-ai/rag-in-n8n/)"
      },
      "typeVersion": 1
    },
    {
      "id": "f902ab8f-4620-4a95-86f7-c5857c4d6c4f",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        160,
        -180
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 460,
        "content": "### \ud83d\udcda Load Data Flow"
      },
      "typeVersion": 1
    },
    {
      "id": "0f4185ea-d7a9-44a9-a824-98f9dc2c2a5d",
      "name": "Insert Data to Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        400,
        -120
      ],
      "parameters": {
        "mode": "insert",
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "vector_store_key",
          "cachedResultName": "vector_store_key"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "ce86b41b-7e1b-458f-ab13-d6b187854ae8",
      "name": "Query Data Tool",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreInMemory",
      "position": [
        1300,
        200
      ],
      "parameters": {
        "memoryKey": {
          "__rl": true,
          "mode": "list",
          "value": "vector_store_key"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "0039537b-558c-4fe8-9716-f8aa13676f4a",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        1280,
        -140
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 2
    },
    {
      "id": "2669a65e-f0f3-45aa-95c0-621b15a4fc67",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        1060,
        -140
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.1
    },
    {
      "id": "3d1b3f5a-bc35-4739-a618-9c85820d39a0",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        940,
        -180
      ],
      "parameters": {
        "color": 7,
        "width": 820,
        "height": 520,
        "content": "### \ud83d\udc15 2. Retriever Flow"
      },
      "typeVersion": 1
    },
    {
      "id": "6553a758-c655-4196-88be-9d93187f9c7b",
      "name": "Answer questions with a vector store",
      "type": "@n8n/n8n-nodes-langchain.toolVectorStore",
      "position": [
        1440,
        60
      ],
      "parameters": {
        "description": "The data contains custom knowledge"
      },
      "typeVersion": 1.1
    },
    {
      "id": "d43cf585-4192-4f53-9532-4677923289ba",
      "name": "Expensive model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1060,
        80
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "gpt-4.1"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "18dcc49d-9ce0-4746-8135-7e4c77cfa501",
      "name": "Cheap Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        1600,
        200
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1-mini"
        },
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    }
  ],
  "connections": {
    "Cheap Model": {
      "ai_languageModel": [
        [
          {
            "node": "Answer questions with a vector store",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Expensive model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Query Data Tool": {
      "ai_tool": [
        []
      ],
      "ai_vectorStore": [
        [
          {
            "node": "Answer questions with a vector store",
            "type": "ai_vectorStore",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Insert Data to Store",
            "type": "ai_embedding",
            "index": 0
          },
          {
            "node": "Query Data Tool",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Insert Data to Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Upload your file here": {
      "main": [
        [
          {
            "node": "Insert Data to Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Answer questions with a vector store": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

This template shows how to use the Question and Answer tool to save costs in RAG use cases.

Source: https://n8n.io/workflows/5011/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

Order and Delivery Support. Uses lmChatOpenAi, documentDefaultDataLoader, embeddingsOpenAi, toolVectorStore. Event-driven trigger; 29 nodes.

OpenAI Chat, Document Default Data Loader, OpenAI Embeddings +15
AI & RAG

Supabase RAG AI Agent PDFs & More. Uses lmChatOpenAi, documentDefaultDataLoader, embeddingsOpenAi, toolVectorStore. Event-driven trigger; 29 nodes.

OpenAI Chat, Document Default Data Loader, OpenAI Embeddings +9
AI & RAG

This workflow implements a complete Retrieval-Augmented Generation (RAG) knowledge assistant with built-in document ingestion, conversational AI, and automated analytics using n8n, OpenAI, and Pinecon

Form Trigger, Data Table, Text Splitter Recursive Character Text Splitter +8
AI & RAG

Building Your First Whatsapp Chatbot. Uses whatsAppTrigger, lmChatOpenAi, memoryBufferWindow, toolVectorStore. Event-driven trigger; 28 nodes.

WhatsApp Trigger, OpenAI Chat, Memory Buffer Window +8
AI & RAG

This n8n template builds a simple WhatsApp chabot acting as a Sales Agent. The Agent is backed by a product catalog vector store to better answer user's questions.

WhatsApp Trigger, OpenAI Chat, Memory Buffer Window +8