Block 1 - OpenAI Chat Model
- Type / Role
- @n8n/n8n-nodes-langchain.lmChatOpenAi - lmChatOpenAi
- Config choices
- Version 1.2
This workflow is provided as-is. Please review and test before using in production.
This guide walks you through building an intelligent AI Agent in n8n that routes tasks to the appropriate sub agent using the new agent framework. You’ll create a Manager Agent that evaluates user ...
@n8n/n8n-nodes-langchain.lmchatopenai, @n8n/n8n-nodes-langchain.memorybufferwindow, @n8n/n8n-nodes-langchain.agenttool, @n8n/n8n-nodes-langchain.agent, n8n-nodes-base.stickynote
This workflow is cataloged by N8N Workflows and links back to its original n8n.io source page by Robert Breen.
Original n8n.io sourceThis guide walks you through building an intelligent AI Agent in n8n that routes tasks to the appropriate sub-agent using the new @n8n/n8n-nodes-langchain agent framework. You’ll create a Manager Agent that evaluates user input and delegates it to either an Email Agent or a Data Agent—each with its own role, memory, and OpenAI model.
This is perfect for use cases where you want a single entry point but intelligent branching behind the scenes.
Start by dragging in an Agent node and name it something like ManagerAgent. This agent will act as the “brain” of your system, analyzing the user's input and determining whether it should be handled by the email-writing sub-agent or the data-summary sub-agent.
Open the node’s settings and paste the following into the System Message:
You are an AI Manager that delegates tasks to specialized agents. Your job is to analyze the user's message and decide whether it requires:
An EmailAgent for writing outreach, follow-up, or templated emails, or
A DataAgent for tasks involving data summaries, metrics, or analysis.
Send the instructions to the sub agents.
This instruction gives the Manager Agent clarity on what roles exist and what types of tasks belong to each one.
Drag in a Memory (BufferWindow) node and label it Manager Memory. Connect it to the ai_memory input of the Manager Agent. This ensures the agent can remember recent inputs and outputs from the user and agents during the conversation.
No extra configuration is needed in this memory node—just connect it to the agent.
Next, add a Language Model node and choose OpenAI Chat Model. Select a model like gpt-4o-mini or gpt-4, depending on what you have access to. Under Credentials, connect your OpenAI API key. If you haven’t created this credential yet:
Once the model is set, connect it to the ai_languageModel input of the Manager Agent.
Now you’ll create a specialized sub-agent that only writes emails.
Add an Agent Tool node and call it EmailAgent. In the tool’s settings, describe its job clearly. For example:
Writes professional, friendly, or action-oriented emails based on instructions.
Then scroll down to the System Message section and enter the following:
You are a professional Email Writing Assistant. You write polished, effective emails for tasks such as outreach, follow-ups, and client communication. Follow the instruction provided exactly and return only the email content. Use a warm, business-appropriate tone.
For the text input field, use the expression:
{{ $fromAI('Prompt__User_Message_', ``, 'string') }}
This allows the Email Agent to receive exactly what the Manager Agent wants it to handle.
Add another Memory node and link it to this tool to help it maintain short-term context. Then add a second Language Model node, configured just like the first one (you can even clone it), and connect it to the EmailAgent.
Finally, connect this entire EmailAgent setup back to the ManagerAgent by attaching it to its ai_tool input.
Repeat the same steps, but this time for data summaries and analysis.
Add another Agent Tool node and name it DataAgent. In the Tool Description, write something like:
Responds to instructions requiring metrics, summaries, or data analysis explanations.
For its input text field, you can use:
{{json.query}}
If desired, provide a system message that gives the agent more detailed instruction on how to behave:
You are a helpful Data Analyst. Summarize trends, explain metrics, and break down data clearly based on user instructions.
As with the EmailAgent, you’ll also need:
ai_tool input of the Manager AgentNow the Manager Agent has two tools it can delegate to: one for communication and one for insights.
Deploy the workflow and start testing by sending prompts like:
> “Write a cold outreach email to a software company.”
The ManagerAgent should route that to the EmailAgent.
Then try:
> “Summarize how our lead volume changed last month.”
The DataAgent should receive that task.
If routing isn’t working as expected, double-check your system messages and input bindings in each agent tool.
You now have a modular, multi-agent AI system powered by n8n. The Manager Agent delegates intelligently, each sub-agent is optimized for its role, and all of them benefit from context memory.
For more advanced setups, you can chain tools, add additional memory types, or use retrieval (RAG) tools for external document support.
This catalog entry is organized from the workflow JSON. The node-level section below shows the executable blocks available for review before importing the template.
| Workflow | Beginner manager agent with sub-agent tools |
|---|---|
| Complexity | intermediate |
| Nodes | 13 |
| Categories | Engineering, Multimodal AI |
| Author | Robert Breen |
| Published | 08 Aug 2025 |
Use the JSON export at /data/workflows/7158/7158.json as the source template for this automation.
Open n8n, import the downloaded JSON, and review each node before activating the workflow.
Replace placeholder credentials, API keys, webhook URLs, account IDs, and environment-specific values with your own settings.
Run the workflow manually or in a staging workspace, inspect node output, and confirm downstream systems receive the expected data.
Enable the workflow only after testing, then monitor executions, errors, and rate limits during the first production runs.
Review imported nodes carefully before activation. This catalog entry is intended to help you inspect the workflow structure, understand required services, and find related templates faster.
Node names, credentials, schedules, webhook paths, and external service limits may need adjustment for your workspace.
This guide walks you through building an intelligent AI Agent in n8n that routes tasks to the appropriate sub agent using the new agent framework. You’ll create a Manager Agent that evaluates user ...
Review the workflow JSON, configure any required credentials in n8n, and test the automation in a safe workspace before using it in production.
Yes. Use the block-by-block analysis and the downloadable JSON to inspect each node, then adjust credentials, prompts, schedules, filters, or destinations for your Engineering, Multimodal AI use case.