Inspiration

As someone who builds automation workflows daily with n8n, I've always thought: "What if AI could not just write the code, but also debug it autonomously?" Most AI code generators give you broken code and leave debugging to you. I wanted to create something different—an AI agent that doesn't give up when things fail.

The inspiration came from watching developers struggle with n8n's learning curve. What if you could just describe what you want in plain English, and AI would handle not just generation, but testing, debugging, and verification until it actually works?

What it does

n8n Workflow Agent transforms natural language descriptions into working n8n automation workflows through an autonomous debugging loop:

  1. Generate: Takes your description and creates n8n workflow JSON with proper node structures
  2. Deploy: Automatically deploys workflows to n8n via API
  3. Test: Activates and triggers workflows with real webhook requests
  4. Analyze: When execution fails, Gemini 3 examines the logs to identify root causes
  5. Fix: Automatically generates and applies fixes to the workflow
  6. Retry: Repeats the test-analyze-fix cycle until success (up to 3 iterations)

The key innovation is true autonomy—it doesn't just generate code, it validates execution, debugs failures, and iteratively improves until the workflow actually works.

How we built it

Tech Stack:

  • Next.js 15 with TypeScript for the UI
  • Google Gemini 3 Flash Preview for generation and autonomous debugging
  • n8n REST API for workflow deployment and execution testing
  • Production webhook triggers for real-world validation

The Autonomous Loop:

User Input → Gemini generates workflow → Deploy to n8n → Activate → Test webhook
→ Fetch execution logs → Gemini analyzes → Error? → Generate fix → Apply → Retry
→ Success? → Return working workflow

Key Technical Implementation:

  • Workflow generation with proper n8n structure (UUIDs, typeVersions, webhookIds at root level)
  • Webhook lifecycle management (activation, 10-second registration wait, triggering)
  • Execution log analysis with error pattern recognition
  • Iterative fix application through workflow JSON mutation
  • Success verification before returning to user

Challenges we ran into

The 404 Mystery (4+ hours): Workflows activated successfully (active: true) but webhooks returned 404. Through systematic testing, discovered three hidden requirements:

  • N8N_WEBHOOK_URL environment variable must be set in the Docker container
  • webhookId must exist at the node root level, not just in parameters
  • Parameter name is httpMethod, not method (completely undocumented!)

Gemini Hallucinations: When webhooks failed to execute (0 executions), Gemini analyzed empty logs and hallucinated errors, creating false debugging loops. Fixed by enhancing the verification prompt to explicitly detect "no execution" vs "execution with errors."

Race Conditions: Webhook registration isn't instant. Initial 2-second waits failed intermittently. Solution: 10-second wait with explicit logging. Reliable execution > fast execution.

Time Pressure: Built during a hackathon with ~4 hours for the core system. Had to make fast decisions: skip unit tests, hard-code success criteria, focus on webhook workflows only, use direct API calls instead of SDKs. Prioritized working proof-of-concept over perfect architecture.

Accomplishments that we're proud of

True autonomous debugging: Not just code generation—actual iterative problem-solving until workflows work

Solved undocumented n8n challenges: Discovered and documented webhook registration requirements through systematic testing

End-to-end working system: From natural language to deployed, tested, verified workflows in one flow

Real-world validation: Uses production webhooks with actual HTTP requests, not simulated testing

Fast iteration cycles: Complete generate-test-fix-verify loop in ~30 seconds per iteration

Gemini 3 integration excellence: Leveraged Gemini's structured reasoning for both generation AND debugging

What we learned

1. AI agents need verification loops: Generation alone isn't enough—testing and iteration unlock real autonomy. Gemini 3 proved it can do more than write code; it can analyze execution state and iteratively fix issues.

2. Domain knowledge is critical: Understanding n8n's undocumented quirks (webhookId placement, parameter naming, registration timing) made the difference between a broken POC and a working system.

3. Systematic debugging beats guesswork: When stuck on the 404 issue, testing one variable at a time (environment variables, parameter names, wait times) revealed the root causes.

4. Gemini 3's structured reasoning shines: The model excelled at generating valid JSON with complex nested structures, analyzing execution logs, identifying specific parameter issues, and suggesting precise fixes—not vague recommendations.

5. Autonomous systems design principles: Clear success/failure criteria are essential. Know when to stop (max iterations). Error context matters more than error messages. Programmatic verification > heuristic guessing.

What's next for n8n Workflow Agent

Expanded Node Support: Add HTTP requests, database operations, conditionals, transformations, and email notifications beyond just webhooks

Parallel Iteration Testing: Try multiple fix approaches simultaneously and select the best one

Learning System: Build a knowledge base of common errors and proven fixes to speed up debugging

Natural Language Editing: "Add email notification when this fails" or "Log all data to database" without regenerating

Multi-Agent Collaboration: Specialized agents—one generates, another debugs, third optimizes for performance

Production Monitoring: Deploy with built-in error detection and auto-healing capabilities

Community Workflow Library: Share and reuse successful workflow patterns across users


This project proves AI can do more than generate code—it can debug, test, and iterate autonomously until things actually work. That's the future of AI-assisted development.

Built With

Share this project:

Updates