AutomationFlowsAI & RAG › AI Prompt Refiner Workflow

AI Prompt Refiner Workflow

Original n8n title: Prompt Refiner

Prompt Refiner. Uses lmChatOpenRouter, chainLlm, agent. Webhook trigger; 6 nodes.

Webhook trigger★★☆☆☆ complexityAI-powered6 nodesOpenRouter ChatChain LlmAgent
AI & RAG Trigger: Webhook Nodes: 6 Complexity: ★★☆☆☆ AI nodes: yes Added:

This workflow follows the Agent → Chainllm 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
{
  "name": "Prompt Refiner",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "refine-prompt",
        "responseMode": "responseNode",
        "options": {}
      },
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.1,
      "position": [
        -576,
        -160
      ],
      "id": "webhook-node",
      "name": "Webhook"
    },
    {
      "parameters": {
        "options": {}
      },
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.5,
      "position": [
        352,
        -160
      ],
      "id": "respond-webhook-node",
      "name": "Respond to Webhook",
      "notesInFlow": false,
      "alwaysOutputData": false
    },
    {
      "parameters": {
        "model": "deepseek/deepseek-r1-0528:free",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        -288,
        64
      ],
      "id": "openrouter-classifier-model",
      "name": "OpenRouter Chat Model",
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{$node[\"Webhook\"].json[\"body\"][\"prompt\"]}}\n",
        "messages": {
          "messageValues": [
            {
              "message": "You are a prompt classification engine.  Analyze the user's prompt and return STRICT JSON with: - intent: one of [coding, design, debugging, explanation, brainstorming] - domain: one of [frontend, backend, devops, uiux, data, general] - missing_context: array of missing but important details - ambiguities: array of unclear or vague parts  Rules: - Return JSON only - No markdown - No explanations"
            }
          ]
        },
        "batching": {}
      },
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.7,
      "position": [
        -352,
        -160
      ],
      "id": "classifier-node",
      "name": "Classifier"
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "={{$node[\"Classifier\"].json[\"text\"]}}\n",
        "options": {
          "systemMessage": "You are a prompt refinement engine.\n\nRewrite the user's original prompt into a clear, complete, and high-quality prompt for an LLM.\n\nRules:\n- Keep the original intent\n- Make reasonable assumptions to fill in missing context (don't ask questions)\n- Resolve ambiguities with sensible defaults\n- Do NOT ask clarifying questions\n- Do NOT list options or alternatives\n- Output ONLY the improved prompt as plain text\n- No markdown, no bullet points, no explanations"
        }
      },
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 3,
      "position": [
        0,
        -160
      ],
      "id": "refiner-node",
      "name": "Refiner"
    },
    {
      "parameters": {
        "model": "deepseek/deepseek-r1-0528:free",
        "options": {}
      },
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenRouter",
      "typeVersion": 1,
      "position": [
        80,
        64
      ],
      "id": "openrouter-refiner-model",
      "name": "OpenRouter Chat Model1",
      "credentials": {
        "openRouterApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Classifier",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Classifier",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Classifier": {
      "main": [
        [
          {
            "node": "Refiner",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Refiner": {
      "main": [
        [
          {
            "node": "Respond to Webhook",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenRouter Chat Model1": {
      "ai_languageModel": [
        [
          {
            "node": "Refiner",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "tags": []
}

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

Prompt Refiner. Uses lmChatOpenRouter, chainLlm, agent. Webhook trigger; 6 nodes.

Source: https://github.com/Hanfried-Nguegan/AI-Prompt-Refiner-Agent/blob/f8338f955f48cd25dbd996b95357b6dc1bdad0b1/n8n/refiner-workflow.json — 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

leads. Uses supabase, gmail, formTrigger, httpRequest. Webhook trigger; 62 nodes.

Supabase, Gmail, Form Trigger +13
AI & RAG

Transform your WhatsApp group conversations into actionable business intelligence through automated AI analysis and daily reporting. This workflow eliminates manual conversation monitoring by capturin

OpenRouter Chat, Output Parser Autofixing, Agent +6
AI & RAG

This workflow is designed for legal professionals, policy analysts, and compliance teams who need to: Research case law, legislation, and regulatory developments on specific topics Build comprehensive

HTTP Request Tool, Tool Http Request, Tool Think +5
AI & RAG

This workflow acts as an AI-powered research assistant that takes a topic from the user, performs multi-step intelligent research, and stores the final report in Notion. It uses advanced search, conte

Memory Buffer Window, Output Parser Structured, Agent +6
AI & RAG

This workflow is designed for researchers, analysts, and knowledge workers who need to: Gather comprehensive information on complex topics from multiple web sources Get AI-synthesized insights rather

Jina Ai Tool, Tool Think, OpenRouter Chat +5