{
  "id": "lTO5ex53oKKkeT0d",
  "name": "Repurpose News from RSS Feed and Publish via PostPulse",
  "tags": [],
  "nodes": [
    {
      "id": "5225f3e9-d85f-4e3e-900a-e67fbc5ea7ac",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "position": [
        -48,
        -144
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "triggerAtHour": 9
            }
          ]
        }
      },
      "typeVersion": 1.2
    },
    {
      "id": "b72c3c2f-7b1d-4925-9dca-720f2353b793",
      "name": "If",
      "type": "n8n-nodes-base.if",
      "position": [
        720,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "bff36021-96e1-421e-9218-81e2117786b1",
              "operator": {
                "type": "dateTime",
                "operation": "afterOrEquals"
              },
              "leftValue": "={{ $json.pubDate }}",
              "rightValue": "={{ $now.minus(1, 'days').startOf('day') }}"
            },
            {
              "id": "8acc637f-1103-4c4f-a80e-428020b3cf41",
              "operator": {
                "type": "dateTime",
                "operation": "beforeOrEquals"
              },
              "leftValue": "={{ $json.pubDate }}",
              "rightValue": "={{ $now.minus(1, 'days').endOf('day') }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "3442e809-c9a9-45a0-9088-72a1810355b1",
      "name": "Get connected accounts",
      "type": "@postpulse/n8n-nodes-postpulse.postPulse",
      "position": [
        784,
        480
      ],
      "parameters": {
        "resource": "account"
      },
      "credentials": {
        "postPulseOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "2d2d2c5f-32b3-4b7a-8a49-a52e8ac9dea1",
      "name": "Media Check IF",
      "type": "n8n-nodes-base.if",
      "position": [
        912,
        0
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "media-check-condition",
              "operator": {
                "type": "string",
                "operation": "notEmpty"
              },
              "leftValue": "={{ (\n          $json.enclosure?.url ||\n          $json['media:content']?.url || \n          $json['media:thumbnail']?.url ||\n          ($json.description && $json.description.match(/<img[^>]+src=[\"']([^\"']+)[\"']/i)?.[1]) ||\n          ($json['content:encoded'] && $json['content:encoded'].match(/<img[^>]+src=[\"']([^\"']+)[\"']/i)?.[1])\n        ) }}"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "13391fd1-8164-4bc2-b5cd-438c507dffa5",
      "name": "RSS Feed Read",
      "type": "n8n-nodes-base.rssFeedRead",
      "position": [
        336,
        -64
      ],
      "parameters": {
        "url": "https://rss.unian.ua/site/gplay_56_ukr.rss",
        "options": {}
      },
      "typeVersion": 1
    },
    {
      "id": "eab7ec94-76a3-4840-a89e-f77f2e1991ef",
      "name": "Merge (no media + accounts)",
      "type": "n8n-nodes-base.merge",
      "position": [
        1152,
        224
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3.2
    },
    {
      "id": "6edb85e6-e42f-486c-8a51-035ea59dbe96",
      "name": "Upload media",
      "type": "@postpulse/n8n-nodes-postpulse.postPulse",
      "position": [
        1104,
        -176
      ],
      "parameters": {
        "url": "={{ $json.enclosure.url }}",
        "resource": "media",
        "filenameHint": "={{ $json.enclosure.url.split(\"/\").pop() }}",
        "uploadSource": "url"
      },
      "credentials": {
        "postPulseOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "13fd97d3-c730-4ad1-9311-58fe5f385c10",
      "name": "Get upload status",
      "type": "@postpulse/n8n-nodes-postpulse.postPulse",
      "position": [
        1312,
        -208
      ],
      "parameters": {
        "importId": "={{ $json.id }}",
        "resource": "media",
        "operation": "getUploadStatus"
      },
      "credentials": {
        "postPulseOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "3b3c7fdb-a992-43ac-8478-e42a7e6ec7d9",
      "name": "Merge1",
      "type": "n8n-nodes-base.merge",
      "position": [
        2160,
        -64
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "combineBy": "combineAll"
      },
      "typeVersion": 3.2
    },
    {
      "id": "1d049387-8e7b-4cc7-b32d-704f0aba5945",
      "name": "If1",
      "type": "n8n-nodes-base.if",
      "position": [
        1504,
        -304
      ],
      "parameters": {
        "options": {},
        "conditions": {
          "options": {
            "version": 2,
            "leftValue": "",
            "caseSensitive": true,
            "typeValidation": "strict"
          },
          "combinator": "and",
          "conditions": [
            {
              "id": "44cab27e-ad6e-4320-aea2-ca7e5ebbbf2f",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              },
              "leftValue": "={{ $json.state }}",
              "rightValue": "READY"
            }
          ]
        }
      },
      "typeVersion": 2.2
    },
    {
      "id": "804a3503-e23f-4a87-b811-bd552edf94ac",
      "name": "Wait",
      "type": "n8n-nodes-base.wait",
      "position": [
        1744,
        -304
      ],
      "parameters": {},
      "typeVersion": 1.1
    },
    {
      "id": "2c315149-3047-467e-bdb3-e62330aabe10",
      "name": "Publish Post",
      "type": "@postpulse/n8n-nodes-postpulse.postPulse",
      "position": [
        2400,
        -32
      ],
      "parameters": {
        "isDraft": true,
        "publications": {
          "publication": [
            {
              "posts": {
                "post": [
                  {
                    "content": "={{ (function(){\nconst t=$json['content:encodedSnippet'],p=$json.platform;\nlet m=500;if(p==='X_TWITTER')m=280;if(p==='BLUE_SKY')m=300;\nif(t.length<=m)return t;\nconst d=t.lastIndexOf('.',m),e=t.lastIndexOf('!',m),q=t.lastIndexOf('?',m),s=Math.max(d,e,q),l=m*0.6;\nif(s>0&&s>=l)return t.substring(0,s+1);\nconst w=t.lastIndexOf(' ',m);\nreturn t.substring(0,w>0?w:m)+'...';\n})() }}",
                    "attachmentPaths": {
                      "path": [
                        {
                          "value": "={{ $json.s3Key }}"
                        }
                      ]
                    }
                  }
                ]
              },
              "platformSettings": "={{ (function() { const platformMapping = { 'X_TWITTER': 'TWITTER', 'YOUTUBE': 'YOUTUBE', 'THREADS': 'THREADS', 'TIKTOK': 'TIK_TOK', 'INSTAGRAM': 'INSTAGRAM', 'FACEBOOK': 'FACEBOOK', 'LINKEDIN': 'LINKEDIN', 'BLUE_SKY': 'BLUE_SKY', 'TELEGRAM': 'TELEGRAM' }; return JSON.stringify({ \"type\": platformMapping[$json.platform] }); })() }}",
              "socialMediaAccountId": "={{ $json.id }}"
            }
          ]
        },
        "scheduledTime": "={{$now.toUTC()}}"
      },
      "credentials": {
        "postPulseOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "abde1db6-6283-472b-8fc6-9d0bd9cfb6eb",
      "name": "Merge",
      "type": "n8n-nodes-base.merge",
      "position": [
        1952,
        -160
      ],
      "parameters": {
        "mode": "combine",
        "options": {},
        "advanced": true,
        "mergeByFields": {
          "values": [
            {
              "field1": "sourceUrl",
              "field2": "enclosure.url"
            }
          ]
        }
      },
      "typeVersion": 3.2
    },
    {
      "id": "c05dd604-c4ee-485b-81f6-d38f67e515b0",
      "name": "Publish Post (text only)",
      "type": "@postpulse/n8n-nodes-postpulse.postPulse",
      "position": [
        1776,
        336
      ],
      "parameters": {
        "isDraft": true,
        "publications": {
          "publication": [
            {
              "posts": {
                "post": [
                  {
                    "content": "={{ (function(){\n  const title = $json.title || '';\n  const content = $json['content'] || $json['content:encodedSnippet'] || $json.description || '';\n  const fullText = title + (content ? '\\n\\n' + content : '');\n  const p = $json.platform;\n  let m = 500;\n  if(p==='X_TWITTER') m=280;\n  if(p==='BLUE_SKY') m=300;\n  if(fullText.length <= m) return fullText;\n  const d = fullText.lastIndexOf('.', m), e = fullText.lastIndexOf('!', m), q = fullText.lastIndexOf('?', m);\n  const s = Math.max(d, e, q), l = m*0.6;\n  if(s > 0 && s >= l) return fullText.substring(0, s+1);\n  const w = fullText.lastIndexOf(' ', m);\n  return fullText.substring(0, w>0?w:m) + '...';\n})() }}\n",
                    "attachmentPaths": {
                      "path": [
                        {}
                      ]
                    }
                  }
                ]
              },
              "platformSettings": "={{ (function() { const platformMapping = { 'X_TWITTER': 'TWITTER', 'YOUTUBE': 'YOUTUBE', 'THREADS': 'THREADS', 'TIKTOK': 'TIK_TOK', 'INSTAGRAM': 'INSTAGRAM', 'FACEBOOK': 'FACEBOOK', 'LINKEDIN': 'LINKEDIN', 'BLUE_SKY': 'BLUE_SKY', 'TELEGRAM': 'TELEGRAM' }; return JSON.stringify({ \"type\": platformMapping[$json.platform] }); })() }}",
              "socialMediaAccountId": "={{ $json.id }}"
            }
          ]
        },
        "scheduledTime": "={{$now.toUTC()}}"
      },
      "credentials": {
        "postPulseOAuth2Api": {
          "name": "<your credential>"
        }
      },
      "typeVersion": 1
    },
    {
      "id": "d20115e7-11a2-4af9-ab4f-a9c33ea44b99",
      "name": "Limit to N Post",
      "type": "n8n-nodes-base.function",
      "position": [
        512,
        -48
      ],
      "parameters": {
        "functionCode": "const limit = 1; // Specify the desired\nconst items = $input.all();\n\nreturn items.slice(0, limit);"
      },
      "typeVersion": 1
    },
    {
      "id": "7cf7be4d-1553-4f52-ac23-007a46e73eb8",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -128,
        -544
      ],
      "parameters": {
        "width": 640,
        "height": 144,
        "content": "## Repurpose News from RSS Feed and Publish via PostPulse\nThis workflow automatically fetches news from an RSS feed, processes the content, and publishes or schedules posts across multiple social media platforms using PostPulse.\n\n"
      },
      "typeVersion": 1
    },
    {
      "id": "8a2f34a4-7099-42c7-82cd-b8291f585e21",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        -112,
        16
      ],
      "parameters": {
        "width": 272,
        "height": 96,
        "content": "## Schedule Trigger\nSets the workflow to run at a chosen time, e.g., daily at 9:00 AM.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "402d5b7c-a30d-4bef-af05-74d48ef703d7",
      "name": "Sticky Note2",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        256,
        -208
      ],
      "parameters": {
        "height": 96,
        "content": "## RSS Feed Read\nFetches the latest news from a specified RSS feed URL.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "b02123b2-1751-4e7b-99c9-49dca6c2c653",
      "name": "Sticky Note3",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        416,
        80
      ],
      "parameters": {
        "width": 288,
        "height": 112,
        "content": "## Limit to N Post  \nLimits the number of items passed through. Set the desired number directly in the node code.  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "ef97a779-fb99-4d50-9e11-2968dad3e477",
      "name": "Sticky Note4",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        656,
        -208
      ],
      "parameters": {
        "width": 384,
        "content": "## If & Media Check IF  \nFilters posts based on publish date (e.g., only from yesterday) **AND** checks if they contain an image by looking at fields like `enclosure.url`, `media:content`, `media:thumbnail`, or `<img>` inside the HTML content.  \n"
      },
      "typeVersion": 1
    },
    {
      "id": "fefe03d9-f87b-43ca-8f17-c5c09fa347ad",
      "name": "Sticky Note5",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1216,
        -448
      ],
      "parameters": {
        "width": 544,
        "height": 112,
        "content": "## PostPulse Upload Media & Get Upload Status\nUploads images or videos from the feed to PostPulse, waits for the media to be ready, and checks the upload status every 5 seconds.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "1e1b08d4-96d7-4229-bdcf-0ac43f58f18c",
      "name": "Sticky Note6",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2064,
        -288
      ],
      "parameters": {
        "width": 336,
        "height": 128,
        "content": "## Merge\nCombines information from the RSS feed with the uploaded media, creating a single record with a shared URL.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "00692b40-ef2b-4aa8-9f2b-e69a097071d9",
      "name": "Sticky Note7",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        2144,
        224
      ],
      "parameters": {
        "width": 320,
        "height": 128,
        "content": "##  Publish Post\nSchedules the news post. If \"Is Draft\" is checked, the post is saved as a draft; if not, it is scheduled for immediate publishing.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "5ee6e715-62dc-4b82-993a-e35587d76d71",
      "name": "Sticky Note8",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        592,
        640
      ],
      "parameters": {
        "width": 352,
        "content": "## PostPulse Get Connected Accounts\nRetrieves your linked social media accounts for publishing posts.\n"
      },
      "typeVersion": 1
    },
    {
      "id": "10976fdd-1cc1-4739-bc62-2ab1cb1d71d0",
      "name": "Sticky Note9",
      "type": "n8n-nodes-base.stickyNote",
      "position": [
        1216,
        48
      ],
      "parameters": {
        "width": 256,
        "content": "## Merge (no media + accounts)  \nMerges posts without media with accounts data.  \n"
      },
      "typeVersion": 1
    }
  ],
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "018ef9cd-662d-4a33-8efd-f090b888f812",
  "connections": {
    "If": {
      "main": [
        [
          {
            "node": "Media Check IF",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Media Check IF",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "If1": {
      "main": [
        [
          {
            "node": "Wait",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "Merge",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Wait": {
      "main": [
        [
          {
            "node": "Get upload status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge": {
      "main": [
        [
          {
            "node": "Merge1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Merge1": {
      "main": [
        [
          {
            "node": "Publish Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Upload media": {
      "main": [
        [
          {
            "node": "Get upload status",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "RSS Feed Read": {
      "main": [
        [
          {
            "node": "Limit to N Post",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Media Check IF": {
      "main": [
        [
          {
            "node": "Upload media",
            "type": "main",
            "index": 0
          },
          {
            "node": "Merge",
            "type": "main",
            "index": 1
          }
        ],
        [
          {
            "node": "Merge (no media + accounts)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Limit to N Post": {
      "main": [
        [
          {
            "node": "If",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Get connected accounts",
            "type": "main",
            "index": 0
          },
          {
            "node": "RSS Feed Read",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get upload status": {
      "main": [
        [
          {
            "node": "If1",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Get connected accounts": {
      "main": [
        [
          {
            "node": "Merge (no media + accounts)",
            "type": "main",
            "index": 1
          },
          {
            "node": "Merge1",
            "type": "main",
            "index": 1
          }
        ]
      ]
    },
    "Merge (no media + accounts)": {
      "main": [
        [
          {
            "node": "Publish Post (text only)",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  }
}