{
  "id": "rss-blog-enh-02",
  "meta": {
    "instanceId": "vorlux-hub"
  },
  "name": "Vorlux AI | RSS to Blog Enhanced (Bilingual EN+ES)",
  "active": true,
  "nodes": [
    {
      "id": "b2c3d4e5-0002-4bbb-8002-000000000001",
      "name": "Webhook Trigger",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [220, 300],
      "parameters": {
        "path": "rss-to-blog",
        "httpMethod": "POST",
        "responseMode": "onReceived",
        "options": {}
      }
    },
    {
      "id": "b2c3d4e5-0002-4bbb-8002-000000000002",
      "name": "Fetch Article Content",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [460, 300],
      "parameters": {
        "method": "GET",
        "url": "={{ $json.body.url || $json.body.link }}",
        "options": {
          "timeout": 20000,
          "response": {
            "response": {
              "fullResponse": true
            }
          }
        }
      },
      "notes": "Fetches the full article HTML from the original URL"
    },
    {
      "id": "b2c3d4e5-0002-4bbb-8002-000000000003",
      "name": "Extract Clean Content",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [700, 300],
      "notes": "Strips HTML tags, extracts main article text, cleans whitespace",
      "parameters": {
        "mode": "runOnceForAllItems",
        "jsCode": "const input = $input.first().json;\nconst html = input.body || input.data || '';\nconst originalTitle = $('Webhook Trigger').first().json.body.title || '';\nconst sourceUrl = $('Webhook Trigger').first().json.body.url || '';\nconst sourceName = $('Webhook Trigger').first().json.body.source || 'RSS';\n\n// Strip HTML to get clean text\nlet text = html\n  .replace(/<script[\\s\\S]*?<\\/script>/gi, '')\n  .replace(/<style[\\s\\S]*?<\\/style>/gi, '')\n  .replace(/<nav[\\s\\S]*?<\\/nav>/gi, '')\n  .replace(/<footer[\\s\\S]*?<\\/footer>/gi, '')\n  .replace(/<header[\\s\\S]*?<\\/header>/gi, '')\n  .replace(/<[^>]+>/g, ' ')\n  .replace(/&nbsp;/g, ' ')\n  .replace(/&amp;/g, '&')\n  .replace(/&lt;/g, '<')\n  .replace(/&gt;/g, '>')\n  .replace(/\\s+/g, ' ')\n  .trim();\n\n// Take most relevant portion (skip very short or empty)\nif (text.length < 200) text = originalTitle + '. ' + ($('Webhook Trigger').first().json.body.description || '');\n\nreturn [{ json: { cleanText: text.substring(0, 8000), originalTitle, sourceUrl, sourceName, wordCount: text.split(/\\s+/).length } }];"
      }
    },
    {
      "id": "b2c3d4e5-0002-4bbb-8002-000000000004",
      "name": "Rewrite as Blog Post (EN)",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [940, 200],
      "notes": "Uses Ollama to rewrite the article as an original English blog post",
      "parameters": {
        "method": "POST",
        "url": "={{$env.OLLAMA_BASE_URL || 'http://localhost:11434'}}/api/generate",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ model: 'qwen2.5:7b', prompt: 'You are Vorlux AI HUB\\'s content writer. Rewrite this article as a NEW, ORIGINAL blog post for Vorlux AI HUB. Keep the core insights but: use our brand voice (tech-savvy, approachable, enthusiastic about AI/streaming/community), add unique perspective, make it 1200-2000 words. Title should be original.\\n\\nOriginal title: ' + $json.originalTitle + '\\n\\nOriginal content:\\n' + $json.cleanText.substring(0, 6000) + '\\n\\nWrite the blog post in English. Format: Start with ## Title, then the post body with proper paragraphs.', stream: false, options: { temperature: 0.7 } }) }}",
        "options": {
          "timeout": 120000
        }
      }
    },
    {
      "id": "b2c3d4e5-0002-4bbb-8002-000000000005",
      "name": "Translate to Spanish",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [940, 450],
      "notes": "Generates Spanish version of the blog post via Ollama",
      "parameters": {
        "method": "POST",
        "url": "={{$env.OLLAMA_BASE_URL || 'http://localhost:11434'}}/api/generate",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ model: 'qwen2.5:7b', prompt: 'Translate the following blog post to Spanish. Keep the same formatting, tone, and structure. Maintain technical terms in English where appropriate (e.g., AI, streaming, API).\\n\\n' + ($json.response || '').substring(0, 6000), stream: false, options: { temperature: 0.3 } }) }}",
        "options": {
          "timeout": 120000
        }
      }
    },
    {
      "id": "b2c3d4e5-0002-4bbb-8002-000000000006",
      "name": "Create Blog Post",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1200, 200],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/blog",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ title: ($json.response || '').match(/^##\\s*(.+)/m)?.[1] || 'Blog: ' + $('Extract Clean Content').first().json.originalTitle, content: $json.response || '', content_es: $('Translate to Spanish').first().json.response || '', source: 'rss_enhanced', source_url: $('Extract Clean Content').first().json.sourceUrl, source_name: $('Extract Clean Content').first().json.sourceName, status: 'draft', bilingual: true }) }}",
        "options": {
          "timeout": 15000
        }
      }
    },
    {
      "id": "b2c3d4e5-0002-4bbb-8002-000000000007",
      "name": "Enrich with SEO",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1440, 200],
      "parameters": {
        "method": "POST",
        "url": "={{$env.VORLUX_HUB_URL}}/api/content/pipeline?action=enrich",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ postId: ($json.data || {}).id, enrichments: ['seo', 'tags', 'summary', 'social_preview'] }) }}",
        "options": {
          "timeout": 30000
        }
      }
    },
    {
      "id": "b2c3d4e5-0002-4bbb-8002-000000000008",
      "name": "Discord Notify",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [1440, 400],
      "parameters": {
        "method": "POST",
        "url": "={{$env.DISCORD_CONTENT_WEBHOOK}}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={\"embeds\":[{\"title\":\"Blog Created from RSS\",\"description\":\"Source: {{ $('Extract Clean Content').first().json.sourceName }}\\nOriginal: {{ $('Extract Clean Content').first().json.originalTitle }}\\nBilingual: EN + ES\",\"color\":3066993,\"footer\":{\"text\":\"RSS to Blog Enhanced Pipeline\"}}]}",
        "options": {
          "timeout": 10000
        }
      }
    }
  ],
  "connections": {
    "Webhook Trigger": {
      "main": [
        [
          {
            "node": "Fetch Article Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Article Content": {
      "main": [
        [
          {
            "node": "Extract Clean Content",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Extract Clean Content": {
      "main": [
        [
          {
            "node": "Rewrite as Blog Post (EN)",
            "type": "main",
            "index": 0
          },
          {
            "node": "Translate to Spanish",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Rewrite as Blog Post (EN)": {
      "main": [
        [
          {
            "node": "Create Blog Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Create Blog Post": {
      "main": [
        [
          {
            "node": "Enrich with SEO",
            "type": "main",
            "index": 0
          },
          {
            "node": "Discord Notify",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1",
    "saveManualExecutions": true,
    "saveExecutionProgress": true
  },
  "tags": [
    { "name": "rss" },
    { "name": "blog" },
    { "name": "content" },
    { "name": "bilingual" }
  ],
  "versionId": "2"
}