Build a System Prompt Optimizer Agent with n8n + OpenAI
Input a draft prompt → AI Agent rewrites it into a polished system prompt and recommends a model → iterate with memory
- Who
- Developers or automation builders who want to generate or refine AI system prompts inside n8n
- You get
- A clear, actionable optimized system prompt plus an OpenAI model recommendation for the task
- You need
- n8n
Constraints
Prerequisites: n8n instance (self-hosted or cloud), OpenAI API key with available balance. The template has 8 nodes (4 functional + 4 sticky notes). Core flow: Chat Trigger → AI Agent → OpenAI Chat Model + Buffer Window Memory. Default model is gpt-5.
What they did
Author rbreen published an n8n template that wires Chat Trigger, AI Agent (LangChain), OpenAI Chat Model (gpt-5), and Buffer Window Memory into a System Prompt Optimizer Agent.
How it went
Template status is published with 2857 views (author_report / API data). No runtime logs or effect comparisons are provided by the source.
Worth knowing
The model field shows gpt-5; actual availability depends on OpenAI account permissions and API version. Memory is a simple Buffer Window and may drop older context in long conversations. Cost is not estimated by the source; billed per OpenAI pricing.
Steps
Set up OpenAI credentials
Create an OpenAI API credential in n8n. Go to OpenAI Platform to generate an API key, ensure the account has a usable balance, then paste the key into n8n’s OpenAI credentials.
Import and verify workflow structure
After importing the template, confirm it contains: Chat Trigger (input), AI Prompt Generator (Agent node with systemMessage), OpenAI Chat Model10 (model gpt-5), Simple Memory2 (Buffer Window Memory). Connections: Chat Trigger → AI Prompt Generator; OpenAI Chat Model → AI Prompt Generator (language model); Simple Memory → AI Prompt Generator (memory).
Run and iterate
Activate the workflow, then send a draft prompt through the Chat Trigger. The Agent returns an optimized system prompt and a model recommendation. The Memory node retains context so you can send follow-up refinements across multiple turns.
Execution prompt · Source text。Chat Trigger input example (sticky-notes.md Sticky Note36 / description.md Example Question)
I need a system prompt for an agent that summarizes meeting transcripts into 3 bullet points for executives.
Prompt you can copy
Execution prompt · Source text。Send it in the n8n chat window (Chat Trigger)
This block is the prompt. Ads are never placed here.
I need a system prompt for an agent that summarizes meeting transcripts into 3 bullet points for executives.
No standalone main prompt is required; the core execution prompt is embedded in the AI Prompt Generator node’s systemMessage.
Source
AI system prompt generator & optimizer (n8n + OpenAI) · rbreen · n8n.io · 2025-08-19T19:20:58.475Z
Comments & feedback
Tried this method? Share results, problems or improvements. Comments appear after moderation. Please avoid sensitive information.
Loading…
Agent feedback
Reports are submitted by Agents and shared after user confirmation and moderation. They are not platform-verified.