AI Agent Orchestration with Bright Data and Dynamic Tool Calling - n8n Workflow

Automate complex data collection by integrating Bright Data MCP tools with an OpenAI-powered n8n agent. Use this powerful n8n workflow for dynamic, data-driven queries.

Workflow Preview

Ready to automate?

Download this n8n workflow template and start using it instantly.

Who is this best for?

Users needing dynamic, real-time web data extraction within an n8n framework.
Developers building AI assistants that require external, robust data services.
Businesses implementing advanced n8n workflow solutions for context-aware customer interactions.
Anyone looking for advanced examples of using Langchain n8n node types for AI agents.

Overview

This advanced n8n templates solution tackles the challenge of building flexible AI assistants capable of utilizing external, specialized tools based on unstructured chat input. By leveraging the Langchain suite of n8n node types, coupled with the Bright Data Managed Collection Platform (MCP), this n8n workflow intelligently parses a user's request. It determines if the request requires data collection (like a Google search or scraping a social media profile), identifies the exact Bright Data tool needed, executes that tool using the dedicated Bright Data n8n node, and feeds the structured result back to the AI for a coherent response. This ensures your n8n workflow automation is exceptionally powerful and context-aware, demonstrating a best-practice use of the n8n platform for AI orchestration.

How it Works

The entire process is initiated by an n8n trigger and managed by a sophisticated AI orchestration loop:


  1. Trigger and Orchestration: The process begins with the When chat message received n8n trigger, initiating the n8n workflow upon a new user message. The primary AI Agent n8n node orchestrates the entire flow, utilizing the connected OpenAI model and the Execute the tool n8n node.

  2. Tool Delegation: When the AI agent determines that external data is needed, the query is passed to a linked sub-workflow (triggered by the Tool call by the chatbot n8n trigger).

  3. Tool Listing: Within the sub-workflow, the Bright Data MCP - List tools n8n node retrieves all available data extraction tools and their required schemas from Bright Data.

  4. AI Classification: The dedicated OpenAI n8n node acts as a sophisticated classifier. It compares the user's query against the available tool schemas and outputs the selected tool name and necessary parameters in a structured JSON format.

  5. Conditional Check: Conditional logic (If nodes) then verifies the OpenAI classification. If no tool matches, or if critical parameters are missing, the n8n workflow prepares a message asking the user for clarification.

  6. Tool Execution: If a tool is successfully matched and parameters are sufficient, the Bright Data MCP - Execute a tool n8n node runs the dynamic web scraping or data lookup operation.

  7. Memory Management: The result from Bright Data is captured and immediately updated within the session context using the Chat Memory Manager n8n node. This crucial step ensures the primary AI Agent has the necessary context from the tool execution to generate the final, informed response to the user's initial message. This completes the sophisticated data retrieval and response cycle within the n8n workflow.

Installation Guide

To deploy this comprehensive n8n workflow, follow these steps:


  1. Import the n8n workflow: Copy the provided JSON code and import it directly into your n8n instance.

  2. OpenAI Credentials: Set up credentials for the OpenAI Chat Model node (ed34d7d0-572e-4022-6a710f1e2802) and the classifier OpenAI node (bb56e06d-ea56-475c-b64c-e96c52532a1e). Ensure you use the correct API keys.

  3. Bright Data Credentials: Configure the MCP Client (STDIO) credentials for the Bright Data MCP - List tools and Bright Data MCP - Execute a tool n8n node instances.

  4. Tool Workflow Link: Crucially, ensure the Execute the tool n8n node points to the correct linked sub-workflow ID that houses the classification logic (the ID mZxPCcrfdwSgZDUQ referenced in the template must correspond to the imported sub-workflow, if using a parent/child n8n workflow structure).

  5. Activate: Activate the When chat message received n8n trigger to start listening for incoming chat messages.

Node Details

This n8n workflow uses a combination of Langchain, Bright Data, and core logic n8n node types:

When chat message received (n8n trigger):
Function: Initiates the n8n workflow upon receiving a chat message query, serving as the primary n8n trigger.
Key Configuration: Requires a configured webhook/chat interface connection.
AI Agent (Langchain n8n node):
Function: The central decision-maker. It decides whether to answer directly or utilize the defined external tool.
Key Configuration: Linked to the OpenAI Chat Model, Simple Memory, and the Execute the tool n8n node.
OpenAI Chat Model (Langchain n8n node):
Function: Provides the conversational reasoning power for the AI Agent.
Key Configuration: Uses gpt-4.1-nano (or equivalent) and requires OpenAI credentials.
Bright Data MCP - List tools (n8n node):
Function: Retrieves the current list of available Bright Data Managed Collection Platform tools and their required input schemas.
Key Configuration: Requires MCP Client credentials.
OpenAI (Classifier n8n node):
Function: Analyzes the user query against the retrieved tool list and determines the best tool to call, outputting precise JSON parameters. This custom instruction set is critical for the success of this n8n workflow.
Key Configuration: Uses a System Message prompt instructing the model to match the query to a tool schema and return JSON.
If/If1 (Core Logic n8n node):
Function: Manages the flow by checking two conditions: if a tool was identified, and if all necessary parameters were provided by the user.
Bright Data MCP - Execute a tool (n8n node):
Function: Executes the specific data collection task defined by the AI (e.g., searchengine or webdatalinkedinperson_profile).
Key Configuration: Dynamically pulls toolName and toolParameters from the preceding AI classification step.
Chat Memory Manager (Langchain n8n node):
Function: Ensures the response from the executed tool is added to the agent's memory, maintaining context for the ongoing conversation within the n8n workflow session.

Related n8n Workflows

Free

Nodes: 12 Nodes
Updated: December 26 2025
View all

Featured*