Skip to content

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

{
  "name": "10 - AI Content Repurposer (starter)",
  "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": {
        "content": "## Your task\n1. Add a **Basic LLM Chain** fed by both *Source from …* nodes, with an **OpenAI Chat Model** (gpt-5-mini).\n2. Write the prompt: audience, CTA, voice rules (practitioner, no hype, facts only), and the format rules for 3 shorts, a LinkedIn post, an X thread and a newsletter blurb.\n3. Turn on *Require Specific Output Format* and connect a **Structured Output Parser** with a JSON example.\n4. Respond with `{{ $json.output }}`.\n\nTest: `WITH_CREDS=1 ./test/test.sh` (repurposes Module 01's blog post)",
        "height": 260,
        "width": 420
      },
      "id": "starter-task-note",
      "name": "Your Task",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        0,
        -340
      ]
    }
  ],
  "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": [
        []
      ]
    },
    "Source from Markdown": {
      "main": [
        []
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  }
}