Skip to content

In n8n, copy this file and paste it onto the canvas, or use Import from File.

{
  "name": "10 - AI Content Repurposer",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "repurpose",
        "responseMode": "responseNode",
        "options": {}
      },
      "id": "m10-webhook",
      "name": "Repurpose API",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        100
      ],
      "webhookId": "course-10-repurpose"
    },
    {
      "parameters": {
        "rules": {
          "values": [
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "u1",
                    "leftValue": "={{ String($json.body.url ?? '') }}",
                    "rightValue": "^https?://",
                    "operator": {
                      "type": "string",
                      "operation": "regex"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "url"
            },
            {
              "conditions": {
                "options": {
                  "caseSensitive": true,
                  "leftValue": "",
                  "typeValidation": "strict",
                  "version": 2
                },
                "conditions": [
                  {
                    "id": "m1",
                    "leftValue": "={{ String($json.body.markdown ?? '').trim().length }}",
                    "rightValue": 200,
                    "operator": {
                      "type": "number",
                      "operation": "gte"
                    }
                  }
                ],
                "combinator": "and"
              },
              "renameOutput": true,
              "outputKey": "markdown"
            }
          ]
        },
        "options": {
          "fallbackOutput": "extra",
          "renameFallbackOutput": "invalid"
        }
      },
      "id": "m10-switch",
      "name": "Input Type",
      "type": "n8n-nodes-base.switch",
      "typeVersion": 3.2,
      "position": [
        220,
        100
      ]
    },
    {
      "parameters": {
        "url": "={{ $json.body.url }}",
        "options": {
          "response": {
            "response": {
              "responseFormat": "text"
            }
          },
          "timeout": 15000
        }
      },
      "id": "m10-fetch",
      "name": "Fetch Article",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        440,
        -60
      ]
    },
    {
      "parameters": {
        "html": "={{ $json.data }}",
        "destinationKey": "markdown",
        "options": {
          "ignore": "script,style,nav,footer,header,aside,form,svg"
        }
      },
      "id": "m10-md",
      "name": "HTML to Markdown",
      "type": "n8n-nodes-base.markdown",
      "typeVersion": 1,
      "position": [
        660,
        -60
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "s1",
              "name": "source_text",
              "value": "={{ $json.markdown.slice(0, 15000) }}",
              "type": "string"
            },
            {
              "id": "s2",
              "name": "source",
              "value": "={{ $('Repurpose API').item.json.body.url }}",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "m10-from-url",
      "name": "Source from URL",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        880,
        -60
      ]
    },
    {
      "parameters": {
        "assignments": {
          "assignments": [
            {
              "id": "t1",
              "name": "source_text",
              "value": "={{ $json.body.markdown.slice(0, 15000) }}",
              "type": "string"
            },
            {
              "id": "t2",
              "name": "source",
              "value": "pasted markdown",
              "type": "string"
            }
          ]
        },
        "options": {}
      },
      "id": "m10-from-md",
      "name": "Source from Markdown",
      "type": "n8n-nodes-base.set",
      "typeVersion": 3.4,
      "position": [
        880,
        120
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { error: 'send {\"url\": \"https://...\"} or {\"markdown\": \"...\"} (at least 200 characters)' } }}",
        "options": {
          "responseCode": 400
        }
      },
      "id": "m10-400",
      "name": "Respond Bad Input",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        440,
        300
      ]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "=Repurpose the article below into social content.\n\nAudience: {{ $('Repurpose API').item.json.body.audience || 'developers and small-business owners learning automation' }}\nCall to action: {{ $('Repurpose API').item.json.body.cta || 'Get the free workflow (link in bio)' }}\n\nRules:\n- Write like a practitioner sharing what they built, not like a marketer. Concrete, specific, no hype words (no \"game-changer\", \"revolutionize\", \"unlock\").\n- Every hook must be under 12 words and create curiosity or name a pain.\n- Use only facts from the article. Do not invent numbers or results.\n- shorts: exactly 3 different angles (e.g. problem/solution, surprising lesson, quick tutorial). script is the spoken voiceover for 30–45 seconds (80–120 words). on_screen describes what to show.\n- linkedin_post: 120–200 words, short paragraphs, ends with the CTA.\n- x_thread: 4–6 posts, each under 270 characters, first post is a hook, last post has the CTA.\n- newsletter: subject under 60 characters and a 60–100 word blurb.\n\nARTICLE:\n{{ $json.source_text }}",
        "hasOutputParser": true
      },
      "id": "m10-chain",
      "name": "Write Content",
      "type": "@n8n/n8n-nodes-langchain.chainLlm",
      "typeVersion": 1.9,
      "position": [
        1100,
        40
      ]
    },
    {
      "parameters": {
        "model": {
          "__rl": true,
          "mode": "list",
          "value": "gpt-5-mini",
          "cachedResultName": "gpt-5-mini"
        },
        "options": {}
      },
      "id": "m10-model",
      "name": "OpenAI Chat Model",
      "type": "@n8n/n8n-nodes-langchain.lmChatOpenAi",
      "typeVersion": 1.3,
      "position": [
        1040,
        260
      ]
    },
    {
      "parameters": {
        "schemaType": "fromJson",
        "jsonSchemaExample": "{\n  \"shorts\": [\n    { \"angle\": \"problem/solution\", \"hook\": \"Your webhook returns nothing. Here's why.\", \"script\": \"Voiceover text...\", \"on_screen\": \"Screen recording of...\", \"caption\": \"Short caption #n8n\" }\n  ],\n  \"linkedin_post\": \"Post text...\",\n  \"x_thread\": [\"Post 1\", \"Post 2\"],\n  \"newsletter\": { \"subject\": \"Subject line\", \"blurb\": \"Blurb text...\" }\n}"
      },
      "id": "m10-parser",
      "name": "Content Format",
      "type": "@n8n/n8n-nodes-langchain.outputParserStructured",
      "typeVersion": 1.3,
      "position": [
        1200,
        260
      ]
    },
    {
      "parameters": {
        "respondWith": "json",
        "responseBody": "={{ { source: $(\"Source from URL\").isExecuted ? $(\"Source from URL\").item.json.source : \"pasted markdown\", generated_at: $now.toISO(), ...$json.output } }}",
        "options": {}
      },
      "id": "m10-respond",
      "name": "Respond",
      "type": "n8n-nodes-base.respondToWebhook",
      "typeVersion": 1.1,
      "position": [
        1420,
        40
      ]
    }
  ],
  "connections": {
    "Repurpose API": {
      "main": [
        [
          {
            "node": "Input Type",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Input Type": {
      "main": [
        [
          {
            "node": "Fetch Article",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Source from Markdown",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Respond Bad Input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Article": {
      "main": [
        [
          {
            "node": "HTML to Markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML to Markdown": {
      "main": [
        [
          {
            "node": "Source from URL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Source from URL": {
      "main": [
        [
          {
            "node": "Write Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Source from Markdown": {
      "main": [
        [
          {
            "node": "Write Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "OpenAI Chat Model": {
      "ai_languageModel": [
        [
          {
            "node": "Write Content",
            "type": "ai_languageModel",
            "index": 0
          }
        ]
      ]
    },
    "Content Format": {
      "ai_outputParser": [
        [
          {
            "node": "Write Content",
            "type": "ai_outputParser",
            "index": 0
          }
        ]
      ]
    },
    "Write Content": {
      "main": [
        [
          {
            "node": "Respond",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  }
}