{
  "name": "AI Text Scorer (Lite)",
  "nodes": [
    {
      "parameters": {
        "content": "## AI Text Scorer (Lite)\n\nA webhook you can POST any text to. Claude returns an overall quality score (0-100) plus a short comment.\n\nA free, single-purpose starter. The full version adds configurable scoring dimensions, per-dimension scores, concrete strengths & improvements, input validation, and API-failure handling.",
        "height": 260,
        "width": 380
      },
      "id": "b1c2c3d4-0001-4000-8000-000000000001",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -520,
        -240
      ]
    },
    {
      "parameters": {
        "content": "Setup (2 things):\n1. Add your Anthropic API key as a Header Auth credential (header name: x-api-key) on \"Score with Claude\".\n2. Activate the workflow, open this Webhook node, copy the Production URL.\n\nThen POST JSON: { \"content\": \"your text here\" }",
        "height": 240,
        "width": 300
      },
      "id": "b1c2c3d4-0002-4000-8000-000000000002",
      "name": "Setup Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -520,
        40
      ]
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "score-text",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "b1c2c3d4-0003-4000-8000-000000000003",
      "name": "Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        -200,
        0
      ]
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const item = $input.item.json;\nconst body = item.body || item;\nconst content = (body.content || body.text || '').toString().trim();\nreturn {\n  json: {\n    content: content.substring(0, 4000)\n  }\n};"
      },
      "id": "b1c2c3d4-0004-4000-8000-000000000004",
      "name": "Extract Text",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        60,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://api.anthropic.com/v1/messages",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpHeaderAuth",
        "sendHeaders": true,
        "headerParameters": {
          "parameters": [
            {
              "name": "anthropic-version",
              "value": "2023-06-01"
            },
            {
              "name": "content-type",
              "value": "application/json"
            }
          ]
        },
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({\n  model: \"claude-sonnet-4-6\",\n  max_tokens: 400,\n  system: \"You are a writing quality reviewer. Respond with ONLY a valid JSON object, no markdown, no code fences: { \\\"score\\\": integer from 0 to 100, \\\"comment\\\": string with one or two sentences of feedback }.\",\n  messages: [\n    {\n      role: \"user\",\n      content: \"Score the overall quality of this text:\\n\\n\" + $json.content\n    }\n  ]\n}) }}",
        "options": {
          "timeout": 30000
        }
      },
      "id": "b1c2c3d4-0005-4000-8000-000000000005",
      "name": "Score with Claude",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        320,
        0
      ],
      "credentials": {
        "httpHeaderAuth": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "mode": "runOnceForEachItem",
        "jsCode": "const raw = $input.item.json;\nlet parsed;\ntry {\n  let text = raw.content && raw.content[0] && raw.content[0].text ? raw.content[0].text : '';\n  const match = text.trim().match(/\\{[\\s\\S]*\\}/);\n  if (!match) throw new Error('no json');\n  parsed = JSON.parse(match[0]);\n} catch (err) {\n  parsed = { score: null, comment: 'Could not parse AI response.' };\n}\nreturn {\n  json: {\n    score: parsed.score,\n    comment: parsed.comment\n  }\n};"
      },
      "id": "b1c2c3d4-0006-4000-8000-000000000006",
      "name": "Parse Response",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        580,
        0
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { score: $json.score, comment: $json.comment } }}",
        "options": {}
      },
      "id": "b1c2c3d4-0007-4000-8000-000000000007",
      "name": "Respond with Score",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        840,
        0
      ]
    }
  ],
  "connections": {
    "Webhook": {
      "main": [
        [
          {
            "node": "Extract Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Text": {
      "main": [
        [
          {
            "node": "Score with Claude",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Score with Claude": {
      "main": [
        [
          {
            "node": "Parse Response",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Parse Response": {
      "main": [
        [
          {
            "node": "Respond with Score",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "00000000-0000-4000-8000-000000000000",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "id": "ai-text-scorer-lite-001",
  "tags": []
}