{"name":"RSS feed to Bluesky with PubNio (approve each item in a data table)","nodes":[{"parameters":{"pollTimes":{"item":[{"mode":"everyHour"}]},"feedUrl":""},"id":"7cff9af3-c56a-40fc-a893-655d03b35c3f","name":"New feed item","type":"n8n-nodes-base.rssFeedReadTrigger","typeVersion":1,"position":[0,0]},{"parameters":{"mode":"runOnceForEachItem","jsCode":"// The item's guid (or link) is the stable row ID, so a feed that repeats\n// an item cannot queue it twice.\nreturn { json: {\n  source_id: String($json.guid || $json.link),\n  text: String($json.title || '').trim() + '\\n' + $json.link,\n  detail: String($json.contentSnippet || '').slice(0, 500),\n} };"},"id":"bcf0f91b-758f-442a-aabd-c0adbcf66c1a","name":"Compose post","type":"n8n-nodes-base.code","typeVersion":2,"position":[220,0]},{"parameters":{"operation":"rowNotExists","dataTableId":{"__rl":true,"value":"pubnio_feed_items","mode":"name"},"filters":{"conditions":[{"keyName":"source_id","keyValue":"={{ $json.source_id }}"}]}},"id":"5b132960-bdea-44bb-a192-cfe9fa341814","name":"Skip items already queued","type":"n8n-nodes-base.dataTable","typeVersion":1.1,"position":[440,0]},{"parameters":{"operation":"insert","dataTableId":{"__rl":true,"value":"pubnio_feed_items","mode":"name"},"columns":{"mappingMode":"defineBelow","value":{"source_id":"={{ $json.source_id }}","text":"={{ $json.text }}","detail":"={{ $json.detail }}","approved":"={{ false }}"},"matchingColumns":[]},"options":{}},"id":"e8d086a3-8d91-408f-a85a-a854baa955d4","name":"Queue for approval","type":"n8n-nodes-base.dataTable","typeVersion":1.1,"position":[660,0]},{"parameters":{"rule":{"interval":[{"field":"minutes","minutesInterval":15}]}},"id":"0cf16139-efc1-42cb-ab14-d3f3d016e84d","name":"Every 15 minutes","type":"n8n-nodes-base.scheduleTrigger","typeVersion":1.2,"position":[0,400]},{"parameters":{"assignments":{"assignments":[{"id":"fc103aac-fcc5-47f6-aadf-40fb490e028e","name":"baseUrl","value":"https://pubnio.com","type":"string"},{"id":"2c19095b-2edd-4e31-a1cc-420729b49e01","name":"workspaceId","value":"","type":"string"}]},"options":{}},"id":"99d67041-858d-4f30-abcd-7259c3cd906e","name":"PubNio settings","type":"n8n-nodes-base.set","typeVersion":3.4,"position":[220,400]},{"parameters":{"operation":"get","dataTableId":{"__rl":true,"value":"pubnio_feed_items","mode":"name"},"filters":{"conditions":[{"keyName":"approved","condition":"isTrue"}]},"returnAll":true},"id":"dd0e38e4-a999-480f-ab96-16c1ace24bbb","name":"Read approved rows","type":"n8n-nodes-base.dataTable","typeVersion":1.1,"position":[440,400]},{"parameters":{"mode":"runOnceForEachItem","jsCode":"// One approved data table row becomes one post.\nconst s = $('PubNio settings').first().json;\nconst text = (value) => String(value ?? '').trim();\nconst row = {\n  rowId: text($json.source_id),\n  approved: $json.approved === true,\n  key: text($json.pubnio_key),\n  postId: text($json.pubnio_post_id),\n  status: text($json.pubnio_status),\n  sentAt: text($json.pubnio_sent_at),\n  outcome: text($json.pubnio_outcome),\n};\nconst body = { text: text($json.text), platforms: ['bluesky'] };\nreturn { json: { ...row, body } };"},"id":"ccff86ee-3893-42c8-aea1-a599dc59b03f","name":"Normalize row","type":"n8n-nodes-base.code","typeVersion":2,"position":[660,400]},{"parameters":{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"loose","version":2},"conditions":[{"id":"1313aacf-8481-4e26-a5a4-8130c0a2a85b","leftValue":"={{ $json.approved }}","rightValue":"","operator":{"type":"boolean","operation":"true","singleValue":true}},{"id":"25b4ec5b-df83-4fd3-a7a6-62d7f515c722","leftValue":"={{ $json.rowId }}","rightValue":"","operator":{"type":"string","operation":"notEmpty","singleValue":true}}],"combinator":"and"},"looseTypeValidation":true,"options":{}},"id":"8c45f6fe-a9df-4dbb-a4d3-26d817042d30","name":"Approved?","type":"n8n-nodes-base.if","typeVersion":2.2,"position":[880,400]},{"parameters":{},"id":"3d0a487e-c823-462d-aa97-77791e554283","name":"Not approved: skip","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[1100,700]},{"parameters":{"mode":"runOnceForEachItem","jsCode":"// Decide what one approved row needs. The idempotency key is a hash of the\n// row ID, saved on the row before the first request, so a rerun after a\n// timeout sends the same key and PubNio replays its first answer.\nconst hash = (value) => {\n  let h1 = 1779033703, h2 = 3144134277, h3 = 1013904242, h4 = 2773480762;\n  for (let i = 0; i < value.length; i++) {\n    const k = value.charCodeAt(i);\n    h1 = h2 ^ Math.imul(h1 ^ k, 597399067);\n    h2 = h3 ^ Math.imul(h2 ^ k, 2869860233);\n    h3 = h4 ^ Math.imul(h3 ^ k, 951274213);\n    h4 = h1 ^ Math.imul(h4 ^ k, 2716044179);\n  }\n  h1 = Math.imul(h3 ^ (h1 >>> 18), 597399067);\n  h2 = Math.imul(h4 ^ (h2 >>> 22), 2869860233);\n  h3 = Math.imul(h1 ^ (h3 >>> 17), 951274213);\n  h4 = Math.imul(h2 ^ (h4 >>> 19), 2716044179);\n  h1 ^= h2 ^ h3 ^ h4; h2 ^= h1; h3 ^= h1; h4 ^= h1;\n  return [h1, h2, h3, h4].map((h) => (h >>> 0).toString(16).padStart(8, '0')).join('');\n};\nconst row = $json;\nconst replayWindowMs = 23 * 60 * 60 * 1000; // PubNio replays a key for 24 hours.\nconst finished = ['published', 'provider_draft', 'failed', 'cancelled', 'rejected', 'needs_review'];\nconst fresh = !row.key;\nconst key = row.key || 'n8n-' + $workflow.id + '-' + hash(String(row.rowId));\nconst sentAt = fresh ? new Date().toISOString() : row.sentAt;\n// One media import per row and URL; a resend after a rejection gets a new sentAt, so a new import.\nconst mediaKey = row.mediaUrl ? key + '-m' + hash(row.mediaUrl + '|' + sentAt).slice(0, 16) : '';\nlet action = 'submit';\nif (row.postId) action = finished.includes(row.status) ? 'done' : 'sync';\nelse if (finished.includes(row.status)) action = 'done';\n// A saved key without a readable send time fails closed: it may be older than the replay window.\nelse if (!fresh && !(Date.now() - Date.parse(row.sentAt) <= replayWindowMs)) action = 'stale';\nelse if (fresh && row.problem) action = 'invalid';\nreturn { json: { ...row, key, sentAt, mediaKey, fresh, action } };"},"id":"a4e928de-68f8-40ac-ab6b-87155a7f55ef","name":"Plan action","type":"n8n-nodes-base.code","typeVersion":2,"position":[1100,300]},{"parameters":{"rules":{"values":[{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict","version":2},"conditions":[{"id":"96e3023d-7935-431b-adae-4ebc95454da2","leftValue":"={{ $json.action }}","rightValue":"submit","operator":{"type":"string","operation":"equals"}}],"combinator":"and"},"renameOutput":true,"outputKey":"submit"},{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict","version":2},"conditions":[{"id":"b94eb76c-d89a-49ba-a464-94633a295b6c","leftValue":"={{ $json.action }}","rightValue":"sync","operator":{"type":"string","operation":"equals"}}],"combinator":"and"},"renameOutput":true,"outputKey":"sync"},{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict","version":2},"conditions":[{"id":"236c481c-fc79-4bc3-a673-5b9d79dde76c","leftValue":"={{ $json.action }}","rightValue":"stale","operator":{"type":"string","operation":"equals"}}],"combinator":"and"},"renameOutput":true,"outputKey":"stale"},{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict","version":2},"conditions":[{"id":"934647eb-7e72-435d-aaee-cacde12a90b8","leftValue":"={{ $json.action }}","rightValue":"invalid","operator":{"type":"string","operation":"equals"}}],"combinator":"and"},"renameOutput":true,"outputKey":"invalid"},{"conditions":{"options":{"caseSensitive":true,"leftValue":"","typeValidation":"strict","version":2},"conditions":[{"id":"93edca4a-68c6-4ba0-af9c-a86b84407fd3","leftValue":"={{ $json.action }}","rightValue":"done","operator":{"type":"string","operation":"equals"}}],"combinator":"and"},"renameOutput":true,"outputKey":"done"}]},"options":{}},"id":"a86800e6-a69a-46c9-aa80-8f825823b07d","name":"Route by action","type":"n8n-nodes-base.switch","typeVersion":3.2,"position":[1320,300]},{"parameters":{"mode":"runOnceForEachItem","jsCode":"// Map PubNio's answer onto the row. A 202 only means PubNio accepted the\n// work; the row says published only when a delivery reports it.\nconst plan = $('Plan action').item.json;\nconst res = $input.item.json;\nconst body = res.body && typeof res.body === 'object' ? res.body : {};\nconst code = Number(res.statusCode);\nconst reject = (out) => Object.assign(out, { status: 'rejected', key: '', sentAt: '' });\nconst active = ['submitting', 'confirming', 'queued', 'scheduled'];\nconst settled = ['unresolved', 'failed', 'published', 'provider_draft', 'cancelled'];\nconst pick = (states) => active.find((s) => states.includes(s)) || settled.find((s) => states.includes(s)) || 'queued';\nconst line = (t) => [\n  t.provider + ' ' + t.placement + ': ' + t.status,\n  t.status === 'scheduled' && t.scheduledAt ? 'at ' + t.scheduledAt : '',\n  t.localDate ? '(queue slot ' + t.localDate + ' ' + t.localTime + ' ' + t.timezone + ')' : '',\n  t.url || '',\n  t.issue ? '[' + t.issue + ']' : '',\n  t.nextAction ? 'Next: ' + t.nextAction : '',\n].filter(Boolean).join(' ');\nconst out = {\n  rowId: plan.rowId,\n  key: plan.key,\n  sentAt: plan.sentAt,\n  postId: plan.postId || '',\n  status: plan.status || '',\n  outcome: plan.outcome || '',\n  error: '',\n  revision: plan.draftRevision || '',\n  media: plan.sentMedia || '',\n  retryFailed: plan.retryFailed,\n};\nif (code >= 200 && code < 300) {\n  const targets = body.deliveries || body.targets || [];\n  out.postId = body.postId || out.postId;\n  out.status = body.status || pick(targets.map((t) => t.status));\n  out.outcome = targets.map(line).join('\\n');\n  if (body.revision) out.revision = body.revision;\n  if (plan.mediaUrl !== undefined) out.media = plan.mediaUrl;\n  return { json: out };\n}\nconst problem = body.code || String(body.type || '').split('/').filter(Boolean).pop() || 'http_' + code;\nout.error = [\n  code + ' ' + problem + (body.title ? ': ' + body.title : ''),\n  ...(body.issues || body.errors || []).map((i) => (i.code || 'invalid') + ' at ' + (i.path || []).join('.') + ': ' + i.message),\n  body.currentRevision ? 'The draft is now revision ' + body.currentRevision + '.' : '',\n  body.nextAction ? 'Next: ' + body.nextAction : '',\n].filter(Boolean).join('\\n');\n// A read or a draft step failed: keep the post and its last known state.\nif (plan.postId) out.status = code === 404 ? 'needs_review' : plan.status;\n// The key was used for another body, or the same text and media already went to\n// this account in the last 24 hours: resending cannot help, so a person decides.\nelse if (problem === 'idempotency_conflict' || problem === 'duplicate_content') out.status = 'needs_review';\n// In progress, rate limited, or a server error: the outcome is unknown, so the\n// next run resends the same key and PubNio replays the first answer.\nelse if (code === 409 || code === 429 || code >= 500) out.status = 'sending';\n// PubNio refused the request and stored nothing. Fix the row, then clear\n// pubnio_status to send it again.\nelse reject(out);\nreturn { json: out };"},"id":"4116cf22-a1c0-4207-a64f-573fdd9b81bb","name":"Record PubNio answer","type":"n8n-nodes-base.code","typeVersion":2,"position":[3300,200]},{"parameters":{"mode":"runOnceForEachItem","jsCode":"// The request got no answer (timeout or network). PubNio may have accepted\n// it, so keep the key: the next run resends it and PubNio replays.\nconst plan = $('Plan action').item.json;\nconst error = $json.error || {};\nconst out = {\n  rowId: plan.rowId,\n  key: plan.key,\n  sentAt: plan.sentAt,\n  postId: plan.postId || '',\n  status: plan.postId ? plan.status : 'sending',\n  outcome: plan.outcome || '',\n  error: '',\n  revision: plan.draftRevision || '',\n  media: plan.sentMedia || '',\n  retryFailed: plan.retryFailed,\n};\nout.error = 'No answer from PubNio: ' + (error.message || error.description || 'request failed');\nreturn { json: out };"},"id":"144c7686-5e25-4fcb-ab93-cec592099b51","name":"Record missing answer","type":"n8n-nodes-base.code","typeVersion":2,"position":[3300,400]},{"parameters":{"operation":"update","dataTableId":{"__rl":true,"value":"pubnio_feed_items","mode":"name"},"filters":{"conditions":[{"keyName":"source_id","condition":"eq","keyValue":"={{ $json.rowId }}"}]},"columns":{"mappingMode":"defineBelow","value":{"pubnio_key":"={{ $json.key }}","pubnio_post_id":"={{ $json.postId }}","pubnio_status":"={{ $json.status }}","pubnio_outcome":"={{ $json.outcome }}","pubnio_error":"={{ $json.error }}","pubnio_sent_at":"={{ $json.sentAt }}"},"matchingColumns":[]},"options":{}},"id":"1855b1c5-0767-4a96-a4c2-0a38fef29c20","name":"Write result to row","type":"n8n-nodes-base.dataTable","typeVersion":1.1,"position":[3520,300]},{"parameters":{"operation":"update","dataTableId":{"__rl":true,"value":"pubnio_feed_items","mode":"name"},"filters":{"conditions":[{"keyName":"source_id","condition":"eq","keyValue":"={{ $('Plan action').item.json.rowId }}"}]},"columns":{"mappingMode":"defineBelow","value":{"pubnio_key":"={{ $('Plan action').item.json.key }}","pubnio_status":"sending","pubnio_sent_at":"={{ $('Plan action').item.json.sentAt }}","pubnio_error":""},"matchingColumns":[]},"options":{}},"id":"b91d2cc2-eec1-4b53-a229-2e41c7a1161c","name":"Save key before sending","type":"n8n-nodes-base.dataTable","typeVersion":1.1,"position":[1560,100]},{"parameters":{"method":"POST","url":"={{ $('PubNio settings').first().json.baseUrl }}/api/v1/posts","authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","sendQuery":true,"queryParameters":{"parameters":[{"name":"workspaceId","value":"={{ $('PubNio settings').first().json.workspaceId }}"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"Idempotency-Key","value":"={{ $('Plan action').item.json.key }}"},{"name":"PubNio-Version","value":"2026-12-02"}]},"sendBody":true,"specifyBody":"json","jsonBody":"={{ JSON.stringify($('Plan action').item.json.body) }}","options":{"response":{"response":{"fullResponse":true,"neverError":true,"responseFormat":"json"}},"timeout":30000}},"id":"78437e30-2372-4f1c-ae9c-ccb309f8aa68","name":"Create post in PubNio","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[2880,100],"onError":"continueErrorOutput"},{"parameters":{"method":"GET","url":"={{ $('PubNio settings').first().json.baseUrl }}/api/v1/posts/{{ $('Plan action').item.json.postId }}","authentication":"genericCredentialType","genericAuthType":"httpHeaderAuth","sendQuery":true,"queryParameters":{"parameters":[{"name":"workspaceId","value":"={{ $('PubNio settings').first().json.workspaceId }}"}]},"sendHeaders":true,"headerParameters":{"parameters":[{"name":"PubNio-Version","value":"2026-12-02"}]},"options":{"response":{"response":{"fullResponse":true,"neverError":true,"responseFormat":"json"}},"timeout":30000}},"id":"12ddae08-d530-4b8c-a79c-5f2209b9f992","name":"Read post status","type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1780,500],"onError":"continueErrorOutput"},{"parameters":{"mode":"runOnceForEachItem","jsCode":"// Nothing is sent for these rows. A key that went out more than 23 hours ago\n// (or whose send time is unreadable) without a post ID may already have\n// posted, and PubNio replays a key for 24 hours only. A row the workflow\n// cannot send as written is rejected until a person fixes it.\nconst plan = $json;\nconst out = {\n  rowId: plan.rowId,\n  key: plan.key,\n  sentAt: plan.sentAt,\n  postId: plan.postId || '',\n  status: 'needs_review',\n  outcome: plan.outcome || '',\n  error: '',\n  revision: plan.draftRevision || '',\n  media: plan.sentMedia || '',\n  retryFailed: plan.retryFailed,\n};\nif (plan.action === 'invalid') {\n  Object.assign(out, { status: 'rejected', key: '', sentAt: '', error: plan.problem });\n  return { json: out };\n}\nout.error = 'Key ' + plan.key + ' was sent at ' + (plan.sentAt || 'an unknown time') + ' and no post ID came back. Find the post in PubNio and paste its ID into pubnio_post_id, or clear pubnio_key, pubnio_sent_at, and pubnio_status to send it as a new post.';\nreturn { json: out };"},"id":"e67ea275-3a7e-4660-a238-a0d02eb397a3","name":"Record row problem","type":"n8n-nodes-base.code","typeVersion":2,"position":[1780,700]},{"parameters":{},"id":"f90f0ae8-c5e3-4002-a3da-9c9e126e786c","name":"Nothing to do","type":"n8n-nodes-base.noOp","typeVersion":1,"position":[1780,900]},{"parameters":{"content":"## RSS → Bluesky\n\nNew feed items wait in a data table until a person approves them; approved rows post once. Bluesky allows 300 graphemes: if a title is too long PubNio rejects the request, the row shows the issue, and you edit `text` and clear `pubnio_status` to send it again.\n\n**Data table `pubnio_feed_items`** (create it under Overview → Data tables): `source_id`, `text`, `detail` (string), `approved` (boolean), and strings `pubnio_key`, `pubnio_post_id`, `pubnio_status`, `pubnio_outcome`, `pubnio_error`, `pubnio_sent_at`. Approve a row by setting `approved` to true in the table.\n\n**Setup:** feed URL on **New feed item**; `workspaceId` in **PubNio settings**; Header Auth credential `PubNio API key`.","height":320,"width":680},"id":"b153e88e-fead-4f45-aa7b-cc6a94c84861","name":"Setup","type":"n8n-nodes-base.stickyNote","typeVersion":1,"position":[-40,-340]}],"connections":{"New feed item":{"main":[[{"node":"Compose post","type":"main","index":0}]]},"Compose post":{"main":[[{"node":"Skip items already queued","type":"main","index":0}]]},"Skip items already queued":{"main":[[{"node":"Queue for approval","type":"main","index":0}]]},"Every 15 minutes":{"main":[[{"node":"PubNio settings","type":"main","index":0}]]},"PubNio settings":{"main":[[{"node":"Read approved rows","type":"main","index":0}]]},"Read approved rows":{"main":[[{"node":"Normalize row","type":"main","index":0}]]},"Normalize row":{"main":[[{"node":"Approved?","type":"main","index":0}]]},"Approved?":{"main":[[{"node":"Plan action","type":"main","index":0}],[{"node":"Not approved: skip","type":"main","index":0}]]},"Plan action":{"main":[[{"node":"Route by action","type":"main","index":0}]]},"Record PubNio answer":{"main":[[{"node":"Write result to row","type":"main","index":0}]]},"Record missing answer":{"main":[[{"node":"Write result to row","type":"main","index":0}]]},"Route by action":{"main":[[{"node":"Save key before sending","type":"main","index":0}],[{"node":"Read post status","type":"main","index":0}],[{"node":"Record row problem","type":"main","index":0}],[{"node":"Record row problem","type":"main","index":0}],[{"node":"Nothing to do","type":"main","index":0}]]},"Save key before sending":{"main":[[{"node":"Create post in PubNio","type":"main","index":0}]]},"Create post in PubNio":{"main":[[{"node":"Record PubNio answer","type":"main","index":0}],[{"node":"Record missing answer","type":"main","index":0}]]},"Read post status":{"main":[[{"node":"Record PubNio answer","type":"main","index":0}],[{"node":"Record missing answer","type":"main","index":0}]]},"Record row problem":{"main":[[{"node":"Write result to row","type":"main","index":0}]]}},"settings":{"executionOrder":"v1"},"pinData":{},"meta":{"templateCredsSetupCompleted":false}}