This workflow corresponds to n8n.io template #7606 — we link there as the canonical source.
This workflow follows the Agent → Chat 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 →
{
"meta": {
"templateCredsSetupCompleted": true
},
"nodes": [
{
"id": "8f16c045-53e2-4405-9053-7dd634d6e82f",
"name": "Sticky Note33",
"type": "n8n-nodes-base.stickyNote",
"position": [
-2048,
8448
],
"parameters": {
"width": 400,
"height": 752,
"content": "## \u2699\ufe0f Setup Instructions\n\n### 1\ufe0f\u20e3 Set Up OpenAI Connection\n1. Go to [OpenAI Platform](https://platform.openai.com/api-keys) \n2. Navigate to [OpenAI Billing](https://platform.openai.com/settings/organization/billing/overview) \n3. Add funds to your billing account \n4. Copy your API key into the **OpenAI credentials** in n8n \n\n\n\n## \ud83d\udcec Contact Information\nNeed help customizing this workflow or building similar automations?\n\n\ud83d\udce7 [robert@ynteractive.com](mailto:robert@ynteractive.com) \n\ud83d\udd17 [Robert Breen](https://www.linkedin.com/in/robert-breen-29429625/) \n\ud83c\udf10 [ynteractive.com](https://ynteractive.com)\n"
},
"typeVersion": 1
},
{
"id": "1faa8374-59e4-4371-a7ed-c17301b8aca7",
"name": "Sticky Note34",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1616,
8448
],
"parameters": {
"color": 7,
"width": 1104,
"height": 752,
"content": "# \ud83d\udee0\ufe0f AI System Prompt Generator & Optimizer (n8n + OpenAI)\n\nThis workflow acts as a **System Prompt Optimizer Agent**. \nYou send it a draft prompt or goal, and it returns: \n1. A rewritten **optimized system prompt** that is clear, specific, and actionable. \n2. A recommendation for the **best OpenAI model** to use based on reasoning needs, complexity, and latency/cost tradeoffs. \n\n"
},
"typeVersion": 1
},
{
"id": "39899c3c-ec7e-4598-873a-0172a79db705",
"name": "OpenAI Chat Model10",
"type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
"position": [
-1040,
9040
],
"parameters": {
"model": {
"__rl": true,
"mode": "list",
"value": "gpt-5",
"cachedResultName": "gpt-5"
},
"options": {}
},
"credentials": {
"openAiApi": {
"name": "<your credential>"
}
},
"typeVersion": 1.2
},
{
"id": "b325fa59-0b59-4535-a0a9-7f3be237044f",
"name": "Sticky Note35",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1152,
8864
],
"parameters": {
"color": 3,
"width": 288,
"height": 304,
"content": "### 1\ufe0f\u20e3 Set Up OpenAI Connection\n1. Go to [OpenAI Platform](https://platform.openai.com/api-keys) \n2. Navigate to [OpenAI Billing](https://platform.openai.com/settings/organization/billing/overview) \n3. Add funds to your billing account \n4. Copy your API key into the **OpenAI credentials** in n8n "
},
"typeVersion": 1
},
{
"id": "fae4be3e-f184-490e-bd98-4108ac657d5f",
"name": "Simple Memory2",
"type": "@n8n/n8n-nodes-langchain.memoryBufferWindow",
"position": [
-688,
9024
],
"parameters": {},
"typeVersion": 1.3
},
{
"id": "12da8616-e4ac-4a4d-8e3b-0387a4c3748f",
"name": "AI Prompt Generator",
"type": "@n8n/n8n-nodes-langchain.agent",
"position": [
-976,
8672
],
"parameters": {
"options": {
"systemMessage": "You are a System Prompt Optimizer. \nYour job is to take a user\u2019s goal or draft prompt and return an optimized system prompt that is clear, specific, and actionable. \n\n### Rules:\n- Always rewrite the input into a polished, professional **system prompt**. \n- Ensure the system prompt includes explicit rules, roles, and constraints where useful. \n- Make it concise but detailed enough to remove ambiguity. \n- Recommend the **best OpenAI model** to use for this prompt, based on complexity, reasoning needs, and latency/cost tradeoffs. \n"
},
"hasOutputParser": true
},
"typeVersion": 2.2
},
{
"id": "77d09a63-9b3c-47cf-a7a4-de76d4a84a07",
"name": "Sticky Note36",
"type": "n8n-nodes-base.stickyNote",
"position": [
-1536,
8736
],
"parameters": {
"color": 3,
"width": 288,
"height": 304,
"content": "### example question\n\nI need a system prompt for an agent that summarizes meeting transcripts into 3 bullet points for executives.\n "
},
"typeVersion": 1
},
{
"id": "a5c3ebce-f05b-4985-96ef-b98b8db66a22",
"name": "Chat Message",
"type": "@n8n/n8n-nodes-langchain.chatTrigger",
"position": [
-1440,
8880
],
"parameters": {
"options": {}
},
"typeVersion": 1.3
}
],
"connections": {
"Chat Message": {
"main": [
[
{
"node": "AI Prompt Generator",
"type": "main",
"index": 0
}
]
]
},
"Simple Memory2": {
"ai_memory": [
[
{
"node": "AI Prompt Generator",
"type": "ai_memory",
"index": 0
}
]
]
},
"AI Prompt Generator": {
"main": [
[]
]
},
"OpenAI Chat Model10": {
"ai_languageModel": [
[
{
"node": "AI Prompt Generator",
"type": "ai_languageModel",
"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.
openAiApi
For the full experience including quality scoring and batch install features for each workflow upgrade to Pro
About this workflow
This workflow acts as a System Prompt Optimizer Agent. You send it a draft prompt or goal, and it returns: A rewritten optimized system prompt that is clear, specific, and actionable. A recommendation for the best OpenAI model to use based on reasoning needs, complexity, and…
Source: https://n8n.io/workflows/7606/ — 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.
Generate Sql Queries From Schema Only Ai Powered. Uses lmChatOpenAi, memoryBufferWindow, noOp, mySql. Chat trigger; 29 nodes.
Generate SQL queries from schema only - AI-powered. Uses lmChatOpenAi, memoryBufferWindow, noOp, mySql. Chat trigger; 29 nodes.
Generate SQL queries from schema only - AI-powered. Uses lmChatOpenAi, memoryBufferWindow, noOp, mySql. Chat trigger; 29 nodes.
This workflow is a modification of the previous template on how to create an SQL agent with LangChain and SQLite.
This n8n template provides a powerful AI-powered chatbot that acts as your personal Spotify DJ. Simply tell the chatbot what kind of music you're in the mood for, and it will intelligently create a cu