AutomationFlowsAI & RAG › Generate n8n Workflows from Webhook Prompts with Azure OpenAI

Generate n8n Workflows from Webhook Prompts with Azure OpenAI

Original n8n title: Generate Workflow JSON Files From Webhook Prompts Using Azure Openai Gpt-4o-mini

ByRahul Joshi @rahul08 on n8n.io

Automate the creation of production-ready n8n workflows using AI 🤖. This template receives a plain-text automation idea via webhook, processes it with Azure OpenAI, and instantly generates a fully valid, import-ready n8n workflow JSON file. The automation sanitizes the prompt,…

Webhook trigger★★★★☆ complexityAI-powered12 nodesAgentLm Chat Azure Open Ai
AI & RAG Trigger: Webhook Nodes: 12 Complexity: ★★★★☆ AI nodes: yes Added:

This workflow corresponds to n8n.io template #13787 — we link there as the canonical source.

This workflow follows the Agent → Lmchatazureopenai recipe pattern — see all workflows that pair these two integrations.

The workflow JSON

Copy or download the full n8n JSON below. Paste it into a new n8n workflow, add your credentials, activate. Full import guide →

Download .json
{
  "id": "HzCoQz3rqyIpSYRr",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "AI Workflow Generator",
  "tags": [],
  "nodes": [
    {
      "id": "cb9054f7-a792-4f88-98b7-7f34509d8084",
      "name": "Receive Workflow Prompt",
      "type": "n8n-nodes-base.webhook",
      "position": [
        -112,
        544
      ],
      "parameters": {
        "path": "7b183879-9ca9-45ba-815c-3c7e9b908f88",
        "options": {},
        "httpMethod": "POST",
        "responseMode": "responseNode"
      },
      "typeVersion": 2.1
    },
    {
      "id": "6e8c9b64-c8b6-4125-a7ca-4718ea746aff",
      "name": "Sanitize & Normalize Prompt",
      "type": "n8n-nodes-base.code",
      "position": [
        96,
        544
      ],
      "parameters": {
        "jsCode": "// Extract prompt safely\nlet prompt = $json.body?.prompt || \"\";\n\n// Normalize formatting\nprompt = prompt\n  .replace(/\\r\\n/g, \"\\n\")        // normalize Windows line breaks\n  .replace(/\\n\\s+\\n/g, \"\\n\\n\")   // remove excessive spacing\n  .trim();                       // remove leading/trailing spaces\n\nreturn [\n  {\n    json: {\n      prompt: prompt\n    }\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "78b4c991-ee4d-4376-93e3-711b06b3a21b",
      "name": "Generate Workflow via AI Agent",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "position": [
        304,
        544
      ],
      "parameters": {
        "text": "=Generate a complete production-ready n8n workflow JSON for the following automation:\n\n{{ $json.prompt }}\n\nRequirements:\n\nInclude proper triggers\n\nInclude required logic\n\nInclude error handling IF needed\n\nEnsure all nodes are connected\n\nEnsure import-ready JSON\n\nSet workflow active to false\n\nProvide realistic node positions\n\nUse best-practice structure\n\nReturn ONLY pure JSON.",
        "options": {
          "systemMessage": "=You are a senior n8n workflow architect.\n\nYour task is to generate a COMPLETE, IMPORT-READY, VALID n8n workflow JSON.\n\nCRITICAL RULES:\n\nOutput ONLY raw JSON.\n\nDo NOT wrap in markdown.\n\nDo NOT explain anything.\n\nDo NOT include comments.\n\nDo NOT include backticks.\n\nDo NOT include extra text before or after JSON.\n\nThe response must start with { and end with }.\n\nJSON must be valid and parsable.\n\nAll nodes must be properly connected.\n\nAll required properties must exist.\n\nREQUIRED WORKFLOW STRUCTURE\n\nYou MUST return a valid n8n workflow object with:\n\nname\n\nnodes (array)\n\nconnections (object)\n\nactive (false)\n\nsettings (object)\n\nversionId\n\nmeta (object)\n\nid (null)\n\nNODE RULES\n\nEach node must include:\n\nid (unique string)\n\nname\n\ntype\n\ntypeVersion\n\nposition [x, y]\n\nparameters (object)\n\nAll nodes must be connected correctly in the connections object.\n\nNo orphan nodes.\n\nConnection format must follow n8n standard:\n\nExample:\n\"connections\": {\n\"Schedule Trigger\": {\n\"main\": [\n[\n{\n\"node\": \"HTTP Request\",\n\"type\": \"main\",\n\"index\": 0\n}\n]\n]\n}\n}\n\nLOGIC RULES\n\nIf user mentions time \u2192 use Schedule Trigger node\n\nIf user mentions email \u2192 use Gmail node\n\nIf user mentions spreadsheet \u2192 use Google Sheets node\n\nIf user mentions webhook \u2192 use Webhook node\n\nIf summarization or AI needed \u2192 use OpenAI node\n\nIf condition required \u2192 use IF node\n\nIf data transformation needed \u2192 use Function node\n\nAlways choose correct official n8n node types like:\n\nn8n-nodes-base.scheduleTrigger\n\nn8n-nodes-base.gmail\n\nn8n-nodes-base.googleSheets\n\nn8n-nodes-base.httpRequest\n\nn8n-nodes-base.if\n\nn8n-nodes-base.function\n\nn8n-nodes-base.webhook\n\nn8n-nodes-base.openAi\n\nVALIDATION RULES\n\nEnsure connections match node names exactly.\n\nEnsure positions are spaced (e.g., 200px apart horizontally).\n\nEnsure no missing commas.\n\nEnsure valid JSON formatting.\n\nEnsure workflow can be directly imported into n8n without edits.\n\nIf user input is unclear, intelligently infer a logical automation flow.\n\nReturn ONLY valid n8n JSON."
        },
        "promptType": "define"
      },
      "typeVersion": 3
    },
    {
      "id": "b719e9dc-bbb5-4945-9ffc-7b81f63efc49",
      "name": "Parse & Validate AI JSON Output",
      "type": "n8n-nodes-base.code",
      "position": [
        656,
        544
      ],
      "parameters": {
        "jsCode": "// Step 1: Get the raw output string\nlet rawOutput = $json.output;\n\n// Step 2: Ensure it's a string\nif (typeof rawOutput !== \"string\") {\n  throw new Error(\"Output is not a string\");\n}\n\n// Step 3: Parse JSON safely\nlet parsedWorkflow;\n\ntry {\n  parsedWorkflow = JSON.parse(rawOutput);\n} catch (error) {\n  throw new Error(\"Invalid JSON returned by AI: \" + error.message);\n}\n\n// Step 4: Return clean normalized JSON\nreturn [\n  {\n    json: parsedWorkflow\n  }\n];"
      },
      "typeVersion": 2
    },
    {
      "id": "ac81bb2e-33a4-4d1c-95b8-44d4afbdef57",
      "name": "Convert Workflow to JSON File",
      "type": "n8n-nodes-base.convertToFile",
      "position": [
        864,
        544
      ],
      "parameters": {
        "options": {},
        "operation": "toJson"
      },
      "typeVersion": 1.1
    },
    {
      "id": "450fe5e9-2ae4-4923-9ee8-f295003f0240",
      "name": "Return JSON File to Caller",
      "type": "n8n-nodes-base.respondToWebhook",
      "position": [
        1088,
        544
      ],
      "parameters": {
        "options": {},
        "respondWith": "binary"
      },
      "typeVersion": 1.5
    },
    {
      "id": "ab863cf3-3f1c-42df-8927-fd1881870ae3",
      "name": "\ud83d\udccb Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -688,
        288
      ],
      "parameters": {
        "color": 3,
        "width": 500,
        "height": 836,
        "content": "## \ud83e\udde0 AI Workflow Generator\n\n### How it works\nThis workflow accepts a plain-text automation description via a POST webhook and uses an Azure OpenAI-powered AI Agent to generate a fully valid, import-ready n8n workflow JSON. The generated JSON is then parsed, validated, converted to a downloadable file, and returned to the caller as a binary response.\n\n**Data flow:**\n1. **Receive Workflow Prompt** \u2014 Accepts POST request with a `prompt` field describing the desired automation.\n2. **Sanitize & Normalize Prompt** \u2014 Cleans whitespace and line breaks to ensure consistent input.\n3. **Generate Workflow via AI Agent** \u2014 Sends the prompt to Azure OpenAI GPT-4o-mini with strict system instructions to return only raw JSON.\n4. **Parse & Validate AI JSON Output** \u2014 Parses the AI's string output into a structured JSON object, throwing errors on invalid responses.\n5. **Convert Workflow to JSON File** \u2014 Wraps the parsed JSON into a downloadable `.json` binary file.\n6. **Return JSON File to Caller** \u2014 Sends the binary file back as the webhook HTTP response.\n\n### Setup steps\n1. Configure your **Azure OpenAI credentials** (`azureOpenAiApi`) in n8n credentials.\n2. Ensure your Azure deployment uses the `gpt-4o-mini` model name.\n3. Activate the workflow and copy the webhook URL.\n4. Send a POST request with body: `{ \"prompt\": \"Your automation description here\" }`\n\n### Customization\n- Swap `gpt-4o-mini` with another Azure deployment for higher quality output.\n- Extend the AI system prompt to enforce additional n8n node types or coding standards."
      },
      "typeVersion": 1
    },
    {
      "id": "d11fd04b-a949-4429-9770-dfd4505ea824",
      "name": "\ud83d\udce5 Section: Input & Prompt Prep",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -144,
        352
      ],
      "parameters": {
        "width": 420,
        "height": 200,
        "content": "## \ud83d\udce5 Input & Prompt Preparation\nReceives the raw POST request and extracts the `prompt` field. Normalizes line breaks and trims whitespace so the AI always gets clean, consistent input."
      },
      "typeVersion": 1
    },
    {
      "id": "0997a823-87c3-48bb-a350-c5f98de409db",
      "name": "\ud83e\udd16 Section: AI Generation",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        304,
        336
      ],
      "parameters": {
        "width": 420,
        "height": 200,
        "content": "## \ud83e\udd16 AI Workflow Generation\nThe AI Agent uses Azure OpenAI GPT-4o-mini with a strict system prompt to produce a complete, import-ready n8n workflow JSON. No markdown, no explanations \u2014 raw JSON only."
      },
      "typeVersion": 1
    },
    {
      "id": "107a24ff-7a90-42ae-9f78-9a85f91f9a54",
      "name": "\ud83d\udce4 Section: Output Processing",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        752,
        352
      ],
      "parameters": {
        "width": 560,
        "height": 200,
        "content": "## \ud83d\udce4 Output Processing & Response\nParses and validates the AI's raw string output into structured JSON, converts it to a downloadable file, and returns it to the caller as a binary HTTP response."
      },
      "typeVersion": 1
    },
    {
      "id": "97f124e8-c0ff-406d-8d04-97239f0eb207",
      "name": "\u26a0\ufe0f Warning: Azure OpenAI Credentials",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        48,
        896
      ],
      "parameters": {
        "color": 2,
        "width": 300,
        "height": 150,
        "content": "\u26a0\ufe0f **Azure OpenAI Credentials Required**\nThis node requires a valid `azureOpenAiApi` credential with an active deployment named `gpt-4o-mini`. Misconfiguration will cause all AI generation to fail."
      },
      "typeVersion": 1
    },
    {
      "id": "ac57db68-8517-4840-b125-4a5a6a634dbf",
      "name": "Azure OpenAI Chat Model1",
      "type": "@n8n/n8n-nodes-langchain.lmChatAzureOpenAi",
      "position": [
        176,
        752
      ],
      "parameters": {
        "model": "gpt-4o-mini",
        "options": {}
      },
      "credentials": {
        "azureOpenAiApi": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "959dcb1e-528e-498b-9928-4e5531958286",
  "connections": {
    "Receive Workflow Prompt": {
      "main": [
        [
          {
            "node": "Sanitize & Normalize Prompt",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Azure OpenAI Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Generate Workflow via AI Agent",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Sanitize & Normalize Prompt": {
      "main": [
        [
          {
            "node": "Generate Workflow via AI Agent",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Convert Workflow to JSON File": {
      "main": [
        [
          {
            "node": "Return JSON File to Caller",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Generate Workflow via AI Agent": {
      "main": [
        [
          {
            "node": "Parse & Validate AI JSON Output",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse & Validate AI JSON Output": {
      "main": [
        [
          {
            "node": "Convert Workflow to JSON File",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}

Credentials you'll need

Each integration node will prompt for credentials when you import. We strip credential IDs before publishing — you'll add your own.

Pro

For the full experience including quality scoring and batch install features for each workflow upgrade to Pro

About this workflow

Automate the creation of production-ready n8n workflows using AI 🤖. This template receives a plain-text automation idea via webhook, processes it with Azure OpenAI, and instantly generates a fully valid, import-ready n8n workflow JSON file. The automation sanitizes the prompt,…

Source: https://n8n.io/workflows/13787/ — original creator credit. Request a take-down →

More AI & RAG workflows → · Browse all categories →

Related workflows

Workflows that share integrations, category, or trigger type with this one. All free to copy and import.

AI & RAG

This template is for teams that use GitLab merge requests and want a practical AI-assisted review workflow in n8n. It is useful for engineering teams that want faster first-pass reviews, consistent re

HTTP Request, Agent, Lm Chat Azure Open Ai +1
AI & RAG

My workflow 5. Uses informationExtractor, lmChatAzureOpenAi, outputParserStructured, mcpClientTool. Webhook trigger; 36 nodes.

Information Extractor, Lm Chat Azure Open Ai, Output Parser Structured +5
AI & RAG

This workflow automates the complete DPDP-aligned Consent Manager Registration screening pipeline — from intake to eligibility evaluation and final compliance routing. Every incoming registration requ

Google Sheets, Lm Chat Azure Open Ai, Agent +1
AI & RAG

This workflow automates payment-related customer support escalation by validating reported issues against transaction data and coordinating all downstream actions in a controlled, auditable way. It is

Agent, Lm Chat Azure Open Ai, Output Parser Structured +6
AI & RAG

Automate your clinic’s patient intake and scheduling with an intelligent AI Healthcare Appointment Booking Agent built in n8n. 🏥 This workflow receives patient form submissions, analyzes symptoms usin

Agent, Lm Chat Azure Open Ai, Google Sheets +3