{
  "id": "linkedin-ecommerce-news-publisher",
  "meta": {
    "templateCredsSetupCompleted": false
  },
  "name": "LinkedIn News Publisher - E-commerce Market",
  "tags": [],
  "nodes": [
    {
      "id": "sticky-overview-01",
      "name": "Sticky Note - Overview",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -220,
        -140
      ],
      "parameters": {
        "color": 4,
        "width": 420,
        "height": 320,
        "content": "## \ud83d\udccc Workflow Overview\nFetches the latest \"E-commerce Market\" news from Google News RSS every day at 9 AM, formats it into a LinkedIn post, and publishes it automatically.\n\n**Flow:**\nTrigger \u2192 Fetch RSS \u2192 Sort newest \u2192 Keep top 1 \u2192 Filter empty \u2192 Format text \u2192 Post to LinkedIn\n\n\u26a0\ufe0f Before activating, complete the 2 setup steps in the yellow note below (LinkedIn credentials + Person URN)."
      },
      "typeVersion": 1
    },
    {
      "id": "sticky-setup-01",
      "name": "Sticky Note - Setup",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        900,
        -140
      ],
      "parameters": {
        "color": 5,
        "width": 340,
        "height": 300,
        "content": "## \u2699\ufe0f Setup Required\n1. **Post to LinkedIn** node \u2192 open Credentials \u2192 create/select a LinkedIn OAuth2 credential (replace `REPLACE_WITH_YOUR_CREDENTIAL_ID`).\n2. Replace `YOUR_LINKEDIN_PERSON_URN_HERE` in the same node with your actual LinkedIn Person URN (format: `urn:li:person:xxxxxxxx`), found via LinkedIn's `/v2/me` API call or your developer app.\n3. Toggle the workflow **Active** once both are set."
      },
      "typeVersion": 1
    },
    {
      "id": "schedule-trigger-01",
      "name": "Daily Trigger (9 AM)",
      "type": "n8n-nodes-base.scheduleTrigger",
      "notes": "Runs once per day at 9:00 AM (server timezone). Change 'triggerAtHour' or add more interval entries to adjust frequency.",
      "position": [
        -220,
        260
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "days",
              "daysInterval": 1,
              "triggerAtHour": 9
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 1.2
    },
    {
      "id": "rss-read-01",
      "name": "Google News RSS - E-commerce Market",
      "type": "n8n-nodes-base.rssFeedRead",
      "notes": "Pulls all current results for the search term \"E-commerce Market\" from Google News RSS. Edit the 'q=' query param to change topic/keyword.",
      "position": [
        0,
        260
      ],
      "parameters": {
        "url": "https://news.google.com/rss/search?q=%22E-commerce+Market%22&hl=en-US&gl=US&ceid=US:en"
      },
      "notesInFlow": true,
      "typeVersion": 1.1
    },
    {
      "id": "sort-01",
      "name": "Sort by Newest",
      "type": "n8n-nodes-base.sort",
      "notes": "Orders RSS items by publish date (isoDate), newest first, so the freshest article is picked next.",
      "position": [
        220,
        260
      ],
      "parameters": {
        "sortFieldsUi": {
          "sortField": [
            {
              "order": "descending",
              "fieldName": "isoDate"
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "limit-01",
      "name": "Keep Top Article",
      "type": "n8n-nodes-base.limit",
      "notes": "Keeps only the single most recent article. Increase maxItems if you want to post multiple articles per run (requires downstream changes).",
      "position": [
        440,
        260
      ],
      "parameters": {
        "maxItems": 1
      },
      "notesInFlow": true,
      "typeVersion": 1
    },
    {
      "id": "filter-01",
      "name": "Filter Valid Items",
      "type": "n8n-nodes-base.filter",
      "notes": "Safety check: stops the workflow here (no LinkedIn post) if the RSS feed returned no title, e.g. empty/broken feed response.",
      "position": [
        660,
        260
      ],
      "parameters": {
        "conditions": {
          "options": {
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "loose"
          },
          "combinator": "and",
          "conditions": [
            {
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ $json.title }}",
              "rightValue": ""
            }
          ]
        }
      },
      "notesInFlow": true,
      "typeVersion": 2.2
    },
    {
      "id": "code-format-01",
      "name": "Format LinkedIn Post",
      "type": "n8n-nodes-base.code",
      "notes": "Builds the post text: strips ' - Source' suffix from title, extracts source name, appends link + fixed hashtag set. Edit 'hashtags' or the template string to change style.",
      "position": [
        880,
        260
      ],
      "parameters": {
        "jsCode": "// Build a LinkedIn-ready post from the Google News RSS item\nconst item = $input.first().json;\n\nconst title = (item.title || '').split(' - ')[0].trim();\nconst link = item.link || '';\nconst sourceMatch = (item.title || '').match(/-\\s*([^-]+)$/);\nconst source = sourceMatch ? sourceMatch[1].trim() : (item.creator || 'Google News');\n\nconst hashtags = '#Ecommerce #EcommerceMarket #RetailTech #OnlineShopping #MarketTrends';\n\nconst postText = `\ud83d\udcca E-commerce Market Update\\n\\n${title}\\n\\nSource: ${source}\\nRead more: ${link}\\n\\n${hashtags}`;\n\nreturn [{\n  json: {\n    postText,\n    title,\n    link,\n    source,\n    publishedAt: item.isoDate || item.pubDate || ''\n  }\n}];"
      },
      "notesInFlow": true,
      "typeVersion": 2
    },
    {
      "id": "linkedin-post-01",
      "name": "Post to LinkedIn",
      "type": "n8n-nodes-base.linkedIn",
      "notes": "\u26a0\ufe0f REQUIRES SETUP: set the LinkedIn OAuth2 credential AND replace 'YOUR_LINKEDIN_PERSON_URN_HERE' with your real Person URN before activating. Posts as a personal profile (shareMediaCategory: NONE = text-only, no image/article preview attached).",
      "position": [
        1100,
        260
      ],
      "parameters": {
        "text": "={{ $json.postText }}",
        "person": "YOUR_LINKEDIN_PERSON_URN_HERE",
        "postAs": "person",
        "resource": "post",
        "operation": "create",
        "shareMediaCategory": "NONE"
      },
      "credentials": {
        "linkedInOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "notesInFlow": true,
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "",
  "connections": {
    "Sort by Newest": {
      "main": [
        [
          {
            "node": "Keep Top Article",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep Top Article": {
      "main": [
        [
          {
            "node": "Filter Valid Items",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Valid Items": {
      "main": [
        [
          {
            "node": "Format LinkedIn Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Daily Trigger (9 AM)": {
      "main": [
        [
          {
            "node": "Google News RSS - E-commerce Market",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Format LinkedIn Post": {
      "main": [
        [
          {
            "node": "Post to LinkedIn",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Google News RSS - E-commerce Market": {
      "main": [
        [
          {
            "node": "Sort by Newest",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}