AI Workflow Builder (EE)
Relevant source files
The following files were used as context for generating this wiki page:
- packages/@n8n/ai-workflow-builder.ee/src/workflow-builder-agent.ts
- packages/@n8n/ai-workflow-builder.ee/src/tools/add-node.tool.ts
- packages/@n8n/ai-workflow-builder.ee/src/chains/planner.ts
- packages/@n8n/ai-workflow-builder.ee/src/ai-workflow-builder-agent.service.ts
- packages/frontend/editor-ui/src/constants.ts
- packages/frontend/editor-ui/src/utils/templates/samples/agents/task_management_agent_with_google_sheets.json
- packages/nodes-base/nodes/HttpRequest/HttpRequest.node.json
The AI Workflow Builder is an experimental, enterprise-level feature designed to construct and modify n8n workflows using natural language prompts. It functions as an AI agent that interprets user requests, creates a step-by-step plan, and executes that plan by programmatically adding and configuring nodes on the workflow canvas. This allows for a more intuitive and rapid workflow creation process, abstracting away the manual steps of searching for nodes and setting up their basic connections.
This feature is managed via an experiment flag, WORKFLOW_BUILDER_EXPERIMENT, indicating its developmental status. The core of the builder is an agent that leverages a planner and a suite of tools to manipulate the workflow structure.
Sources: packages/frontend/editor-ui/src/constants.ts:510-514, packages/@n8n/ai-workflow-builder.ee/src/ai-workflow-builder-agent.service.ts
Architecture
The AI Workflow Builder's architecture is composed of a service layer, a core agent, a planner, and a set of specialized tools. The AiWorkflowBuilderAgentService acts as the main entry point, receiving user prompts and orchestrating the workflow generation process. It initializes and invokes the WorkflowBuilderAgent, which in turn uses a Planner to devise a strategy and Tools to execute it.
This diagram illustrates the high-level architecture of the AI Workflow Builder.
Core Components
| Component | Description | Source File |
|---|---|---|
AiWorkflowBuilderAgentService | The primary service that handles incoming requests. It initializes the agent with the current workflow state and available nodes, runs the agent, and returns the modified workflow. | ai-workflow-builder-agent.service.ts |
WorkflowBuilderAgent | The central agent responsible for processing the user's request. It uses a planner to break down the request into executable steps and then invokes the appropriate tools to perform actions like adding nodes. | workflow-builder-agent.ts |
Planner | A chain responsible for creating a multi-step plan from the user's prompt and the available tools. It outputs a series of steps that the agent will execute sequentially. | planner.ts |
Tools | A collection of functions that the agent can use to interact with the workflow canvas. Each tool is designed for a specific action, such as adding a new node. Example: AddNodeTool. | add-node.tool.ts |
Data Flow
The process begins when a user submits a natural language prompt. The AiWorkflowBuilderAgentService receives this prompt along with the current state of the workflow. It then invokes the WorkflowBuilderAgent. The agent passes the prompt and the list of available tools to the Planner, which returns a structured plan. The agent executes each step of the plan, calling the necessary tools to modify the workflow JSON.
The following sequence diagram shows the interaction between the components.
Agent Tools
The agent's capabilities are defined by its tools. These are structured classes that allow the agent to perform specific, discrete actions on the workflow.
AddNodeTool
The AddNodeTool is a prime example of a tool used by the builder. It is responsible for adding a new node to the workflow.
- Name:
add-node - Description: "Use this to add a new node to the workflow."
- Schema (Input): It takes a single argument,
nodeName, which is the name of the node to add (e.g., "n8n-nodes-base.httpRequest"). The tool validates this against a list of available nodes.
When executed, this tool finds the specified node's definition, creates a new node instance with default parameters, and adds it to the workflow's node list.
Sources: packages/@n8n/ai-workflow-builder.ee/src/tools/add-node.tool.ts:13-48
Example: Task Management Agent Workflow
While the AI Workflow Builder is a tool for creating workflows, it can be used to build other agents. The "Task management agent (with Google Sheets)" is a pre-built template that demonstrates an agent living inside a workflow. This type of workflow could potentially be constructed by the AI Workflow Builder.
This agent uses a chat trigger, a language model, memory, and several Google Sheets tools to manage a task list.
The diagram below shows the structure of the Task Management Agent workflow.
This workflow is composed of the following key nodes:
| Node Name in Template | Node Type | Purpose |
|---|---|---|
| When chat message received | @n8n/n8n-nodes-langchain.chatTrigger | The entry point for user interaction via chat. |
| Task management agent | @n8n/n8n-nodes-langchain.agent | The core agent that orchestrates the use of the model, memory, and tools based on a system prompt. |
| Model | @n8n/n8n-nodes-langchain.lmChatOpenAi | The language model (e.g., GPT-4o) that provides the intelligence. |
| Simple Memory | @n8n/n8n-nodes-langchain.memoryBufferWindow | Remembers the last few turns of the conversation for context. |
| Get tasks | n8n-nodes-base.googleSheetsTool | A tool for the agent to read tasks from a Google Sheet. |
| Create task | n8n-nodes-base.googleSheetsTool | A tool for the agent to add a new task to the sheet. |
| Update task | n8n-nodes-base.googleSheetsTool | A tool for the agent to modify an existing task. |
| Delete task | n8n-nodes-base.googleSheetsTool | A tool for the agent to remove a task from the sheet. |
Summary
The AI Workflow Builder (EE) is a powerful, agent-based system that translates natural language into n8n workflows. By combining a planning module with a set of executable tools, it automates the process of adding and configuring nodes, significantly accelerating development and making workflow creation more accessible. While still in an experimental phase, it represents a major step towards AI-driven workflow automation within the n8n platform.