Calling subworkflows

Hello.

I’ve recently started to build projects with n8n and I’d love to learn how to call another agent from my main agent

This is the main concept of my project, but I have not successfully execute all workflow because my main agent does not call my sub-agent.

1 Like

Hi @Rafael_Rezende Welcome!
To Call your sub-agent from your principle agent, you typically need to set it up for the execution so that it can call it seamlessly.

The workflow should look like this:

And For principle agent’s tool (call sub workflow) the settings should look like this:

So in that field your sub workflow would be shown when it is published so make sure it is published and once you will select it will not show you that Search Query and it will only be shown when you will set that up in the sub agent workflow trigger which is “When executed by another workflow” that side would look like this:

So when you will set this up and will publish this sub workflow, then in your main agent’s tool for calling workflows would reflect the name of this sub workflow file, and then you will be able to see this feild and just click on that magic ICON so that AI will take over to that, And that is how it is done, hope this helps.

1 Like

@Rafael_Rezende The key is to create Tools in your main agent that trigger your sub-agent workflows.

Architecture Overview

Main Agent (Coordinator)
  ├── Tool 1: Call Research Agent
  ├── Tool 2: Call Analysis Agent  
  └── Tool 3: Call Writing Agent

Each tool → HTTP Request → Sub-agent workflow webhook

Step-by-Step Implementation

Step 1: Create Sub-Agent Workflows

Each sub-agent needs its own workflow with a Webhook trigger:

Research Agent Workflow:

Webhook Trigger (POST)
  → AI Agent (Research specialist)
      System Prompt: "You are a research specialist. 
                      Analyze the query and provide detailed research."
  → Respond to Webhook (return results)

Webhook Configuration:

  • Method: POST

  • Path: research-agent (or any unique path)

  • Response Mode: “Respond to Webhook”

AI Agent System Prompt Example:

You are a research specialist agent.

Your role:
- Gather and analyze information
- Provide factual, well-researched responses
- Cite sources when possible

Input format: You'll receive a "query" field with the research question.
Output format: Return a JSON object with "findings" and "sources".

In your Main Agent workflow, add HTTP Request Tool nodes:

Tool Configuration for Research Agent:

HTTP Request Tool Node:

  • Name: “Call Research Agent”

  • Description: “Use this tool when you need to research information or gather facts. Provide a clear research query.”

  • Method: POST

  • URL: https://your-n8n-instance.com/webhook/research-agent

  • Send Body: Yes

  • Body Content Type: JSON

  • Specify Body: Using Fields Below

    • Field: query

    • Value: ={{ $json.query }} (this comes from the AI’s tool call)

Step 3: Configure Main Agent

Main Agent System Prompt:

You are a coordinator agent that manages specialized sub-agents.

Available agents:
1. Research Agent - Use for gathering information and facts
2. Analysis Agent - Use for analyzing data and drawing conclusions
3. Writing Agent - Use for creating written content

Your process:
1. Understand the user's request
2. Determine which sub-agents to consult
3. Call the appropriate agents using your tools
4. Synthesize their responses into a final answer

Always explain which agents you're consulting and why.

Connect Tools to Agent:

  1. Add your AI Agent node

  2. In the Tools section, connect your HTTP Request Tool nodes

  3. The agent will automatically see these as available tools

Hope this helps!

1 Like

Hi! Thanks for answering so fast, but I can’t find the Workflow inputs under my main agent call workflow tool

1 Like

Hey @Rafael_Rezende this is because in the sub agent you have not configured the input data fields which are:

Fill those and refresh the main agent calling tool and it will come up just as expected.

1 Like

Thank you so much!! It worked now, cheers and have a good day sir :slight_smile:

1 Like

This topic was automatically closed 7 days after the last reply. New replies are no longer allowed.