{
  "name": "prompt-qa-lab-openai",
  "nodes": [
    {
      "id": "a7b8c9d0-0001-4000-8000-000000000001",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        300
      ],
      "parameters": {
        "httpMethod": "POST",
        "path": "prompt-qa-lab",
        "responseMode": "onReceived",
        "options": {}
      }
    },
    {
      "id": "a7b8c9d0-0002-4000-8000-000000000002",
      "name": "Run Prompt: GPT-4o",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        220,
        160
      ],
      "parameters": {
        "model": "gpt-4o",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "={{ $json.system_prompt }}"
            },
            {
              "role": "user",
              "content": "={{ $json.user_input }}"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "a7b8c9d0-0003-4000-8000-000000000003",
      "name": "Run Prompt: GPT-4o-mini",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        220,
        440
      ],
      "parameters": {
        "model": "gpt-4o-mini",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "={{ $('Webhook Trigger').item.json.system_prompt }}"
            },
            {
              "role": "user",
              "content": "={{ $('Webhook Trigger').item.json.user_input }}"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "a7b8c9d0-0004-4000-8000-000000000004",
      "name": "Collect Outputs",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [
        440,
        300
      ],
      "parameters": {
        "mode": "manual",
        "fields": {
          "values": [
            {
              "name": "prompt_label",
              "type": "expression",
              "value": "={{ $('Webhook Trigger').item.json.prompt_label }}"
            },
            {
              "name": "system_prompt",
              "type": "expression",
              "value": "={{ $('Webhook Trigger').item.json.system_prompt }}"
            },
            {
              "name": "user_input",
              "type": "expression",
              "value": "={{ $('Webhook Trigger').item.json.user_input }}"
            },
            {
              "name": "rubric",
              "type": "expression",
              "value": "={{ $('Webhook Trigger').item.json.rubric }}"
            },
            {
              "name": "output_gpt4o",
              "type": "expression",
              "value": "={{ $('Run Prompt: GPT-4o').item.json.message.content }}"
            },
            {
              "name": "output_gpt4o_mini",
              "type": "expression",
              "value": "={{ $('Run Prompt: GPT-4o-mini').item.json.message.content }}"
            }
          ]
        }
      }
    },
    {
      "id": "a7b8c9d0-0005-4000-8000-000000000005",
      "name": "Score Outputs",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1,
      "position": [
        660,
        300
      ],
      "parameters": {
        "model": "gpt-4o",
        "messages": {
          "values": [
            {
              "role": "system",
              "content": "You are a prompt quality evaluator. Score two model outputs against a rubric. Return ONLY valid JSON:\n{\n  \"scores\": {\n    \"gpt_4o\": {\"score\": 8, \"rationale\": \"one sentence\"},\n    \"gpt_4o_mini\": {\"score\": 6, \"rationale\": \"one sentence\"}\n  },\n  \"winner\": \"gpt_4o\",\n  \"recommendation\": \"one sentence on which model to use and why\"\n}"
            },
            {
              "role": "user",
              "content": "Rubric: {{ $json.rubric }}\n\nOutput A (gpt-4o):\n{{ $json.output_gpt4o }}\n\nOutput B (gpt-4o-mini):\n{{ $json.output_gpt4o_mini }}"
            }
          ]
        }
      },
      "credentials": {
        "openAiApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "a7b8c9d0-0006-4000-8000-000000000006",
      "name": "Build Report",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3,
      "position": [
        880,
        300
      ],
      "parameters": {
        "mode": "manual",
        "fields": {
          "values": [
            {
              "name": "report",
              "type": "expression",
              "value": "={{ JSON.parse($json.message.content) }}"
            },
            {
              "name": "prompt_label",
              "type": "expression",
              "value": "={{ $('Collect Outputs').item.json.prompt_label }}"
            },
            {
              "name": "output_gpt4o",
              "type": "expression",
              "value": "={{ $('Collect Outputs').item.json.output_gpt4o }}"
            },
            {
              "name": "output_gpt4o_mini",
              "type": "expression",
              "value": "={{ $('Collect Outputs').item.json.output_gpt4o_mini }}"
            }
          ]
        }
      }
    },
    {
      "id": "a7b8c9d0-0007-4000-8000-000000000007",
      "name": "Post Results to Slack",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2,
      "position": [
        1100,
        300
      ],
      "parameters": {
        "operation": "post",
        "select": "channel",
        "channelId": {
          "value": "#prompt-lab"
        },
        "text": "Prompt QA Results: {{ $json.prompt_label }}\n\nGPT-4o: {{ $json.report.scores.gpt_4o.score }}/10 - {{ $json.report.scores.gpt_4o.rationale }}\nGPT-4o-mini: {{ $json.report.scores.gpt_4o_mini.score }}/10 - {{ $json.report.scores.gpt_4o_mini.rationale }}\n\nWinner: {{ $json.report.winner }}\nRecommendation: {{ $json.report.recommendation }}",
        "otherOptions": {}
      },
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Run Prompt: GPT-4o",
            "type": "main",
            "index": 0
          },
          {
            "node": "Run Prompt: GPT-4o-mini",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Prompt: GPT-4o": {
      "main": [
        [
          {
            "node": "Collect Outputs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run Prompt: GPT-4o-mini": {
      "main": [
        [
          {
            "node": "Collect Outputs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Collect Outputs": {
      "main": [
        [
          {
            "node": "Score Outputs",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Score Outputs": {
      "main": [
        [
          {
            "node": "Build Report",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Build Report": {
      "main": [
        [
          {
            "node": "Post Results to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "tags": [],
  "triggerCount": 1,
  "updatedAt": "2026-05-17T00:00:00.000Z",
  "versionId": "v1"
}