{
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "nodes": [
    {
      "id": "a5964b4d-d916-4742-8678-8f448b15b78d",
      "name": "Call n8nBuilder API",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2064,
        -400
      ],
      "parameters": {
        "url": "https://api.n8nbuilder.dev/api/generate",
        "method": "POST",
        "options": {
          "timeout": 60000
        },
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "email",
              "value": "={{ $json.email }}"
            },
            {
              "name": "query",
              "value": "={{ $json.query }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "x-user-token",
              "value": "={{ $json.api_token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "21f46e20-fb1e-47b3-9536-5cd3caaaab93",
      "name": "When chat message received",
      "type": "@n8n/n8n-nodes-langchain.chatTrigger",
      "position": [
        768,
        -288
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 1.4
    },
    {
      "id": "9a1fd230-b017-4789-ad23-34c83e9a8838",
      "name": "n8nBuilder Chat Assistant",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        992,
        -400
      ],
      "parameters": {
        "options": {
          "systemMessage": "You are a helpful assistant which creates n8n workflows. \n\nYour top priority is to forward request to \"Generate Workflow Tool\" tool. \n\nAfter gathering the response from the tool, simply return it as a response. "
        }
      },
      "typeVersion": 3.1
    },
    {
      "id": "4f36ebc5-f3cf-4e4d-9fe0-0b44d0a104a9",
      "name": "Generate Workflow Tool",
      "type": "n8n-nodes-base.httpRequestTool",
      "position": [
        1136,
        -144
      ],
      "parameters": {
        "url": "https://api.n8nbuilder.dev/api/generate",
        "method": "POST",
        "options": {
          "timeout": 60000
        },
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "email",
              "value": "YOUR_EMAIL_ADRESS"
            },
            {
              "name": "query",
              "value": "={{ /*n8n-auto-generated-fromAI-override*/ $fromAI('parameters1_Value', ``, 'string') }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "x-user-token",
              "value": "YOUR_USER_TOKEN"
            },
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "typeVersion": 4.3
    },
    {
      "id": "0e68a887-14d5-4ae8-b04a-5ddae46f9b13",
      "name": "GPT-4o Mini Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "position": [
        928,
        -128
      ],
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-4o-mini"
        },
        "options": {
          "temperature": 0.1
        },
        "builtInTools": {}
      },
      "typeVersion": 1.3
    },
    {
      "id": "03fd382c-97cd-4700-b1fa-9163db24ee31",
      "name": "Workflow Generator Form",
      "type": "n8n-nodes-base.formTrigger",
      "position": [
        1840,
        -400
      ],
      "parameters": {
        "options": {
          "buttonLabel": "Generate Workflow",
          "appendAttribution": false
        },
        "formTitle": "n8n Workflow Generator",
        "formFields": {
          "values": [
            {
              "fieldName": "api_token",
              "fieldLabel": "n8nBuilder API Token",
              "placeholder": "Enter your API token from n8nbuilder.dev",
              "requiredField": true
            },
            {
              "fieldName": "email",
              "fieldType": "email",
              "fieldLabel": "Your Email Address",
              "placeholder": "your@email.com",
              "requiredField": true
            },
            {
              "fieldName": "query",
              "fieldType": "textarea",
              "fieldLabel": "Workflow Description",
              "placeholder": "Example: Read RSS from https://example.com/feed.xml every hour and send Slack message if new post arrives",
              "requiredField": true
            }
          ]
        },
        "formDescription": "Generate complete n8n workflows from natural language descriptions using the n8nBuilder API"
      },
      "typeVersion": 2.4
    },
    {
      "id": "ce2e0cc3-cd0d-4d85-930c-16bac25e5aa5",
      "name": "Process API Response",
      "type": "n8n-nodes-base.set",
      "position": [
        2384,
        -400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "id-1",
              "name": "output",
              "type": "string",
              "value": "={{ $json.output }}"
            },
            {
              "id": "id-2",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            },
            {
              "id": "id-3",
              "name": "query_description",
              "type": "string",
              "value": "={{ $('Workflow Generator Form').item.json.query }}"
            },
            {
              "id": "id-4",
              "name": "has_valid_json",
              "type": "boolean",
              "value": "={{ $json.output && $json.output.length > 10 }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "663e90a7-3425-42ee-93f4-bb2095d3fb16",
      "name": "Show Results",
      "type": "n8n-nodes-base.form",
      "position": [
        2736,
        -400
      ],
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "Workflow Generated Successfully!",
        "completionMessage": "=**Your workflow is ready!**\n\n**Generated at:** {{ $json.timestamp }}\n\n**What you asked for:** {{ $json.query_description }}\n\n---\n\n**Next Steps:**\n1. Copy the JSON code below\n2. Go to your n8n instance\n3. Click the \"+\" button - \"Import from File\" or \"Import from URL\"\n4. Paste the JSON code\n5. Configure any required credentials\n6. Activate your workflow!\n\n---\n\n**Generated Workflow JSON:**\n```json\n{{ $json.output }}\n```\n\n---\n\n**Tips:**\n- Make sure to replace placeholder credentials\n- Test the workflow before activating it\n- Check all node connections\n\n**Need help?** Visit [n8n Community](https://community.n8n.io)"
      },
      "typeVersion": 2.4
    },
    {
      "id": "a8dce9e9-df9f-4dba-b3b3-f3e0902635fb",
      "name": "Extract Generated Workflow",
      "type": "n8n-nodes-base.set",
      "position": [
        1344,
        -400
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "cc6f7d09-6708-4554-ac80-b3ef4d8e0e72",
              "name": "output",
              "type": "string",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "7ad71ff6-0157-4afc-bb9c-649b1aeca5ea",
      "name": "Handle API Errors",
      "type": "n8n-nodes-base.if",
      "position": [
        2544,
        -400
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.has_valid_json }}",
              "value2": true
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "724d37cc-d904-40c3-bc7b-c44ecbe984ac",
      "name": "Show Error Message",
      "type": "n8n-nodes-base.form",
      "position": [
        2736,
        -208
      ],
      "parameters": {
        "options": {},
        "operation": "completion",
        "completionTitle": "Generation Failed",
        "completionMessage": "=**Oops! Something went wrong.**\n\n**Possible reasons:**\n\n1. **Invalid API Token**\n   - Check your token at [n8nbuilder.dev/dashboard](https://n8nbuilder.dev/dashboard)\n   - Make sure you copied it correctly\n\n2. **API Limit Reached**\n   - Free tier has usage limits\n   - Check your quota in the dashboard\n\n3. **Invalid Request**\n   - Description might be too vague\n   - Try being more specific\n\n4. **Network Issues**\n   - API might be temporarily unavailable\n   - Try again in a few moments\n\n---\n\n**What to do:**\n- Double-check your API token\n- Try with a simpler workflow description\n- Contact [support](https://n8nbuilder.dev/support) if issue persists\n\n**Response received:**\n```\n{{ $json.output || 'No response from API' }}\n```"
      },
      "typeVersion": 2.4
    },
    {
      "id": "2896db8e-68dd-436b-9245-9ddf22ac8c82",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "position": [
        1760,
        192
      ],
      "parameters": {
        "path": "generate-workflow",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2
    },
    {
      "id": "38e07ebb-790e-4a31-8f94-9604ebfb03fc",
      "name": "Call n8nBuilder API (Webhook)",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        1984,
        192
      ],
      "parameters": {
        "url": "https://api.n8nbuilder.dev/api/generate",
        "method": "POST",
        "options": {
          "timeout": 60000
        },
        "sendBody": true,
        "sendHeaders": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "email",
              "value": "={{ $json.body.email }}"
            },
            {
              "name": "query",
              "value": "={{ $json.body.query }}"
            }
          ]
        },
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            },
            {
              "name": "x-user-token",
              "value": "={{ $json.body.api_token }}"
            }
          ]
        }
      },
      "typeVersion": 4.2
    },
    {
      "id": "17a22c62-a40e-47a6-b412-8b3c204149d5",
      "name": "Process Webhook Response",
      "type": "n8n-nodes-base.set",
      "position": [
        2208,
        192
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "wh-1",
              "name": "success",
              "type": "boolean",
              "value": "={{ $json.output && $json.output.length > 10 }}"
            },
            {
              "id": "wh-2",
              "name": "workflow_json",
              "type": "string",
              "value": "={{ $json.output }}"
            },
            {
              "id": "wh-3",
              "name": "timestamp",
              "type": "string",
              "value": "={{ $now.toISO() }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "31cf89b6-4da3-4f68-b12b-343e2f066eda",
      "name": "Check Webhook Response",
      "type": "n8n-nodes-base.if",
      "position": [
        2432,
        192
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "boolean": [
            {
              "value1": "={{ $json.success }}",
              "value2": true
            }
          ]
        }
      },
      "typeVersion": 2
    },
    {
      "id": "90381fbf-013f-4d16-856b-ac7bd3faaeb8",
      "name": "Return Success Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        2656,
        192
      ],
      "parameters": {
        "options": {
          "responseCode": 200
        },
        "respondWith": "json",
        "responseBody": "={\n  \"success\": true,\n  \"timestamp\": \"{{ $json.timestamp }}\",\n  \"workflow\": {{ $json.workflow_json }}\n}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "81469ddf-60d5-4564-9e3b-d05b96386f30",
      "name": "Return Error Response",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        2656,
        384
      ],
      "parameters": {
        "options": {
          "responseCode": 400
        },
        "respondWith": "json",
        "responseBody": "={\n  \"success\": false,\n  \"error\": \"Failed to generate workflow. Please check your API token and try again.\",\n  \"timestamp\": \"{{ $json.timestamp }}\"\n}"
      },
      "typeVersion": 1.1
    },
    {
      "id": "2cda642c-4c30-49dd-8101-c4aa1a321718",
      "name": "n8nBuilder Workflow Generator",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        96,
        -560
      ],
      "parameters": {
        "color": 2,
        "width": 420,
        "height": 420,
        "content": "## How it works\n\n1. Choose your mode: Form, AI Chat, or Webhook\n2. Enter your n8nBuilder API token and workflow description\n3. API generates a complete n8n workflow JSON\n4. Copy the output and import into your n8n instance\n\n## Setup steps\n\n1. Get API token from n8nbuilder.dev\n2. For AI Chat: Configure OpenAI credentials and update token in \"Generate Workflow Tool\" node\n3. Activate the workflow\n4. Access Form URL, Chat URL, or Webhook URL to start generating"
      },
      "typeVersion": 1
    },
    {
      "id": "705bac7e-3cae-46ee-ba46-93162c98478d",
      "name": "AI Chat Mode",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        -560
      ],
      "parameters": {
        "color": 7,
        "width": 700,
        "height": 132,
        "content": "AI Chat Mode\n\nConversational workflow generation using OpenAI.\nConfigure OpenAI credentials and update YOUR_EMAIL_ADRESS / YOUR_USER_TOKEN in the tool node."
      },
      "typeVersion": 1
    },
    {
      "id": "a32c4b10-13a0-4c2e-96d4-0e87b9108334",
      "name": "Form Mode",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1776,
        -528
      ],
      "parameters": {
        "color": 7,
        "width": 416,
        "height": 108,
        "content": "Form Mode\n\nSimple form-based workflow generation.\nUsers enter API token, email, and workflow description."
      },
      "typeVersion": 1
    },
    {
      "id": "8b9d49f8-2cc7-4300-8e15-c7716e35d4f7",
      "name": "Response and Error Handling",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2384,
        -528
      ],
      "parameters": {
        "color": 7,
        "width": 528,
        "height": 100,
        "content": "Response and Error Handling\n\nValidates API response and displays success or error message to the user."
      },
      "typeVersion": 1
    },
    {
      "id": "c3a0e18d-873a-4910-9382-f94520a0b980",
      "name": "Advanced Options",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2992,
        -528
      ],
      "parameters": {
        "color": 7,
        "width": 340,
        "height": 296,
        "content": "Advanced Options\n\nCommunity Node Available:\nnpm install n8n-nodes-n8nbuilder\n\nGitHub: github.com/mbakgun/n8n-nodes-n8nbuilder\n\nExample Use Cases:\n- RSS to Slack notifications\n- GitHub webhook processors\n- Data sync workflows\n- API integrations"
      },
      "typeVersion": 1
    },
    {
      "id": "b8865932-98bf-403a-ad92-92934e4dddcc",
      "name": "Webhook Mode",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1728,
        32
      ],
      "parameters": {
        "color": 7,
        "width": 432,
        "height": 108,
        "content": "Webhook Mode\n\nProgrammatic API integration. POST to /webhook/generate-workflow with JSON body: { \"api_token\": \"...\", \"email\": \"...\", \"query\": \"...\" }"
      },
      "typeVersion": 1
    },
    {
      "id": "18a19182-e0de-4045-8b07-1a5e8796b249",
      "name": "Response and Error Handling1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2240,
        48
      ],
      "parameters": {
        "color": 7,
        "width": 528,
        "height": 100,
        "content": "Response and Error Handling\n\nValidates API response and displays success or error message to the user."
      },
      "typeVersion": 1
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Call n8nBuilder API (Webhook)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "GPT-4o Mini Model": {
      "ai_languageModel": [
        [
          {
            "node": "n8nBuilder Chat Assistant",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Handle API Errors": {
      "main": [
        [
          {
            "node": "Show Results",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Show Error Message",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call n8nBuilder API": {
      "main": [
        [
          {
            "node": "Process API Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process API Response": {
      "main": [
        [
          {
            "node": "Handle API Errors",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check Webhook Response": {
      "main": [
        [
          {
            "node": "Return Success Response",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Return Error Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Workflow Tool": {
      "ai_tool": [
        [
          {
            "node": "n8nBuilder Chat Assistant",
            "type": "ai_tool",
            "index": 0
          }
        ]
      ]
    },
    "Workflow Generator Form": {
      "main": [
        [
          {
            "node": "Call n8nBuilder API",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Process Webhook Response": {
      "main": [
        [
          {
            "node": "Check Webhook Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "n8nBuilder Chat Assistant": {
      "main": [
        [
          {
            "node": "Extract Generated Workflow",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When chat message received": {
      "main": [
        [
          {
            "node": "n8nBuilder Chat Assistant",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Call n8nBuilder API (Webhook)": {
      "main": [
        [
          {
            "node": "Process Webhook Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}