{
  "name": "Praxica Omni-Channel Content Factory",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "content-factory",
        "options": {}
      },
      "id": "1",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 1,
      "position": [400, 400]
    },
    {
      "parameters": {
        "conditions": {
          "string": [
            {
              "value1": "={{ $json[\"body\"][\"url\"] }}",
              "operation": "contains",
              "value2": "youtube.com"
            }
          ]
        }
      },
      "id": "2",
      "name": "Is YouTube?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [600, 400]
    },
    {
      "parameters": {
        "url": "={{ $node[\"Webhook Trigger\"].json[\"body\"][\"url\"] }}",
        "options": {}
      },
      "id": "3",
      "name": "Fetch Blog HTML",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [800, 500]
    },
    {
      "parameters": {
        "operation": "extractHtmlContent",
        "sourceData": "json",
        "extractionValues": {
          "values": [
            {
              "key": "article",
              "cssSelector": "article",
              "returnValue": "html"
            }
          ]
        }
      },
      "id": "4",
      "name": "Extract Content",
      "type": "n8n-nodes-base.html",
      "typeVersion": 1,
      "position": [1000, 500]
    },
    {
      "parameters": {
        "text": "={{ $json[\"article\"] }}",
        "options": {}
      },
      "id": "5",
      "name": "HTML to Markdown",
      "type": "n8n-nodes-base.markdown",
      "typeVersion": 1,
      "position": [1200, 500]
    },
    {
      "parameters": {
        "resource": "video",
        "id": "={{ $node[\"Webhook Trigger\"].json[\"body\"][\"url\"].split('v=')[1] }}",
        "options": {}
      },
      "id": "6",
      "name": "Get YT Transcript",
      "type": "n8n-nodes-base.youtube",
      "typeVersion": 1,
      "position": [800, 300]
    },
    {
      "parameters": {
        "promptType": "define",
        "text": "Analyze this content: {{ $json[\"text\"] || $node[\"HTML to Markdown\"].json[\"markdown\"] }}. \n\nExtract 3 viral hooks and rewrite them for:\n1. A 5-part X Thread (Punchy, short).\n2. A LinkedIn Post (Professional, storytelling).\n3. A Newsletter Draft (Insightful summary).",
        "options": {
          "systemMessage": "You are an elite content strategist for founders."
        }
      },
      "id": "7",
      "name": "AI Content Strategist",
      "type": "@n8n/n8n-nodes-langchain.agent",
      "typeVersion": 1,
      "position": [1450, 400]
    },
    {
      "parameters": {
        "jsCode": "const text = $input.first().json.output;\nconst chunks = text.split(/\\s+/);\nlet current = \"\";\nlet results = [];\n\nchunks.forEach(word => {\n  if ((current + word).length > 240) {\n    results.push(current.trim());\n    current = word + \" \";\n  } else {\n    current += word + \" \";\n  }\n});\nresults.push(current.trim());\n\nreturn results.map((t, i) => ({ json: { tweet: t + ` (${i+1}/${results.length})` } }));"
      },
      "id": "8",
      "name": "X Thread Formatter",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [1700, 300]
    },
    {
      "parameters": {
        "resource": "databasePage",
        "databaseId": "your_notion_db_id",
        "propertiesUI": {
          "propertyValues": [
            {
              "key": "Content",
              "type": "rich_text",
              "richTextValue": "={{ $json[\"tweet\"] || $node[\"AI Content Strategist\"].json[\"output\"] }}"
            },
            {
              "key": "Platform",
              "type": "select",
              "selectValue": "={{ $node[\"X Thread Formatter\"].name ? 'X' : 'LinkedIn' }}"
            }
          ]
        }
      },
      "id": "9",
      "name": "Save to Notion",
      "type": "n8n-nodes-base.notion",
      "typeVersion": 2,
      "position": [1950, 400]
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Is YouTube?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Is YouTube?": {
      "main": [
        [
          {
            "node": "Get YT Transcript",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Fetch Blog HTML",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Blog HTML": {
      "main": [
        [
          {
            "node": "Extract Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Content": {
      "main": [
        [
          {
            "node": "HTML to Markdown",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "HTML to Markdown": {
      "main": [
        [
          {
            "node": "AI Content Strategist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get YT Transcript": {
      "main": [
        [
          {
            "node": "AI Content Strategist",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "AI Content Strategist": {
      "main": [
        [
          {
            "node": "X Thread Formatter",
            "type": "main",
            "index": 0
          },
          {
            "node": "Save to Notion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "X Thread Formatter": {
      "main": [
        [
          {
            "node": "Save to Notion",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}
