{
  "name": "Query-to-action automation with Bright Data MCP & OpenAI GPT",
  "nodes": [
    {
      "id": "45ba993f-2078-4119-8722-6a710f1e2802",
      "name": "AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        -1308,
        500
      ]
    },
    {
      "id": "2e4ded08-f4a0-4b7e-b833-ff1f8228a078",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        -1560,
        500
      ]
    },
    {
      "id": "ed34d7d0-572e-4022-b14d-b7c1ead42240",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        -1340,
        720
      ]
    },
    {
      "id": "ffbcd9d2-4276-48bc-aa39-dc97f07ca6d5",
      "name": "Simple Memory",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        -1220,
        720
      ]
    },
    {
      "id": "b42d7a27-cc18-4d5c-b169-b041816e4ccc",
      "name": "Execute the tool",
      "type": "@n8n/n8n-nodes-langchain.toolWorkflow",
      "position": [
        -1100,
        720
      ]
    },
    {
      "id": "bb56e06d-ea56-475c-b64c-e96c52532a1e",
      "name": "OpenAI",
      "type": "@n8n/n8n-nodes-langchain.openAi",
      "position": [
        -1300,
        1440
      ]
    },
    {
      "id": "40d20726-6c0c-4688-8623-5b9c5cd0bb94",
      "name": "If1",
      "type": "n8n-nodes-base.if",
      "position": [
        -580,
        1400
      ]
    },
    {
      "id": "c6f20cd6-64d8-4ad2-9b13-cc4bf40b0e4a",
      "name": "Edit Fields1",
      "type": "n8n-nodes-base.set",
      "position": [
        -360,
        1560
      ]
    },
    {
      "id": "5d9824a6-a5aa-444d-b34d-d23b0b463de3",
      "name": "Chat Memory Manager",
      "type": "@n8n/n8n-nodes-langchain.memoryManager",
      "position": [
        120,
        1240
      ]
    },
    {
      "id": "0d030063-0675-4397-bbf3-6d884b266cde",
      "name": "Simple Memory1",
      "type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
      "position": [
        120,
        1400
      ]
    },
    {
      "id": "47106d93-fa33-49f7-bc79-ecd6ab6866de",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        -860,
        1440
      ]
    },
    {
      "id": "8f640b71-3e7d-40f1-a636-de1cca8ba46a",
      "name": "Return error message for no matching tool",
      "type": "n8n-nodes-base.set",
      "position": [
        -680,
        1580
      ]
    },
    {
      "id": "a8e64261-225f-43e5-8530-65bea38a5657",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1720,
        340
      ],
      "parameters": {
        "width": 1000,
        "height": 540,
        "content": "## AI Chat Agent\nYou may use any AI model. Make sure to point the 'Execute the Tool' tool to the correct sub-workflow."
      }
    },
    {
      "id": "bfb5099c-5fac-47ba-9fe0-20a571a6b0e8",
      "name": "Tool call by the chatbot",
      "type": "n8n-nodes-base.executeWorkflowTrigger",
      "position": [
        -2120,
        1420
      ]
    },
    {
      "id": "9235d4c6-1ac2-41fd-9b60-c491de53aa6d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1880,
        1280
      ],
      "parameters": {
        "width": 460,
        "height": 480,
        "content": "## Retrieve all possible tools\nTo minimize the time to get all the tools, store all the results in Edit Field node or Code node."
      }
    },
    {
      "id": "18568e11-908e-4b70-980f-c19a2f572499",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -1380,
        1280
      ],
      "parameters": {
        "width": 440,
        "height": 480,
        "content": "## Classify the query and match it with the appropriate MCP tool.\nThe tool will return a JSON object containing the tool’s name and its parameters, adhering to the schema of a specific tool."
      }
    },
    {
      "id": "88cbcb2b-10c8-4538-b27d-9ffa8cf99fd0",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -920,
        1280
      ],
      "parameters": {
        "width": 760,
        "height": 480,
        "content": "## Verify the output\nCheck the output from OpenAI if it needs some info from the user or there's no matchin tool from their inquiry."
      }
    },
    {
      "id": "f5c45d2d-0ac1-4a4c-b052-bc01eef6c1c9",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -120,
        1120
      ],
      "parameters": {
        "width": 760,
        "height": 480,
        "content": "## Deliver the output to the AI Agent"
      }
    },
    {
      "id": "52353143-f1a6-4146-99c1-80c9518a87e9",
      "name": "Copy the output from the MCP tool",
      "type": "n8n-nodes-base.set",
      "position": [
        460,
        1240
      ]
    },
    {
      "id": "844bd15c-e6ed-4077-8f12-3c5cee55c2c0",
      "name": "Bright Data MCP - List tools",
      "type": "n8n-nodes-mcp.mcpClient",
      "position": [
        -1720,
        1440
      ]
    },
    {
      "id": "3fb02605-054b-43c5-b9bd-2b798323372c",
      "name": "Bright Data MCP - Execute a tool",
      "type": "n8n-nodes-mcp.mcpClient",
      "position": [
        -60,
        1380
      ]
    }
  ],
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Return error message for no matching tool",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Bright Data MCP - Execute a tool",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Edit Fields1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory": {
      "ai_memory": [
        [
          {
            "node": "AI Agent",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Simple Memory1": {
      "ai_memory": [
        [
          {
            "node": "Chat Memory Manager",
            "type": "ai_memory",
            "index": 0
          }
        ]
      ]
    },
    "Execute the tool": {
      "ai_tool": [
        [
          {
            "node": "AI Agent",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Chat Memory Manager": {
      "main": [
        [
          {
            "node": "Copy the output from the MCP tool",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Tool call by the chatbot": {
      "main": [
        [
          {
            "node": "Bright Data MCP - List tools",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bright Data MCP - List tools": {
      "main": [
        [
          {
            "node": "OpenAI",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Bright Data MCP - Execute a tool": {
      "main": [
        [
          {
            "node": "Chat Memory Manager",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}