{
  "name": "Automate Document Q&A with Multi-Agent RAG Orchestration using Contextual AI & Gemini",
  "nodes": [
    {
      "id": "3fc78343-dd47-4b2a-926c-f366c47fd1cc",
      "name": "Create Agent",
      "type": "n8n-nodes-contextualai.contextualAi",
      "position": [
        288,
        112
      ]
    },
    {
      "id": "9afd4c74-47cc-4ecf-ab7b-ef7df2e3d88b",
      "name": "Submit Agent Information",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        -160,
        112
      ]
    },
    {
      "id": "f0cae1d6-6af5-4d06-90d4-e754e7bd4d22",
      "name": "Preprocessing Step",
      "type": "n8n-nodes-base.code",
      "position": [
        64,
        112
      ]
    },
    {
      "id": "db104ab2-8ccb-4ab0-aca1-88ed528e539f",
      "name": "Agent Orchestrator",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        192,
        448
      ]
    },
    {
      "id": "58ad8395-3866-4cf2-a101-c4e6dd24186a",
      "name": "Chat",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -160,
        448
      ]
    },
    {
      "id": "37877c08-6529-4b48-a039-b4ccc8128231",
      "name": "Google Gemini Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatGoogleGemini",
      "position": [
        32,
        672
      ]
    },
    {
      "id": "96aa07fe-7b74-41ea-af24-41c0aaeb11e1",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        192,
        672
      ]
    },
    {
      "id": "6da227ee-1f51-447a-b13e-23ae53cdbd5b",
      "name": "Query Agent Tool",
      "type": "n8n-nodes-contextualai.contextualAiTool",
      "position": [
        336,
        672
      ]
    },
    {
      "id": "212f4d81-bc46-4ee3-afa9-debfb6dca484",
      "name": "List Agents Tool",
      "type": "n8n-nodes-contextualai.contextualAiTool",
      "position": [
        480,
        672
      ]
    },
    {
      "id": "b4e66a87-4f35-4b62-80d8-2973d478d5c8",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -736,
        -144
      ],
      "parameters": {
        "width": 480,
        "height": 1312,
        "content": "# RAG Multi-Agent Orchestration with Contextual AI Query Tool and Gemini 2.5 Flash\n\n## PROBLEM  \nManaging multiple RAG AI agents can be complex when each has its own purpose and vector database.  \n- M"
      }
    },
    {
      "id": "96446a81-d558-4261-8f00-28678d5baa20",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        -144
      ],
      "parameters": {
        "width": 1808,
        "height": 448,
        "content": "### 1: Form Submission  \nUsers submit a form to create a new RAG agent by providing the **agent name**, **description**, **datastore name** and uploading relevant **documents**. Then, we iterate over "
      }
    },
    {
      "id": "96195bc9-9ede-45eb-8c26-60a8bf46cee3",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -224,
        320
      ],
      "parameters": {
        "width": 992,
        "height": 496,
        "content": "### Step 2: Query and Retrieval  \nUsers can enter a query, and the workflow automatically identifies the most relevant RAG agent based on the query and provides users with grounded answers.\n"
      }
    },
    {
      "id": "7a94b05a-46ff-4b54-be80-c8038ca7052e",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        512,
        112
      ]
    },
    {
      "id": "1d2b3eab-8937-4f20-9619-994cfa711a59",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        960,
        48
      ]
    },
    {
      "id": "a32883c4-bee5-4922-854c-b4a3ae25226d",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        1408,
        112
      ]
    },
    {
      "id": "4c41e78c-2c4b-4bd7-94a3-278d4335f086",
      "name": "Iterate over each files",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        736,
        112
      ]
    },
    {
      "id": "b48205ed-227d-468f-88e6-e7da8230427a",
      "name": "Get Document Ingestion Status",
      "type": "n8n-nodes-contextualai.contextualAi",
      "position": [
        1184,
        -32
      ]
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Iterate over each files",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Chat": {
      "main": [
        [
          {
            "node": "Agent Orchestrator",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Get Document Ingestion Status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Iterate over each files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Agent": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "Agent Orchestrator",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "List Agents Tool": {
      "ai_tool": [
        [
          {
            "node": "Agent Orchestrator",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Query Agent Tool": {
      "ai_tool": [
        [
          {
            "node": "Agent Orchestrator",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Preprocessing Step": {
      "main": [
        [
          {
            "node": "Create Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Iterate over each files": {
      "main": [
        [],
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google Gemini Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Agent Orchestrator",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Submit Agent Information": {
      "main": [
        [
          {
            "node": "Preprocessing Step",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get Document Ingestion Status": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}