Skip to content

Instantly share code, notes, and snippets.

@ivanfoong
Created March 30, 2025 05:28
Show Gist options
  • Save ivanfoong/657c6f738806db9bf25c90477f5b8a32 to your computer and use it in GitHub Desktop.
Save ivanfoong/657c6f738806db9bf25c90477f5b8a32 to your computer and use it in GitHub Desktop.

Revisions

  1. ivanfoong created this gist Mar 30, 2025.
    87 changes: 87 additions & 0 deletions builder.json
    Original file line number Diff line number Diff line change
    @@ -0,0 +1,87 @@
    {
    "nodes": [
    {
    "parameters": {
    "path": "generate-workflow",
    "methods": [
    "POST"
    ]
    },
    "name": "Webhook",
    "type": "n8n-nodes-base.webhook",
    "typeVersion": 1,
    "position": [200, 300]
    },
    {
    "parameters": {
    "actions": [
    {
    "name": "Extract Intent",
    "value": "Extract key actions from user input"
    }
    ]
    },
    "name": "AI Text Analysis",
    "type": "n8n-nodes-base.openai",
    "typeVersion": 1,
    "position": [400, 300]
    },
    {
    "parameters": {
    "functionCode": "function generateWorkflowStructure(text) {\n // Basic example: Convert simple text prompts into workflows\n if (text.includes(\"send email\")) {\n return {\n nodes: [\n {\n parameters: { recipient: '[email protected]', subject: 'Automated Email', text: 'Hello!' },\n name: 'Send Email',\n type: 'n8n-nodes-base.emailSend',\n typeVersion: 1,\n position: [400, 600]\n }\n ],\n connections: {}\n };\n }\n return { nodes: [], connections: {} };\n}\n\nreturn [{ json: { workflow: generateWorkflowStructure(items[0].json.text) } }];"
    },
    "name": "Generate Workflow JSON",
    "type": "n8n-nodes-base.function",
    "typeVersion": 1,
    "position": [600, 300]
    },
    {
    "parameters": {
    "requestMethod": "POST",
    "url": "https://your-n8n-instance.com/api/v1/workflows",
    "jsonParameters": true,
    "options": {},
    "bodyParametersJson": "={{JSON.stringify($node[\"Generate Workflow JSON\"].json.workflow)}}"
    },
    "name": "Deploy Workflow",
    "type": "n8n-nodes-base.httpRequest",
    "typeVersion": 1,
    "position": [800, 300]
    }
    ],
    "connections": {
    "Webhook": {
    "main": [
    [
    {
    "node": "AI Text Analysis",
    "type": "main",
    "index": 0
    }
    ]
    ]
    },
    "AI Text Analysis": {
    "main": [
    [
    {
    "node": "Generate Workflow JSON",
    "type": "main",
    "index": 0
    }
    ]
    ]
    },
    "Generate Workflow JSON": {
    "main": [
    [
    {
    "node": "Deploy Workflow",
    "type": "main",
    "index": 0
    }
    ]
    ]
    }
    }
    }