This workflow corresponds to n8n.io template #5045 — we link there as the canonical source.
This workflow follows the Chainllm → Form Trigger 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 →
{
"name": "AI Prompt Generator Workflow",
"nodes": [
{
"parameters": {
"httpMethod": "POST",
"path": "generate-prompt",
"responseMode": "responseNode",
"options": {
"cors": true
}
},
"id": "webhook-start",
"name": "Webhook Start",
"type": "n8n-nodes-base.webhook",
"typeVersion": 1,
"position": [
240,
300
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "user_input",
"name": "user_input",
"value": "={{ $json.body.prompt || 'Default prompt' }}",
"type": "string"
},
{
"id": "prompt_type",
"name": "prompt_type",
"value": "={{ $json.body.type || 'general' }}",
"type": "string"
},
{
"id": "creativity_level",
"name": "creativity_level",
"value": "={{ $json.body.creativity || 0.7 }}",
"type": "number"
},
{
"id": "language",
"name": "language",
"value": "={{ $json.body.language || 'Indonesian' }}",
"type": "string"
}
]
},
"options": {}
},
"id": "extract-parameters",
"name": "Extract Parameters",
"type": "n8n-nodes-base.set",
"typeVersion": 3.2,
"position": [
460,
300
]
},
{
"parameters": {
"jsCode": "// Prompt enhancement logic based on type\nconst userInput = $input.item(0).json.user_input;\nconst promptType = $input.item(0).json.prompt_type;\nconst creativityLevel = $input.item(0).json.creativity_level;\nconst language = $input.item(0).json.language;\n\n// Define prompt templates\nconst promptTemplates = {\n 'creative-writing': {\n prefix: 'Sebagai penulis kreatif yang berpengalaman, buatlah',\n structure: 'cerita/artikel yang menarik dengan gaya naratif yang engaging',\n suffix: 'Pastikan untuk menggunakan bahasa yang hidup dan deskriptif.'\n },\n 'technical': {\n prefix: 'Sebagai ahli teknis, jelaskan dengan detail',\n structure: 'konsep atau solusi dengan pendekatan sistematis',\n suffix: 'Berikan contoh praktis dan implementasi yang jelas.'\n },\n 'marketing': {\n prefix: 'Sebagai marketing strategist, buatlah',\n structure: 'konten pemasaran yang persuasif dan menarik target audience',\n suffix: 'Fokus pada value proposition dan call-to-action yang kuat.'\n },\n 'educational': {\n prefix: 'Sebagai educator yang berpengalaman, ajarkan',\n structure: 'materi dengan pendekatan yang mudah dipahami',\n suffix: 'Gunakan analogi dan contoh untuk memperjelas konsep.'\n },\n 'general': {\n prefix: 'Tolong bantu saya dengan',\n structure: 'informasi yang komprehensif dan akurat',\n suffix: 'Berikan jawaban yang terstruktur dan mudah dipahami.'\n }\n};\n\n// Get template based on type\nconst template = promptTemplates[promptType] || promptTemplates['general'];\n\n// Create enhanced prompt\nlet enhancedPrompt = `${template.prefix} ${userInput}. ${template.structure}. ${template.suffix}`;\n\n// Add creativity instructions based on level\nif (creativityLevel > 0.8) {\n enhancedPrompt += ' Jadilah sangat kreatif dan inovatif dalam pendekatan Anda.';\n} else if (creativityLevel > 0.5) {\n enhancedPrompt += ' Gunakan pendekatan yang seimbang antara kreativitas dan struktur.';\n} else {\n enhancedPrompt += ' Fokus pada akurasi dan struktur yang jelas.';\n}\n\n// Add language instruction\nif (language !== 'Indonesian') {\n enhancedPrompt += ` Jawab dalam bahasa ${language}.`;\n}\n\n// Add metadata\nconst metadata = {\n original_prompt: userInput,\n enhanced_prompt: enhancedPrompt,\n prompt_type: promptType,\n creativity_level: creativityLevel,\n language: language,\n timestamp: new Date().toISOString(),\n template_used: template\n};\n\nreturn [{ json: metadata }];"
},
"id": "enhance-prompt",
"name": "Enhance Prompt",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
680,
300
]
},
{
"parameters": {
"conditions": {
"options": {
"caseSensitive": true,
"leftValue": "",
"typeValidation": "strict"
},
"conditions": [
{
"id": "ai_provider_check",
"leftValue": "={{ $json.prompt_type }}",
"rightValue": "technical",
"operator": {
"type": "string",
"operation": "equals"
}
}
],
"combinator": "and"
},
"options": {}
},
"id": "check-ai-integration",
"name": "Check AI Integration",
"type": "n8n-nodes-base.if",
"typeVersion": 2,
"position": [
900,
300
]
},
{
"parameters": {
"method": "POST",
"url": "https://api.openai.com/v1/chat/completions",
"authentication": "predefinedCredentialType",
"nodeCredentialType": "openAiApi",
"sendHeaders": true,
"headerParameters": {
"parameters": [
{
"name": "Content-Type",
"value": "application/json"
}
]
},
"sendBody": true,
"bodyParameters": {
"parameters": [
{
"name": "model",
"value": "gpt-3.5-turbo"
},
{
"name": "messages",
"value": "=[{\"role\": \"user\", \"content\": \"{{ $json.enhanced_prompt }}\"}]"
},
{
"name": "temperature",
"value": "={{ $json.creativity_level }}"
},
{
"name": "max_tokens",
"value": "1000"
}
]
},
"options": {
"response": {
"response": {
"responseFormat": "json"
}
}
}
},
"id": "openai-request",
"name": "OpenAI Request",
"type": "n8n-nodes-base.httpRequest",
"typeVersion": 4.1,
"position": [
1120,
200
],
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
}
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "final_response",
"name": "final_response",
"value": "={{ $json.enhanced_prompt }}",
"type": "string"
},
{
"id": "metadata",
"name": "metadata",
"value": "={{ $json }}",
"type": "object"
},
{
"id": "response_type",
"name": "response_type",
"value": "enhanced_prompt_only",
"type": "string"
}
]
},
"options": {}
},
"id": "format-response-no-ai",
"name": "Format Response (No AI)",
"type": "n8n-nodes-base.set",
"typeVersion": 3.2,
"position": [
1120,
400
]
},
{
"parameters": {
"jsCode": "// Format OpenAI response\nconst aiResponse = $input.item(0).json;\nconst originalData = $input.item(1).json;\n\nlet finalResponse = {\n success: true,\n original_prompt: originalData.original_prompt,\n enhanced_prompt: originalData.enhanced_prompt,\n ai_response: aiResponse.choices?.[0]?.message?.content || 'No AI response available',\n metadata: {\n prompt_type: originalData.prompt_type,\n creativity_level: originalData.creativity_level,\n language: originalData.language,\n timestamp: originalData.timestamp,\n ai_model_used: 'gpt-3.5-turbo',\n tokens_used: aiResponse.usage?.total_tokens || 0\n }\n};\n\nreturn [{ json: finalResponse }];"
},
"id": "format-ai-response",
"name": "Format AI Response",
"type": "n8n-nodes-base.code",
"typeVersion": 2,
"position": [
1340,
200
]
},
{
"parameters": {
"assignments": {
"assignments": [
{
"id": "final_output",
"name": "final_output",
"value": "={{ $json }}",
"type": "object"
}
]
},
"options": {}
},
"id": "merge-responses",
"name": "Merge Responses",
"type": "n8n-nodes-base.set",
"typeVersion": 3.2,
"position": [
1560,
300
]
},
{
"parameters": {
"respondWith": "json",
"responseBody": "={{ $json.final_output || $json }}",
"options": {
"responseHeaders": {
"entries": [
{
"name": "Content-Type",
"value": "application/json"
},
{
"name": "Access-Control-Allow-Origin",
"value": "*"
}
]
}
}
},
"id": "webhook-response",
"name": "Webhook Response",
"type": "n8n-nodes-base.respondToWebhook",
"typeVersion": 1,
"position": [
1780,
300
]
}
],
"connections": {
"Webhook Start": {
"main": [
[
{
"node": "Extract Parameters",
"type": "main",
"index": 0
}
]
]
},
"Extract Parameters": {
"main": [
[
{
"node": "Enhance Prompt",
"type": "main",
"index": 0
}
]
]
},
"Enhance Prompt": {
"main": [
[
{
"node": "Check AI Integration",
"type": "main",
"index": 0
}
]
]
},
"Check AI Integration": {
"main": [
[
{
"node": "OpenAI Request",
"type": "main",
"index": 0
}
],
[
{
"node": "Format Response (No AI)",
"type": "main",
"index": 0
}
]
]
},
"OpenAI Request": {
"main": [
[
{
"node": "Format AI Response",
"type": "main",
"index": 0
}
]
]
},
"Format Response (No AI)": {
"main": [
[
{
"node": "Merge Responses",
"type": "main",
"index": 0
}
]
]
},
"Format AI Response": {
"main": [
[
{
"node": "Merge Responses",
"type": "main",
"index": 0
}
]
]
},
"Merge Responses": {
"main": [
[
{
"node": "Webhook Response",
"type": "main",
"index": 0
}
]
]
}
},
"settings": {
"executionOrder": "v1"
},
"staticData": null,
"tags": [
{
"createdAt": "2025-01-08T10:00:00.000Z",
"updatedAt": "2025-01-08T10:00:00.000Z",
"id": "prompt-generator",
"name": "Prompt Generator"
}
],
"triggerCount": 1,
"updatedAt": "2025-01-08T10:00:00.000Z",
"versionId": "1"
}
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.
googlePalmApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow is for AI builders, prompt engineers, developers, marketers, and no-code creators who want to convert rough user input into structured, high-quality prompts for LLMs. It’s especially useful for tools that rely on precision prompting and want to automate the…
Source: https://n8n.io/workflows/5045/ — original creator credit. Request a take-down →
Related workflows
Workflows that share integrations, category, or trigger type with this one. All free to copy and import.
Content - Newsletter Agent. Uses formTrigger, chainLlm, outputParserStructured, httpRequest. Event-driven trigger; 91 nodes.
Content - Newsletter Agent. Uses formTrigger, chainLlm, outputParserStructured, httpRequest. Event-driven trigger; 87 nodes.
Host Your Own AI Deep Research Agent with n8n, Apify and OpenAI. Uses outputParserStructured, lmChatOpenAi, formTrigger, chainLlm. Event-driven trigger; 87 nodes.
This template attempts to replicate OpenAI's DeepResearch feature which, at time of writing, is only available to their pro subscribers.
My workflow 53. Uses formTrigger, httpRequest, lmChatOpenAi, form. Event-driven trigger; 74 nodes.