{
  "id": "zcMsl2ECqGK6naSU",
  "meta": {
    "templateCredsSetupCompleted": true
  },
  "name": "Detect, Analyze and Humanize AI-generated text",
  "tags": [],
  "nodes": [
    {
      "id": "ef1f3ff4-b88a-4150-bd67-ddca955fd1cd",
      "name": "When clicking \u2018Execute workflow\u2019",
      "type": "n8n-nodes-base.manualTrigger",
      "position": [
        -32,
        496
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "fd13ca46-8b5e-47af-a8d9-dc435580392d",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        352
      ],
      "parameters": {
        "color": 7,
        "width": 1120,
        "height": 560,
        "content": "## STEP 1 - Detect text AI\n\"Set Text\" in the relative node\nSupported Languages:\n - English,  German, French, Spanish, Italian, Portuguese, Dutch, Polish, Japanese\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\nScore Interpretation:\n - Overall Score: Ranges from 0 (human) to 100 (AI).\n - Sentence Scores (mode = \"depth\"): 0 is human, 100 is AI.\n - Other modes: 100 indicates human, 0 indicates AI.\n\nFlesch Score Interpretation:\n - The Flesch score measures readability. Higher scores indicate easier-to-read text.\n - Range: 0-100. A score of 60-70 is easily readable for 13- to 15-year-olds.\n - A higher score often means simpler language."
      },
      "typeVersion": 1
    },
    {
      "id": "0b83d4a2-b3b8-401c-bb8c-116f64332e9c",
      "name": "Split Out",
      "type": "n8n-nodes-base.splitOut",
      "position": [
        1168,
        496
      ],
      "parameters": {
        "include": "allOtherFields",
        "options": {},
        "fieldToSplitOut": "sentences"
      },
      "typeVersion": 1
    },
    {
      "id": "2bd02c16-3abe-425b-8cea-aaa2f0dcf982",
      "name": "Loop Over Items",
      "type": "n8n-nodes-base.splitInBatches",
      "position": [
        1424,
        496
      ],
      "parameters": {
        "options": {}
      },
      "typeVersion": 3
    },
    {
      "id": "715bdee9-eea0-4f7b-a94f-231eb7ef4d53",
      "name": "Set text",
      "type": "n8n-nodes-base.set",
      "position": [
        240,
        496
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "9c8ea44b-8910-4d4b-b754-2c79790e6d69",
              "name": "text",
              "type": "string",
              "value": "XXX"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8e122543-dd1a-4f50-8f7d-73434d2b21f9",
      "name": "AI Detector",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        576,
        496
      ],
      "parameters": {
        "url": "https://detector.rephrasy.ai/detect_api",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"text\": \"{{ $json.text }}\", \n  \"mode\": \"depth\"\n} ",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "b2f4a6dc-7c94-4f32-bcc1-37ec40daac27",
      "name": "AI Humanizer",
      "type": "n8n-nodes-base.httpRequest",
      "position": [
        2064,
        368
      ],
      "parameters": {
        "url": "https://v2-humanizer.rephrasy.ai/api",
        "method": "POST",
        "options": {},
        "jsonBody": "={\n  \"text\": \"{{ $json.sentences.text }}\", \n  \"model\": \"v3\", \n  \"words\": true, \n  \"costs\": true, \n  \"language\": \"English\"\n} ",
        "sendBody": true,
        "sendHeaders": true,
        "specifyBody": "json",
        "authentication": "genericCredentialType",
        "genericAuthType": "httpBearerAuth",
        "headerParameters": {
          "parameters": [
            {
              "name": "Content-Type",
              "value": "application/json"
            }
          ]
        }
      },
      "credentials": {
        "httpBearerAuth": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 4.4
    },
    {
      "id": "ca618c12-023e-44b9-a1b4-7b2d3d8859cd",
      "name": "Get sentences",
      "type": "n8n-nodes-base.code",
      "position": [
        864,
        496
      ],
      "parameters": {
        "jsCode": "const output = [];\n\nfor (const item of $input.all()) {\n\n  const input = item.json;\n\n  const data = Array.isArray(input) ? input[0] : input;\n\n  const sentences = data.sentences || {};\n\n  const merged = [];\n\n  for (const [text, score] of Object.entries(sentences)) {\n    merged.push({\n      text,\n      score,\n      type: score > 50 ? \"ai\" : \"human\"\n    });\n  }\n\n  output.push({\n    json: {\n      sentences: merged\n    }\n  });\n}\n\nreturn output;"
      },
      "typeVersion": 2
    },
    {
      "id": "555d788a-e44c-46f2-985a-9c0a7c513213",
      "name": "> 50?",
      "type": "n8n-nodes-base.if",
      "position": [
        1728,
        512
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 3,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "7fdefab6-fba8-4036-a279-7dcff04d23a3",
              "operator": {
                "type": "number",
                "operation": "gt"
              },
              "leftValue": "={{ $json.sentences.score }}",
              "rightValue": 50
            }
          ]
        }
      },
      "typeVersion": 2.3
    },
    {
      "id": "34f11c29-87dd-4855-8d03-985f2a75ae77",
      "name": "Text",
      "type": "n8n-nodes-base.set",
      "position": [
        2080,
        592
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "70cc6f8a-85f4-41a4-91fa-0f34efdbc8a7",
              "name": "text",
              "type": "string",
              "value": "={{ $json.sentences.text }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "37f68738-b5d0-4732-a633-cfd601a7ad2d",
      "name": "Continue...",
      "type": "n8n-nodes-base.noOp",
      "position": [
        2064,
        48
      ],
      "parameters": {},
      "typeVersion": 1
    },
    {
      "id": "c7086527-1ac1-4c4b-83d2-45e64c8f294c",
      "name": "Text 2",
      "type": "n8n-nodes-base.set",
      "position": [
        2432,
        704
      ],
      "parameters": {
        "options": {},
        "assignments": {
          "assignments": [
            {
              "id": "7ae2d5b9-fe1d-478e-b276-4ed9bdca522f",
              "name": "text",
              "type": "string",
              "value": "={{ $json.output }}"
            }
          ]
        }
      },
      "typeVersion": 3.4
    },
    {
      "id": "8327437e-b39d-4a59-a257-fb9c0a7a9b8c",
      "name": "Aggregate Text",
      "type": "n8n-nodes-base.aggregate",
      "position": [
        1744,
        48
      ],
      "parameters": {
        "options": {},
        "fieldsToAggregate": {
          "fieldToAggregate": [
            {
              "fieldToAggregate": "text"
            }
          ]
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3b7efced-5217-4134-a3fd-4eaabb3319d6",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        176,
        -96
      ],
      "parameters": {
        "width": 1120,
        "height": 432,
        "content": "## Detect, Analyze and Humanize AI-generated text automatically\nThe workflow then sends this text to an AI detection service to evaluate how \u201cAI-like\u201d it is. The text is broken down into individual sentences, and each sentence is scored based on its likelihood of being AI-generated.\n\n### How it works\n\nThe workflow takes an input text, sends it to the Rephrasy AI Detector, and receives sentence-level scores showing how likely each sentence is to be AI-generated. A code step labels each sentence as AI or human, then the workflow loops through them and only routes sentences with a score above 50 to the AI Humanizer for rewriting. Sentences already considered human are kept unchanged, and all results are merged back into one final text.\n\n### Setup steps\n\nCreate and connect an HTTP Bearer Auth credential in n8n for both the AI Detector and AI Humanizer nodes using your Rephrasy API key. Then update the **Set text** node with the text you want to process, or map in text from another trigger such as a webhook or form. Check that the `language` field in the AI Humanizer node matches your input language, then run the workflow manually or activate it for ongoing use.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "7e8c2f91-e216-4d7b-be8e-52efb57d6f9d",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1696,
        240
      ],
      "parameters": {
        "color": 7,
        "width": 992,
        "height": 672,
        "content": "## STEP 2 - Conditional Humanization\n\nFor each sentence, the \"> 50?\" node (IF condition) checks the AI score. If the score is greater than 50 (indicating AI), the workflow routes the sentence to the **AI Humanizer** node to be rewritten. If the score is 50 or less (human), the sentence is passed through unchanged."
      },
      "typeVersion": 1
    },
    {
      "id": "358246c3-08d2-4edb-8f96-89c76ced1438",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1696,
        -96
      ],
      "parameters": {
        "color": 7,
        "width": 992,
        "height": 320,
        "content": "## STEP 3 - Reassembly\n\nOnce the loop finishes, the \u201cAggregate Text\u201d node collects all the sentences (both the rewritten AI sentences and the original human sentences) and reassembles them into a single, final text output."
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "binaryMode": "separate",
    "executionOrder": "v1"
  },
  "versionId": "0633093c-7dbb-429d-af22-f7ad8847b499",
  "connections": {
    "Text": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "> 50?": {
      "main": [
        [
          {
            "node": "AI Humanizer",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Text 2": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Set text": {
      "main": [
        [
          {
            "node": "AI Detector",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Split Out": {
      "main": [
        [
          {
            "node": "Loop Over Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Detector": {
      "main": [
        [
          {
            "node": "Get sentences",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Humanizer": {
      "main": [
        [
          {
            "node": "Text 2",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get sentences": {
      "main": [
        [
          {
            "node": "Split Out",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Aggregate Text": {
      "main": [
        [
          {
            "node": "Continue...",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Loop Over Items": {
      "main": [
        [
          {
            "node": "Aggregate Text",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "> 50?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "When clicking \u2018Execute workflow\u2019": {
      "main": [
        [
          {
            "node": "Set text",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}