Need help with workflow

Hi everyone. I’m new to building workflows in n8n.
I need a little help finishing my workflow.

I created an AI agent that should accept package requests from clients and send them to Google Sheets, as well as answer client questions. I want to delegate tasks between agents.

So, I made a main AI agent whose job is to understand the client’s request and forward it to the agent that can handle it.
If it’s a question, the Consultant agent should respond.
If it’s a shipping request, the Package Manager agent should handle it.

But I can’t figure out how to make the main AI agent send tasks to the other two agents.
I’ve tried many different options, but nothing has worked so far.

I’d really appreciate your help.

1 Like

Hi @Alex6

Instead of using multiple agents in your main workflow, set it up with sub workflows. Use a system prompt to tell the main agent when to use each sub workflow tool. Here’s an example.

The solution in this post uses a sub workflow as a tool. How to Pass Subflow Outputs Back to the Main Flow: Resolving Return Value Issues - #2 by rbreen

If this answer solves your question, please mark it as the solution so others can benifit as well.

Hi i guess you just need to replace your main agent with this

2 Likes

u can use a switch, between the main and subs, sure need to get the main ai agent to format the data out structed ie use json by using "Require Specific Output Format
" tick that box in the ai agent, specify the json example by selecting the plus on output parser and picking Structured Output Parser json, provide an example json with the data and a field for the switch and u should be able to only process depending on the first ai agent out.

Hope that makes sense, or you could have a main agent which uses tools, to call subworkflows which have ai agents in? up to you :slight_smile:

1 Like


Hi @rbreen . I tried doing as you suggested, but I keep encountering an error every time. I watched many guides before writing here and also tried to solve this problem with ChatGPT, but it didn’t work. I connected the “consultant” tool to the AI agent, but I can’t understand why the message “How do I send a package?” isn’t being passed on to the other workflow (consultant).

1 Like

@tridi Thank you, but this method doesn’t quite work.

1 Like

Hi @Alex6

In your sub workflow, use this as the prompt. Set it as define below, and pass in {{json.query}}

If that doesn’t work, include both of your n8n workflows in a code block in this forum. That will help solve the issue.

Robert

@rbreen If it’s not too much trouble, could you show me? I didn’t quite understand you.

1 Like

@Alex6

Here’s a video. Copy the sub workflow and paste it in the workflow tool.
2025-05-2008-55-01-ezgif.com-video-to-gif-converter