DEV Community

KrisYing
KrisYing

Posted on

Multi-Agent AI in n8n: 3 Parallel Agents for Competitive Intelligence

Agentic AI is the hottest topic in software development right now. Every week there is a new framework — LangChain, CrewAI, AutoGen, LlamaIndex Workflows — promising to make multi-agent systems accessible. But if you are already using n8n for automation, you can build a surprisingly capable multi-agent pipeline today with no new dependencies, no Python environments, and no infrastructure changes.

This article walks through a competitive intelligence pipeline that spins up three specialized AI agents, runs two of them in parallel, then synthesizes their outputs into a structured research report. The whole thing triggers from a webhook and logs results to Google Sheets.


Section 1: The Architecture

Here is the full workflow at a glance:

Webhook Trigger
    └── Validate Request (Code node)
            ├── Agent 1: Market Analyst ──────────┐
            │                                      ├── Merge Node (waitForAll)
            └── Agent 2: Competitor Analyst ───────┘
                                                        └── Code Node: Merge Results
                                                                └── Agent 3: Strategy Synthesizer
                                                                        └── Respond to Webhook
                                                                                └── Google Sheets Log
Enter fullscreen mode Exit fullscreen mode

The critical design decision is that Agent 1 and Agent 2 run in parallel. They receive the same input — a company name and market context — but each has a distinct system prompt and produces a different slice of analysis. Agent 3 only runs after both upstream agents have finished, consuming both outputs to produce an executive synthesis.

This maps closely to the "fan-out / fan-in" pattern you would implement in LangChain or a task queue, but n8n's visual canvas makes the data flow explicit and debuggable without writing orchestration code.


Section 2: The Three Agents

Agent 1 — Market Analyst

System prompt:

You are a senior market research analyst. Given a company name and industry context,
produce a structured market analysis covering:
1. Market overview and definition
2. Total addressable market (TAM) with size and growth rate
3. Key macro trends (3-5 bullet points)
4. Primary customer segments with pain points
5. Regulatory or technology tailwinds/headwinds

Be specific. Use numbers where available. Flag assumptions clearly.
Output valid JSON matching the schema provided.
Enter fullscreen mode Exit fullscreen mode

Output schema:

{
  "market_overview": "string",
  "tam_estimate": "string",
  "growth_rate": "string",
  "key_trends": ["string"],
  "customer_segments": [{ "name": "string", "pain_points": ["string"] }]
}
Enter fullscreen mode Exit fullscreen mode

This agent is good at breadth. It sets the stage: is this a crowded space or a greenfield? Is the market growing or contracting? Downstream agents and the final synthesizer reference these findings.

Agent 2 — Competitor Analyst

System prompt:

You are a competitive intelligence specialist. Given a target company and market,
produce a structured competitor analysis covering:
1. Top 3-5 direct competitors with brief profiles
2. Competitive positioning matrix (price vs. feature depth)
3. Identified gaps in current market offerings
4. Specific strategies for winning against each competitor

Focus on actionable intelligence, not generic descriptions.
Output valid JSON matching the schema provided.
Enter fullscreen mode Exit fullscreen mode

Output schema:

{
  "competitors": [{ "name": "string", "strengths": ["string"], "weaknesses": ["string"] }],
  "positioning_matrix": "string",
  "market_gaps": ["string"],
  "win_strategies": [{ "competitor": "string", "tactics": ["string"] }]
}
Enter fullscreen mode Exit fullscreen mode

Running this in parallel with the Market Analyst cuts total latency roughly in half. On DeepSeek V3, each agent call takes around 4-8 seconds. Sequential execution would stack those delays; parallel execution caps them at the slower of the two.

Agent 3 — Strategy Synthesizer

System prompt:

You are a strategy consultant preparing an executive briefing. You will receive:
- A market analysis (from Market Analyst)
- A competitor analysis (from Competitor Analyst)

Synthesize these into a concise strategic report with:
1. Executive summary (3 sentences max)
2. Top 3 strategic recommendations with rationale
3. Quick wins achievable in 30 days
4. KPIs to track success over 90 days

Cross-reference findings from both inputs. Surface non-obvious connections.
Output valid JSON matching the schema provided.
Enter fullscreen mode Exit fullscreen mode

Agent 3 is where the multi-agent design pays off. A single-agent approach would have to hold both the market context and competitor detail in its reasoning simultaneously, which introduces more hallucination surface area. By letting two specialist agents do the groundwork first, the synthesizer operates on already-structured, validated JSON rather than raw prompts.


