{
  "name": "Repurpose a blog or YouTube piece into LinkedIn and X drafts",
  "nodes": [
    {
      "parameters": {
        "content": "## Repurpose a blog or YouTube piece into LinkedIn and X drafts\n\nPortfolio demo only. This workflow is an original example for demonstration. It is not client work and it does not represent a deployment for any customer.\n\nRun **Run demo** to execute the offline rules engine. The live branch is used only when the incoming item sets `demo` to false and the placeholder credentials have been replaced.",
        "height": 220,
        "width": 520,
        "color": 4
      },
      "id": "717f256e-3154-48b1-9be3-657438d17020",
      "name": "Overview",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -40,
        -40
      ]
    },
    {
      "parameters": {},
      "id": "9de8c9c2-bcfa-455b-b883-f7aa7f5928ab",
      "name": "Run demo",
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        40,
        280
      ],
      "notes": "CLI and the n8n editor start here. An empty manual run loads the bundled sample.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "social-content-repurposing",
        "authentication": "none",
        "responseMode": "lastNode",
        "responseData": "firstEntryJson",
        "options": {}
      },
      "id": "c5f248fb-63eb-4b98-8d2c-5aea699b2d74",
      "name": "Inbound webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        40,
        460
      ],
      "notes": "POST JSON to this path. Include demo:false only after credentials are connected.",
      "notesInFlow": true,
      "webhookId": "9417bb2b-9b00-46d2-bd16-c3d4f9133e73"
    },
    {
      "parameters": {
        "feedUrl": "https://example.com/feed.xml"
      },
      "id": "d8792372-8148-4169-b354-3a625d24c2eb",
      "name": "RSS feed",
      "type": "n8n-nodes-base.rssFeedReadTrigger",
      "typeVersion": 1,
      "position": [
        40,
        640
      ],
      "notes": "Point the feed URL at the blog or YouTube RSS before activating.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const sample = {\n  \"demo\": true,\n  \"title\": \"What a 60-second lead response changes\",\n  \"url\": \"https://example.com/blog/speed-to-lead\",\n  \"body\": \"Teams that answer a new lead inside a minute book more meetings. The rest send a careful email tomorrow. A named owner matters as much as the speed.\",\n  \"transcript\": \"Teams that answer a new lead inside a minute book more meetings. The rest send a careful email tomorrow. A named owner matters as much as the speed.\"\n};\nconst incoming = $input.first()?.json ?? {};\nconst provided = Object.keys(incoming).filter((key) => incoming[key] !== undefined && incoming[key] !== null && incoming[key] !== '');\nconst base = provided.length ? { ...sample, ...incoming } : { ...sample };\nconst flag = incoming.demo;\nbase.demo = !(flag === false || flag === 'false' || flag === 0 || flag === '0');\nreturn [{ json: base }];\n"
      },
      "id": "b608eff8-b66a-489b-b556-53ed11df8aa5",
      "name": "Normalize input",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        340,
        360
      ],
      "notes": "Merges the request over the bundled sample. demo stays true unless the caller explicitly turns it off.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const item = $input.first().json;\nconst produced = (() => {\n\nconst title = String(item.title || 'Untitled').trim();\nconst source = String(item.transcript || item.body || item.summary || '').replace(/\\s+/g, ' ').trim();\nconst sentence = source.split(/(?<=\\.)\\s/)[0] || source.slice(0, 180);\nconst linkedin = sentence.slice(0, 420) + (sentence.length > 420 ? '\u2026' : '') + '\\n\\nFull piece: ' + (item.url || 'link in comments');\nconst x = (title + ' \u2014 ' + sentence).slice(0, 240);\nconst shorts = source.split(/(?<=\\.)\\s/).slice(0, 3).map((line, index) => (index + 1) + '. ' + line.trim());\nconst record = {\n  title,\n  url: item.url || '',\n  linkedin,\n  x,\n  carousel: shorts,\n  status: 'draft',\n};\nreturn {\n  summary: 'Drafted LinkedIn, X, and a 3-beat carousel from \"' + title + '\".',\n  route: 'draft',\n  record,\n  slackText: 'Social drafts ready for \"' + title + '\".',\n  actions: [\n    { app: 'LinkedIn', operation: 'draft', payload: { text: linkedin } },\n    { app: 'X', operation: 'draft', payload: { text: x } },\n  ],\n};\n\n})();\nif (!produced || typeof produced.summary !== 'string' || !produced.summary.trim()) {\n  throw new Error('Apply rules must return a summary string');\n}\nreturn [{\n  json: {\n    ...item,\n    ...produced,\n    demo: item.demo !== false,\n  },\n}];\n"
      },
      "id": "8d0a109c-5218-4214-9b08-c8d7ba7bc301",
      "name": "Apply rules",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        620,
        360
      ],
      "notes": "Deterministic stand-in for the model or enrichment API. Replace or precede this with a live model node when you turn demo mode off.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "13fb9498-8b10-468f-a234-d7a0fa649cd4",
              "leftValue": "={{ $json.demo }}",
              "rightValue": true,
              "operator": {
                "type": "boolean",
                "operation": "true",
                "singleValue": true
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "5760107f-43cf-4391-8a49-104d54077657",
      "name": "Demo mode?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        900,
        360
      ],
      "notes": "True: package the offline result. False: run the credentialed apps.",
      "notesInFlow": true
    },
    {
      "parameters": {
        "mode": "runOnceForAllItems",
        "language": "javaScript",
        "jsCode": "const item = $input.first().json;\nreturn [{\n  json: {\n    demo: true,\n    status: 'demo_ready',\n    workflow: 'social-content-repurposing',\n    summary: item.summary,\n    route: item.route ?? null,\n    record: item.record ?? {},\n    actions: item.actions ?? [],\n    slackText: item.slackText ?? item.summary,\n    notes: 'Demo mode did not call external apps. Send {\"demo\": false} after placeholder credentials are replaced.',\n  },\n}];\n"
      },
      "id": "c2fbe664-ddc4-4e3a-bc3c-8c523bf56163",
      "name": "Package demo result",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        1180,
        180
      ]
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "sheet",
        "operation": "append",
        "documentId": {
          "__rl": true,
          "mode": "id",
          "value": "YOUR_SPREADSHEET_ID"
        },
        "sheetName": {
          "__rl": true,
          "mode": "name",
          "value": "Social queue"
        },
        "columns": {
          "mappingMode": "autoMapInputData",
          "value": {},
          "matchingColumns": [],
          "schema": []
        },
        "options": {}
      },
      "id": "c346c912-35e1-46aa-aec8-8805aa90687c",
      "name": "Append Social queue",
      "type": "n8n-nodes-base.googleSheets",
      "typeVersion": 4.7,
      "position": [
        1180,
        760
      ],
      "credentials": {
        "googleSheetsOAuth2Api": {
          "id": "PLACEHOLDER_GOOGLESHEETSOAUTH2API",
          "name": "Google Sheets account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "standard",
        "resource": "post",
        "operation": "create",
        "postAs": "person",
        "person": "YOUR_LINKEDIN_PERSON_URN",
        "text": "={{ $json.record.linkedin || $json.summary }}"
      },
      "id": "fc6591f2-407b-4692-9596-0db94430d064",
      "name": "Create LinkedIn post",
      "type": "n8n-nodes-base.linkedIn",
      "typeVersion": 1,
      "position": [
        1460,
        760
      ],
      "credentials": {
        "linkedInOAuth2Api": {
          "id": "PLACEHOLDER_LINKEDINOAUTH2API",
          "name": "LinkedIn account"
        }
      }
    },
    {
      "parameters": {
        "resource": "tweet",
        "operation": "create",
        "text": "={{ $json.record.x || $json.summary }}"
      },
      "id": "e2029d07-22b9-4d77-a6ff-01bfa1fb9147",
      "name": "Create X post",
      "type": "n8n-nodes-base.twitter",
      "typeVersion": 2,
      "position": [
        1740,
        760
      ],
      "credentials": {
        "twitterOAuth2Api": {
          "id": "PLACEHOLDER_TWITTEROAUTH2API",
          "name": "X account"
        }
      }
    },
    {
      "parameters": {
        "authentication": "oAuth2",
        "resource": "message",
        "operation": "post",
        "select": "channel",
        "channelId": {
          "__rl": true,
          "mode": "name",
          "value": "#social"
        },
        "text": "={{ $json.slackText || $json.summary }}",
        "otherOptions": {}
      },
      "id": "a3e4f538-ef33-48dd-9c3e-52dbc88a4369",
      "name": "Post #social",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2.3,
      "position": [
        2020,
        760
      ],
      "credentials": {
        "slackOAuth2Api": {
          "id": "PLACEHOLDER_SLACKOAUTH2API",
          "name": "Slack account"
        }
      }
    },
    {
      "parameters": {
        "content": "## Live path\n\nReplace every `PLACEHOLDER_*` credential, then POST the sample with `\"demo\": false`.\n\nThe nodes on this branch use the `record` and `actions` fields produced by Apply rules.",
        "height": 180,
        "width": 420,
        "color": 6
      },
      "id": "3a0907bf-0148-48e0-adc2-fc25ea4920c0",
      "name": "Live path",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        1120,
        520
      ]
    }
  ],
  "connections": {
    "Run demo": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Inbound webhook": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RSS feed": {
      "main": [
        [
          {
            "node": "Normalize input",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Normalize input": {
      "main": [
        [
          {
            "node": "Apply rules",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Apply rules": {
      "main": [
        [
          {
            "node": "Demo mode?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Demo mode?": {
      "main": [
        [
          {
            "node": "Package demo result",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Append Social queue",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Append Social queue": {
      "main": [
        [
          {
            "node": "Create LinkedIn post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create LinkedIn post": {
      "main": [
        [
          {
            "node": "Create X post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create X post": {
      "main": [
        [
          {
            "node": "Post #social",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "pinData": {},
  "settings": {
    "executionOrder": "v1"
  },
  "staticData": null,
  "meta": {
    "templateCredsSetupCompleted": false,
    "description": "A long source is cut into a LinkedIn draft, a short X draft, and a three-beat carousel. The drafts are logged and posted to Slack for approval. Nothing publishes itself."
  },
  "active": false
}
