{ "nodes": [ { "id": "publish-recent-wordpress-posts-to-medium-0", "name": "When clicking \"Execute Workflow\"", "type": "n8n-nodes-base.manualTrigger", "position": [ 460, 640 ], "parameters": {}, "typeVersion": 1 }, { "name": "Read recent published posts", "type": "n8n-nodes-base.wordpress", "typeVersion": 1, "parameters": { "authType": "basicAuth", "resource": "post", "operation": "getAll", "returnAll": false, "limit": 5, "options": { "order": "desc", "orderBy": "date", "status": "publish" } }, "id": "publish-recent-wordpress-posts-to-medium-1" }, { "id": "publish-recent-wordpress-posts-to-medium-2", "name": "Loop Over Items", "type": "n8n-nodes-base.splitInBatches", "position": [ 1300, 640 ], "parameters": { "batchSize": 1, "options": {} }, "typeVersion": 3 }, { "name": "Prepare post", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForEachItem", "jsCode": "const p=$json,t=p?.title?.rendered,c=p?.content?.rendered;if(typeof t!=='string'||!t.trim()||typeof c!=='string'||!c.trim())throw Error('Post requires rendered title and content');const title=t.replace(/<[^>]*>/g,'').replace(/&#(x[0-9a-f]+|\\d+);/gi,(_,v)=>String.fromCodePoint(v[0].toLowerCase()==='x'?parseInt(v.slice(1),16):parseInt(v,10))).replace(/&(amp|lt|gt|quot|apos|nbsp);/gi,(_,v)=>({amp:'&',lt:'<',gt:'>',quot:'\"',apos:\"'\",nbsp:' '})[v.toLowerCase()]);if(/&[a-z][a-z0-9]+;/i.test(title))throw Error('Unsupported HTML entity in title');return {json:{title,content:c}};" }, "id": "publish-recent-wordpress-posts-to-medium-3" }, { "name": "Read Medium author", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "parameters": { "url": "https://api.medium.com/v1/me", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "options": {} }, "id": "publish-recent-wordpress-posts-to-medium-4" }, { "name": "Publish to Medium", "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.2, "parameters": { "method": "POST", "url": "={{ 'https://api.medium.com/v1/users/' + encodeURIComponent($json.data.id) + '/posts' }}", "authentication": "genericCredentialType", "genericAuthType": "httpHeaderAuth", "sendBody": true, "contentType": "json", "specifyBody": "json", "jsonBody": "={{ {title: $('Prepare post').item.json.title, contentFormat:'html', content: $('Prepare post').item.json.content, tags:['Email Hosting','Email','Email Marketing'], publishStatus:'public', notifyFollowers:false} }}", "options": {} }, "id": "publish-recent-wordpress-posts-to-medium-5" }, { "name": "Confirm publication", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForEachItem", "jsCode": "if(!$json.data?.id||!$json.data?.url)throw Error('Medium publication not confirmed; inspect before retrying');return {json:$json};" }, "id": "publish-recent-wordpress-posts-to-medium-6" } ], "pinData": {}, "connections": { "When clicking \"Execute Workflow\"": { "main": [ [ { "node": "Read recent published posts", "type": "main", "index": 0 } ] ] }, "Read recent published posts": { "main": [ [ { "node": "Loop Over Items", "type": "main", "index": 0 } ] ] }, "Loop Over Items": { "main": [ [], [ { "node": "Prepare post", "type": "main", "index": 0 } ] ] }, "Prepare post": { "main": [ [ { "node": "Read Medium author", "type": "main", "index": 0 } ] ] }, "Read Medium author": { "main": [ [ { "node": "Publish to Medium", "type": "main", "index": 0 } ] ] }, "Publish to Medium": { "main": [ [ { "node": "Confirm publication", "type": "main", "index": 0 } ] ] }, "Confirm publication": { "main": [ [ { "node": "Loop Over Items", "type": "main", "index": 0 } ] ] } }, "name": "Publish Recent WordPress Posts to Medium", "active": false, "settings": { "executionOrder": "v1" } }