Section 3: The Parallel Execution Trick

This is the key insight most n8n tutorials skip over.

When you split workflow execution across two branches (by connecting one node's output to two different downstream nodes), n8n does not automatically wait for both branches to finish before continuing. It will fire each branch and move on. If you naively connect both agent outputs to a single downstream node, you will get two separate executions of that downstream node — one for each branch completing.

The fix is the Merge node, configured like this:

{
  "parameters": {
    "mode": "waitForAll",
    "outputType": "all"
  },
  "type": "n8n-nodes-base.merge",
  "typeVersion": 3
}
Enter fullscreen mode Exit fullscreen mode

With mode: "waitForAll", the Merge node holds execution until all input branches have produced at least one item. With outputType: "all", it passes through every item from every branch as a combined array into the next node.

After the Merge node, a small Code node restructures the data:

// Merge node outputs items from both branches in the items array
const marketAnalysis = items.find(i => i.json.agent === 'market_analyst')?.json;
const competitorAnalysis = items.find(i => i.json.agent === 'competitor_analyst')?.json;

return [{
  json: {
    market: marketAnalysis,
    competitors: competitorAnalysis,
    query: items[0].json.query,
    timestamp: new Date().toISOString()
  }
}];
Enter fullscreen mode Exit fullscreen mode

This gives Agent 3 a clean, merged input object rather than a raw array. The agent sees one structured payload and can reference both analyses by key.

One practical note: tag each agent's output with its identity (agent: 'market_analyst') in the AI Agent node's output mapping. This makes the downstream Code node's find() lookup reliable regardless of which branch finishes first.


Section 4: Cost Analysis

Here is what this pipeline costs to run per query with DeepSeek V3 as the backend model:

Component Tokens (approx.) Cost
Agent 1 — Market Analyst ~800 in / ~600 out $0.0009
Agent 2 — Competitor Analyst ~800 in / ~700 out $0.0010
Agent 3 — Strategy Synthesizer ~1,800 in / ~900 out $0.0011
Total per query ~5,600 tokens ~$0.003

At $0.003 per report, you can run 333 research queries for $1.

Compare that to:

  • Hiring a research analyst: $50-100/hr, 2-4 hours per report = $100-400 per report
  • Dedicated competitive intelligence platforms (Crayon, Klue, Kompyte): $500-2,000/month
  • Perplexity Pro or similar AI research tools: $20/month but no workflow integration, no structured output, no Google Sheets logging

The n8n pipeline produces structured JSON that flows directly into downstream automations — Notion databases, Slack digests, email reports, CRM updates. That integration layer is where the real productivity gain lives, not just in the raw AI output.

For teams running competitive intelligence on 10-20 companies per week, this pipeline replaces a meaningful portion of manual analyst time at a cost that rounds to zero.


Putting It Together

The workflow handles a few edge cases worth noting:

  • Validate Request node: checks that the incoming webhook payload has a non-empty query field and a company field before wasting tokens on a bad request. Returns a 400 with an error message if validation fails.
  • Google Sheets logging: after the final response is sent, a separate branch logs the query, timestamp, and a summary of the output. This builds a historical record of all research runs without blocking the response.
  • Error handling: each AI Agent node has a fallback branch that catches timeouts or API errors and returns a structured error payload rather than a raw exception. The Merge node handles partial failures gracefully because the Code node checks for undefined before accessing nested fields.

The entire workflow is 12 nodes. Import time from JSON is under 30 seconds. Adding a new research agent — say, a Patent Analyst or a Pricing Analyst — is a matter of duplicating an existing agent node, updating the system prompt, and adding another input connector to the Merge node.


Get the Workflow

This workflow is part of my 16-template AI automation pack covering research pipelines, lead enrichment, content generation, and Slack/email digests — all built on n8n with DeepSeek or OpenAI as the backend.

Get the importable JSON files at [GUMROAD_LINK].


Full-stack developer specializing in AI automation, MCP servers, and Claude Code integrations. I build production workflows that replace manual research and content tasks with structured, auditable AI pipelines.

📦 Get My Templates

Want these templates ready to use? Check out my complete collection of

25 production-ready n8n automation templates — ready to deploy immediately.

👉 Get the n8n Templates Bundle ($10)

Perfect for automation engineers, consultants, and anyone looking to accelerate their n8n projects with battle-tested workflows.

Top comments (0)