AutomationFlows β€Ί AI & RAG β€Ί My Solution for the "agentic Arena Community Contest" (rag, Qdrant, Mistral Ocr)

My Solution for the "agentic Arena Community Contest" (rag, Qdrant, Mistral Ocr)

ByDavide Boizza @n3witaliaβœ“ on n8n.io

πŸ€–πŸ“ˆ This workflow is my personal solution for the Agentic Arena Community Contest, where the goal is to build a Retrieval-Augmented Generation (RAG) AI agent capable of answering questions based on a provided PDF knowledge base.

Event triggerβ˜…β˜…β˜…β˜…β˜… complexityAI-powered41 nodesEvaluationEvaluation TriggerChatOpenAI ChatHTTP RequestOpenAI EmbeddingsDocument Default Data LoaderQdrant Vector Store
AI & RAG Trigger: Event Nodes: 41 Complexity: β˜…β˜…β˜…β˜…β˜… AI nodes: yes Added:

This workflow corresponds to n8n.io template #8944 β€” we link there as the canonical source.

This workflow follows the Agent β†’ Documentdefaultdataloader 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
{
  "id": "9wQdbEN53X1Q78fl",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "My Agentic Arena Community Contest",
  "tags": [],
  "nodes": [
    {
      "id": "ff9d2c01-8f8b-4e2b-927a-68e73a048a50",
      "name": "Only if we are evaluating",
      "type": "n8n-nodes-base.evaluation",
      "position": [
        -176,
        336
      ],
      "parameters": {
        "operation": "checkIfEvaluating"
      },
      "typeVersion": 4.7
    },
    {
      "id": "061e124c-c05a-4d8e-be34-5e3894d5afc9",
      "name": "Eval Input",
      "type": "n8n-nodes-base.set",
      "position": [
        -1392,
        320
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "91a79047-f1c3-4b16-921e-0c8a45c43320",
              "name": "chatInput",
              "type": "string",
              "value": "={{ $json.question }}"
            },
            {
              "id": "56cb3f48-70b0-4737-b4cd-8563fdd28455",
              "name": "sessionId",
              "type": "string",
              "value": "=pureEval-{{ Math.round(Math.random()*1000) }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "1b9691ad-a118-4c57-a970-6dae65cf4f6a",
      "name": "Eval Set",
      "type": "n8n-nodes-base.evaluationTrigger",
      "position": [
        -1600,
        320
      ],
      "parameters": {
        "filtersUI": {
          "values": [
            {
              "lookupColumn": "agent answer"
            }
          ]
        },
        "limitRows": true,
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ed0c-Nt4BTETlbwpCA3oTdp7Z_-h1om2tJGasOpPvbo/edit#gid=0",
          "cachedResultName": "Eval"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ed0c-Nt4BTETlbwpCA3oTdp7Z_-h1om2tJGasOpPvbo",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ed0c-Nt4BTETlbwpCA3oTdp7Z_-h1om2tJGasOpPvbo/edit?usp=drivesdk",
          "cachedResultName": "Public Agentic Arena Evaluation Set"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.6
    },
    {
      "id": "2f3235df-a66a-4ac2-82b3-38b58985357e",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -320,
        96
      ],
      "parameters": {
        "color": 4,
        "width": 1024,
        "height": 560,
        "content": "## Eval for Correctness"
      },
      "typeVersion": 1
    },
    {
      "id": "aadf0db5-676b-47c0-99ef-12f9b14aaffe",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1648,
        208
      ],
      "parameters": {
        "color": 4,
        "width": 656,
        "height": 288,
        "content": "## Eval Input\n\nCorrect the _Set-Node_ directly to your Agent, once done"
      },
      "typeVersion": 1
    },
    {
      "id": "98e04e20-12dc-4d2b-947f-5dc54ba9abc0",
      "name": "Respond to Chat",
      "type": "@n8n/n8n-nodes-langchain.chat",
      "position": [
        304,
        512
      ],
      "parameters": {
        "message": "={{ $json.output }}",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "adf0d271-cae7-4aa7-b8fd-e58a3d4fd4af",
      "name": "Filter Empty Rows",
      "type": "n8n-nodes-base.filter",
      "position": [
        -1184,
        320
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "9eab8192-200a-4520-afe9-b13c14cd000c",
              "operator": {
                "type": "string",
                "operation": "notEmpty",
                "singleValue": true
              },
              "leftValue": "={{ $json.chatInput }}",
              "rightValue": ""
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "ac63265e-e361-4df3-9a32-4f3aca4d504f",
      "name": "Save Eval",
      "type": "n8n-nodes-base.evaluation",
      "position": [
        560,
        272
      ],
      "parameters": {
        "outputs": {
          "values": [
            {
              "outputName": "correctness",
              "outputValue": "={{ $json.Correctness }}"
            },
            {
              "outputName": "agent answer",
              "outputValue": "={{ $('AI Agent').item.json.output }}"
            }
          ]
        },
        "sheetName": {
          "__rl": true,
          "mode": "list",
          "value": "gid=0",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1D1P_B70KYuzLXVhSFGd6t19Q2u7msEenvhUqajwLw7k/edit#gid=0",
          "cachedResultName": "Sheet1"
        },
        "documentId": {
          "__rl": true,
          "mode": "list",
          "value": "1ed0c-Nt4BTETlbwpCA3oTdp7Z_-h1om2tJGasOpPvbo",
          "cachedResultUrl": "https://docs.google.com/spreadsheets/d/1ed0c-Nt4BTETlbwpCA3oTdp7Z_-h1om2tJGasOpPvbo/edit?usp=drivesdk",
          "cachedResultName": "Public Agentic Arena Evaluation Set"
        }
      },
      "credentials": {
        "googleSheetsOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.7
    },
    {
      "id": "baac5f6a-46ab-4207-94c0-cc2445c3a0aa",
      "name": "Run Evaluation",
      "type": "n8n-nodes-base.evaluation",
      "position": [
        208,
        272
      ],
      "parameters": {
        "prompt": "You are an expert factual evaluator assessing the accuracy of answers compared to established ground truths.\n\nEvaluate the factual correctness of a given output compared to the provided ground truth on a scale from 1 to 5. Use detailed reasoning to thoroughly analyze all claims before determining the final score.\n\n# Scoring Criteria\n\n- 5: Highly similar - The output and ground truth are nearly identical, with only minor, insignificant differences.\n- 4: Somewhat similar - The output is largely similar to the ground truth but has few noticeable differences.\n- 3: Moderately similar - There are some evident differences, but the core essence is captured in the output.\n- 2: Slightly similar - The output only captures a few elements of the ground truth and contains several differences.\n- 1: Not similar - The output is significantly different from the ground truth, with few or no matching elements.\n- 0: Not similar at all \u2013 The outpus is completely different from the ground truth or not provided. Like nothings is matching.\n\nEvery correct Citation (ideally exact) inside of the Output that matches the provided ground truth is a strong boost for a good score. Also important: A Citation DOES NOT require to be in square brackets. Correct Text is perfectly fine.\n\n# Evaluation Steps\n\n1. Identify and list the key elements present in both the output and the ground truth.\n2. Compare these key elements to evaluate their similarities and differences, considering both content and structure.\n3. Analyze the semantic meaning conveyed by both the output and the ground truth, noting any significant deviations.\n4. Consider factual accuracy of specific details, including names, dates, numbers, and relationships.\n5. Assess whether the output maintains the factual integrity of the ground truth, even if phrased differently.\n6. Determine the overall level of similarity and accuracy according to the defined criteria.\n7. Check if the Citation of Source is provided and matches the original source of the ground truth.\n\n# Output Format\n\nProvide:\n- A detailed analysis of the comparison (extended reasoning)\n- A one-sentence summary highlighting key differences (not similarities)\n- The final similarity score as an integer (0, 1, 2, 3, 4, or 5)\n\nAlways follow the JSON format below and return nothing else:\n{\n  \"extended_reasoning\": \"<detailed step-by-step analysis of factual accuracy and similarity>\",\n  \"reasoning_summary\": \"<one sentence summary focusing on key differences>\",\n  \"score\": <number: integer from 1 to 5>,\n  \"expected_citation\": \"<exact correct citation of the source like in expected answer>\",\n}\n\n# Examples\n\n**Example 1:**\n\nInput:\n- Output: \"The cat sat on the mat.\"\n- Ground Truth: \"The feline is sitting on the rug.\"\n\nExpected Output:\n{\n  \"extended_reasoning\": \"I need to compare 'The cat sat on the mat' with 'The feline is sitting on the rug.' First, let me identify the key elements: both describe an animal ('cat' vs 'feline') in a position ('sat' vs 'sitting') on a surface ('mat' vs 'rug'). The subject is semantically identical - 'cat' and 'feline' refer to the same animal. The action is also semantically equivalent - 'sat' and 'sitting' both describe the same position, though one is past tense and one is present continuous. The location differs in specific wording ('mat' vs 'rug') but both refer to floor coverings that serve the same function. The basic structure and meaning of both sentences are preserved, though they use different vocabulary and slightly different tense. The core information being conveyed is the same, but there are noticeable wording differences.\",\n  \"reasoning_summary\": \"The sentences differ in vocabulary choice ('cat' vs 'feline', 'mat' vs 'rug') and verb tense ('sat' vs 'is sitting').\",\n  \"score\": 3\n}\n\n**Example 2:**\n\nInput:\n- Output: \"The quick brown fox jumps over the lazy dog.\"\n- Ground Truth: \"A fast brown animal leaps over a sleeping canine.\"\n\nExpected Output:\n{\n  \"extended_reasoning\": \"I need to compare 'The quick brown fox jumps over the lazy dog' with 'A fast brown animal leaps over a sleeping canine.' Starting with the subjects: 'quick brown fox' vs 'fast brown animal'. Both describe the same entity (a fox is a type of animal) with the same attributes (quick/fast and brown). The action is described as 'jumps' vs 'leaps', which are synonymous verbs describing the same motion. The object in both sentences is a dog, described as 'lazy' in one and 'sleeping' in the other, which are related concepts (a sleeping dog could be perceived as lazy). The structure follows the same pattern: subject + action + over + object. The sentences convey the same scene with slightly different word choices that maintain the core meaning. The level of specificity differs slightly ('fox' vs 'animal', 'dog' vs 'canine'), but the underlying information and imagery remain very similar.\",\n  \"reasoning_summary\": \"The sentences use different but synonymous terminology ('quick' vs 'fast', 'jumps' vs 'leaps', 'lazy' vs 'sleeping') and varying levels of specificity ('fox' vs 'animal', 'dog' vs 'canine').\",\n  \"score\": 4\n}\n\n# Notes\n\n- Focus primarily on factual accuracy and semantic similarity, not writing style or phrasing differences.\n- Identify specific differences rather than making general assessments.\n- Pay special attention to dates, numbers, names, locations, and causal relationships when present.\n- Consider the significance of each difference in the context of the overall information.\n- Be consistent in your scoring approach across different evaluations.\n- Value the Citation if correct. False Citation is a negative factor. A missing Citation is strong negative factor.",
        "options": {},
        "operation": "setMetrics",
        "actualAnswer": "={{ $json.output || \"No output provided.\" }}",
        "expectedAnswer": "={{ $('Eval Set').item.json.answer }}"
      },
      "typeVersion": 4.7
    },
    {
      "id": "f9b69d7f-87c5-412e-844f-b198aa7b64d0",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        144,
        160
      ],
      "parameters": {
        "content": "## Hook up your own GSheet for saving Outputs"
      },
      "typeVersion": 1
    },
    {
      "id": "56ade4de-8554-4a50-9a9c-e0a9f4ad30b0",
      "name": "LLM as a Judge",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        576,
        496
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "gpt-4.1"
        },
        "options": {
          "temperature": 0.1,
          "responseFormat": "json_object"
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "787c3ae3-8d48-4cb3-8380-0f00a69962ed",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        144,
        432
      ],
      "parameters": {
        "color": 3,
        "height": 224,
        "content": "## Do not touch this!\n\n![I see you](https://cloud.let-the-work-flow.com/workflow-data/eval-emoji-72.png)\nSincerely,\n_Pure Eval_"
      },
      "typeVersion": 1
    },
    {
      "id": "c050a45d-7708-4981-8f87-09f97589e2e6",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -1568,
        -1216
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "81da391f-e1a8-4bec-8020-ba452132c46f",
      "name": "Mistral Upload",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -960,
        -912
      ],
      "parameters": {
        "url": "https://api.mistral.ai/v1/files",
        "method": "POST",
        "options": {},
        "sendBody": true,
        "contentType": "multipart-form-data",
        "authentication": "predefinedCredentialType",
        "bodyParameters": {
          "parameters": [
            {
              "name": "purpose",
              "value": "ocr"
            },
            {
              "name": "file",
              "parameterType": "formBinaryData",
              "inputDataFieldName": "data"
            }
          ]
        },
        "nodeCredentialType": "mistralCloudApi"
      },
      "credentials": {
        "mistralCloudApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1c48b0d2-8256-406f-86cc-c05f3b762117",
      "name": "Mistral Signed URL",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -640,
        -912
      ],
      "parameters": {
        "url": "=https://api.mistral.ai/v1/files/{{ $json.id }}/url",
        "options": {},
        "sendQuery": true,
        "sendHeaders": true,
        "authentication": "predefinedCredentialType",
        "queryParameters": {
          "parameters": [
            {
              "name": "expiry",
              "value": "24"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Accept",
              "value": "application/json"
            }
          ]
        },
        "nodeCredentialType": "mistralCloudApi"
      },
      "credentials": {
        "mistralCloudApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1868dc23-f486-4ec7-85e4-41ca7a677c7a",
      "name": "Mistral DOC OCR",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -320,
        -912
      ],
      "parameters": {
        "url": "https://api.mistral.ai/v1/ocr",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"model\": \"mistral-ocr-latest\",\n  \"document\": {\n    \"type\": \"document_url\",\n    \"document_url\": \"{{ $json.url }}\"\n  },\n  \"include_image_base64\": true\n}",
        "sendBody": true,
        "specifyBody": "json",
        "authentication": "predefinedCredentialType",
        "nodeCredentialType": "mistralCloudApi"
      },
      "credentials": {
        "mistralCloudApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "1795d977-cce8-42aa-a74e-9d8ac80bf5c5",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -1552,
        -640
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "1bc2beaf-c0da-41ec-95c4-740ae35cd55d",
      "name": "Refresh collection",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1248,
        -1216
      ],
      "parameters": {
        "url": "http://XX.XX.XX:6333/collections/agentic-arena/points/delete",
        "method": "POST",
        "options": {},
        "jsonBody": "{\n  \"filter\": {}\n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "83d76a59-2184-4d36-bb00-eb882c6882eb",
      "name": "Embeddings OpenAI",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        -768,
        -368
      ],
      "parameters": {
        "options": {
          "stripNewLines": false
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "f2170147-3b23-460c-b9d4-8d5554a8d90c",
      "name": "Default Data Loader",
      "type": "@n8n/n8n-nodes-langchain.documentDefaultDataLoader",
      "position": [
        -624,
        -400
      ],
      "parameters": {
        "options": {
          "metadata": {
            "metadataValues": [
              {
                "name": "document",
                "value": "={{$('Get PDF').item.binary.data.fileName}}"
              }
            ]
          }
        }
      },
      "typeVersion": 1
    },
    {
      "id": "8c819fbd-daa2-4390-af6e-10665073e0e7",
      "name": "Code",
      "type": "n8n-nodes-base.code",
      "position": [
        0,
        -912
      ],
      "parameters": {
        "jsCode": "const data = $json.pages;\n\nreturn data.map(entry => ({\n  json: {\n    markdown: entry.markdown\n  }\n}));"
      },
      "typeVersion": 2
    },
    {
      "id": "2f4108c9-9ac2-49e9-b9d1-52db9d50d518",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        -224,
        -624
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "994ae38c-8f8d-4dfb-9441-a72de0d32d3c",
      "name": "Qdrant Vector Store",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "position": [
        -704,
        -624
      ],
      "parameters": {
        "mode": "insert",
        "options": {},
        "qdrantCollection": {
          "__rl": true,
          "mode": "list",
          "value": "agentic-arena",
          "cachedResultName": "agentic-arena"
        }
      },
      "credentials": {
        "qdrantApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.1
    },
    {
      "id": "7304d3bc-929a-4e99-9663-b9e6ccee849d",
      "name": "Loop Over Items1",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        -592,
        -1216
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "77330811-3fc7-4cab-b370-c7053b99d613",
      "name": "When Executed by Another Workflow",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -1616,
        -912
      ],
      "parameters": {
        "inputSource": "passthrough"
      },
      "typeVersion": 1.1
    },
    {
      "id": "1de75150-f5a5-4eec-82d0-f1cf930babb0",
      "name": "Create collection",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        -1568,
        -1472
      ],
      "parameters": {
        "url": "http://XX.XX.XX:6333/collections/agentic-arena",
        "method": "PUT",
        "options": {},
        "jsonBody": "{\n  \"vectors\": {\n    \"size\": 1536,\n    \"distance\": \"Cosine\"  \n  },\n  \"shard_number\": 1,  \n  \"replication_factor\": 1,  \n  \"write_consistency_factor\": 1 \n}",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "46919cd2-4558-413e-8676-6dfc85b060fe",
      "name": "Set page",
      "type": "n8n-nodes-base.set",
      "position": [
        -1088,
        -624
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "189f4944-a692-423c-bc6d-76747e1d04df",
              "name": "text",
              "type": "string",
              "value": "={{ $json.markdown }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "fbfdd7d6-f648-4460-b645-7f98228eb57d",
      "name": "Search PDFs",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -896,
        -1216
      ],
      "parameters": {
        "filter": {
          "folderId": {
            "__rl": true,
            "mode": "list",
            "value": "1dbVllHyJvJqJs2P5lTzvhqP8NNCrqwVp",
            "cachedResultUrl": "https://drive.google.com/drive/folders/1dbVllHyJvJqJs2P5lTzvhqP8NNCrqwVp",
            "cachedResultName": "Agentic Arena"
          },
          "whatToSearch": "files"
        },
        "options": {},
        "resource": "fileFolder",
        "returnAll": true
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "0a35360d-17a7-4095-a93b-0c0ca6efa754",
      "name": "Get PDF",
      "type": "n8n-nodes-base.googleDrive",
      "position": [
        -1312,
        -912
      ],
      "parameters": {
        "fileId": {
          "__rl": true,
          "mode": "id",
          "value": "={{ $json.file_id }}"
        },
        "options": {},
        "operation": "download"
      },
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 3
    },
    {
      "id": "6f6ee381-0c36-4c59-823e-a7bb522ccc70",
      "name": "Character Text Splitter",
      "type": "@n8n/n8n-nodes-langchain.textSplitterCharacterTextSplitter",
      "position": [
        -608,
        -192
      ],
      "parameters": {
        "separator": "#",
        "chunkOverlap": 100
      },
      "typeVersion": 1
    },
    {
      "id": "003c9ac1-c683-4b5d-9a43-dbdaca687b37",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -880,
        336
      ],
      "parameters": {
        "text": "={{ $json.chatInput }}",
        "options": {
          "systemMessage": "=You are a Ministry of Finance (MoF) policy compliance assistant specialized in permit applications and regulatory analysis. Your role is to evaluate permit applications against established MoF policies and provide accurate determinations.\n\n**CORE INSTRUCTIONS:**\n1. **Always use the RAG tool** for each request to retrieve relevant policy information\n2. **Never invent or fabricate information** - only use verified policy data\n3. **Respond in English** with clear and professional language\n4. **Provide definitive determinations** - start with \"Yes\" or \"No\" followed by specific reasoning\n\n**RESPONSE STRUCTURE:**\n- **Opening determination:** Clear Yes/No or specific outcome statement\n- **Reasoning:** Concise explanation referencing specific policy requirements\n- **Citations:** Always include citations in format: Citation: [MoF Policy ###: Policy Name]\n\n**KEY ANALYSIS AREAS:**\n- Zone requirements and submission timelines\n- Payment timing (minimum 7 days before activation)\n- Entity type eligibility (nonprofit vs. for-profit restrictions)\n- Officer conflict of interest rules\n- Emergency processing classifications\n- Seasonal adjustment requirements\n- Fee calculations and waiver eligibility\n\n**EXAMPLE RESPONSE FORMAT:**\n```\nYes/No\u2014[specific violation]. [Timeline/requirement details], [consequences].\n\nCitation: [MoF Policy ###: Policy Name, MoF Policy ###: Policy Name]\n```\n\n**QUALITY STANDARDS:**\n- Be precise with dates, timelines, and calculations\n- Identify ALL applicable violations in complex cases\n- Reference multiple policies when relevant\n- Maintain professional, authoritative tone\n- Ensure legal accuracy and compliance\n\nAlways cross-reference multiple policies when evaluating complex scenarios involving multiple potential violations."
        },
        "promptType": "define"
      },
      "typeVersion": 2.2
    },
    {
      "id": "8d8a79c6-0055-4829-89f7-08b98399c157",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -768,
        528
      ],
      "parameters": {},
      "typeVersion": 1.3
    },
    {
      "id": "7e2250c0-a209-4c51-b87e-73193dc192d8",
      "name": "Reranker Cohere",
      "type": "@n8n/n8n-nodes-langchain.rerankerCohere",
      "position": [
        -512,
        704
      ],
      "parameters": {},
      "credentials": {
        "cohereApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "b89afe71-728c-497c-8f07-7c8ace131607",
      "name": "Embeddings OpenAI1",
      "type": "@n8n/n8n-nodes-langchain.embeddingsOpenAi",
      "position": [
        -672,
        704
      ],
      "parameters": {
        "options": {}
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "22f8a99c-77a1-4708-b086-b75723d82031",
      "name": "RAG",
      "type": "@n8n/n8n-nodes-langchain.vectorStoreQdrant",
      "position": [
        -640,
        528
      ],
      "parameters": {
        "mode": "retrieve-as-tool",
        "options": {},
        "useReranker": true,
        "toolDescription": "Search the RAG for questions you are asked\n",
        "qdrantCollection": {
          "__rl": true,
          "mode": "list",
          "value": "agentic-arena",
          "cachedResultName": "agentic-arena"
        }
      },
      "credentials": {
        "qdrantApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.3
    },
    {
      "id": "f0aec6e7-a4b4-43a6-a15b-890712c59703",
      "name": "Call 'Agent Arena'",
      "type": "n8n-nodes-base.executeWorkflow",
      "position": [
        32,
        -1200
      ],
      "parameters": {
        "mode": "each",
        "options": {
          "waitForSubWorkflow": true
        },
        "workflowId": {
          "__rl": true,
          "mode": "id",
          "value": "9wQdbEN53X1Q78fl"
        },
        "workflowInputs": {
          "value": {},
          "schema": [],
          "mappingMode": "defineBelow",
          "matchingColumns": [],
          "attemptToConvertTypes": false,
          "convertFieldsToString": true
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "c49b7933-592a-4cb7-86f5-fcba33269e4d",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -928,
        528
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4.1",
          "cachedResultName": "gpt-4.1"
        },
        "options": {
          "temperature": 0.1
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "315b9054-8eb6-48b7-a6b5-97663e5059f5",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1664,
        -2752
      ],
      "parameters": {
        "color": 3,
        "width": 1904,
        "height": 432,
        "content": "# Agentic Arena Community Contest\n\n## Overview\n\nThis competition challenges you to build a Retrieval-Augmented Generation (RAG) AI agent in n8n that can accurately answer questions based on a provided PDF knowledge base. \n\n## What You're Building\n\nYou'll create an n8n workflow that:\n\n- Ingests PDF documents into a vector database or knowledge retrieval system\n- Processes natural language questions about the content\n- Returns accurate answers based solely on the provided documentation with proper citations\n- Demonstrates high accuracy when tested against our evaluation questions\n\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "35156e25-624e-47cc-9d2d-48e4a335b970",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1664,
        -2288
      ],
      "parameters": {
        "color": 5,
        "width": 1904,
        "height": 352,
        "content": "\n## Rules\n\n### 1. PDF Knowledge Base\n- Find a folder with the [PDF files here](https://drive.google.com/drive/folders/1FqVwbNrAPn2dHhIwSEtlu5kl3z2jEC0U?usp=sharing).\n- Copy or download them for use from your own system\n\n### 2. Evaluation Set\n- Find the Google Sheet with the [evaluation set here](https://docs.google.com/spreadsheets/d/1cgZzr0-D5Kpd6HrKowyoN_fI2dY0dkP9Ljljxix0AlI/edit?usp=sharing).\n- Copy the Sheet to use it in your workflow\n\n### 3. Starter Workflow\n- [Download this starter workflow](https://file.notion.so/f/f/d147bfac-0bab-4c58-884f-f45c5f5a13e8/7f8419b8-7ac3-4c55-8c5c-e0874aa7a46f/AgenticArena_Challenge1_StarterWorkflow.json?table=block&id=2685b6e0-c94f-809b-905c-cf39f05e0e0f&spaceId=d147bfac-0bab-4c58-884f-f45c5f5a13e8&expirationTimestamp=1758902400000&signature=C3ERsAdCUDcvYkODZBR5LZLxx9q4_2Nk1XEqjgOQNOY&downloadName=AgenticArena_Challenge1_StarterWorkflow.json) and import into your n8n instance "
      },
      "typeVersion": 1
    },
    {
      "id": "4ca9e2fe-fa70-4f5e-b694-5e0c2c0d08fd",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1664,
        -1888
      ],
      "parameters": {
        "width": 1904,
        "height": 1856,
        "content": "## My Solution\n\n1. **Create a collection on Qdrant** (Self-hosted) - Set up a new vector collection in Qdrant for storing embeddings\n\n2. **Retrieve PDF files from Google Drive** - Download or access the PDF documents from Google Drive\n\n3. **Convert PDF documents using Mistral OCR** - Process the PDF files through Mistral's OCR (Optical Character Recognition) system to extract text\n\n4. **Embed documents in Qdrant Vector Store** - Generate embeddings for the extracted content and store them in the Qdrant vector database\n\n5. **Set up Evaluation Workflow with AI Agent** - Configure an evaluation workflow that includes:\n   - AI Agent integration\n   - Connection to Qdrant vector database\n   - Cohere reranker implementation\n   - GPT-4.1 model (or GPT-4o/GPT-4 Turbo, depending on the actual model being used)\n\n6. **Save output to Google Sheets** - Export and store the results in a [Google Sheets document](https://docs.google.com/spreadsheets/d/1ed0c-Nt4BTETlbwpCA3oTdp7Z_-h1om2tJGasOpPvbo/edit?usp=sharing)\n"
      },
      "typeVersion": 1
    },
    {
      "id": "fc396562-d642-46d9-a287-8357bf79b59f",
      "name": "Get File ID",
      "type": "n8n-nodes-base.set",
      "position": [
        -272,
        -1200
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "ca7c30f2-444d-4551-988d-0f513e5ee4b1",
              "name": "file_id",
              "type": "string",
              "value": "={{ $json.id }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "d7715ff3-8833-4b10-862e-0eb02f65c2ff",
  "connections": {
    "RAG": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Code": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get PDF": {
      "main": [
        [
          {
            "node": "Mistral Upload",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Agent": {
      "main": [
        [
          {
            "node": "Only if we are evaluating",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Eval Set": {
      "main": [
        [
          {
            "node": "Eval Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set page": {
      "main": [
        [
          {
            "node": "Qdrant Vector Store",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Eval Input": {
      "main": [
        [
          {
            "node": "Filter Empty Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get File ID": {
      "main": [
        [
          {
            "node": "Call 'Agent Arena'",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Search PDFs": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "LLM as a Judge": {
      "ai_languageModel": [
        [
          {
            "node": "Run Evaluation",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Mistral Upload": {
      "main": [
        [
          {
            "node": "Mistral Signed URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Evaluation": {
      "main": [
        [
          {
            "node": "Save Eval",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [],
        [
          {
            "node": "Set page",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Mistral DOC OCR": {
      "main": [
        [
          {
            "node": "Code",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Reranker Cohere": {
      "ai_reranker": [
        [
          {
            "node": "RAG",
            "type": "ai_reranker",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items1": {
      "main": [
        [],
        [
          {
            "node": "Get File ID",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI": {
      "ai_embedding": [
        [
          {
            "node": "Qdrant Vector Store",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Filter Empty Rows": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Call 'Agent Arena'": {
      "main": [
        [
          {
            "node": "Loop Over Items1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Embeddings OpenAI1": {
      "ai_embedding": [
        [
          {
            "node": "RAG",
            "type": "ai_embedding",
            "index": 0
          }
        ]
      ]
    },
    "Mistral Signed URL": {
      "main": [
        [
          {
            "node": "Mistral DOC OCR",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Refresh collection": {
      "main": [
        [
          {
            "node": "Search PDFs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Default Data Loader": {
      "ai_document": [
        [
          {
            "node": "Qdrant Vector Store",
            "type": "ai_document",
            "index": 0
          }
        ]
      ]
    },
    "Qdrant Vector Store": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Character Text Splitter": {
      "ai_textSplitter": [
        [
          {
            "node": "Default Data Loader",
            "type": "ai_textSplitter",
            "index": 0
          }
        ]
      ]
    },
    "Only if we are evaluating": {
      "main": [
        [
          {
            "node": "Run Evaluation",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond to Chat",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When Executed by Another Workflow": {
      "main": [
        [
          {
            "node": "Get PDF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Refresh collection",
            "type": "main",
            "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 workflow is my personal solution for the Agentic Arena Community Contest, where the goal is to build a Retrieval-Augmented Generation (RAG) AI agent capable of answering questions based on a provided PDF knowledge base.

Source: https://n8n.io/workflows/8944/ β€” 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

πŸ“Œ Overview

Redis, WhatsApp, OpenAI Chat +12
AI & RAG

Your AI workforce is ready. Are you?

Google Sheets Tool, Mcp Trigger, Google Drive +29
AI & RAG

This comprehensive workflow bundle is designed as a powerful starter kit, enabling you to build a multi-functional AI assistant on Telegram. It seamlessly integrates AI-powered voice interactions, an

Telegram Trigger, Telegram, OpenAI +19
AI & RAG

This advanced n8n workflow automates the full lead enrichment, qualification, and personalized outreach process tailored specifically for the B2B real estate sector. Integrating top platforms like Api

N8N Nodes Fillout, OpenAI Chat, Pinecone Vector Store +11
AI & RAG

This n8n template automatically classifies incoming emails (Sales, Support, Internal, Finance, Promotions) and routes them to a dedicated OpenAI LLM Agent for processing. Depending on the category, th

OpenAI, Gmail, Text Classifier +16