{ "name": "Create a Short URL and Read Its Statistics", "nodes": [ { "name": "On clicking 'execute'", "type": "n8n-nodes-base.manualTrigger", "position": [ 370, 300 ], "parameters": {}, "typeVersion": 1, "id": "create-short-url-and-read-stats-0" }, { "name": "Set link details", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForAllItems", "jsCode": "const target='',title='';if(!/^https?:\\/\\/[^\\s]+$/i.test(target)||!title.trim())throw Error('Enter a valid destination URL and title');return [{json:{target,title}}];" }, "id": "create-short-url-and-read-stats-1" }, { "name": "Yourls", "type": "n8n-nodes-base.yourls", "position": [ 570, 300 ], "parameters": { "url": "={{ $(\"Set link details\").first().json.target }}", "additionalFields": { "title": "={{ $(\"Set link details\").first().json.title }}" } }, "typeVersion": 1, "id": "create-short-url-and-read-stats-2" }, { "name": "Confirm short URL", "type": "n8n-nodes-base.code", "typeVersion": 2, "parameters": { "mode": "runOnceForAllItems", "jsCode": "const b=$input.first().json;if(!b||b.status==='fail'||typeof b.shorturl!=='string'||!/^https?:\\/\\/[^\\s]+$/i.test(b.shorturl))throw Error('YOURLS did not return a valid short URL');return $input.all();" }, "id": "create-short-url-and-read-stats-3" }, { "name": "Yourls1", "type": "n8n-nodes-base.yourls", "position": [ 770, 300 ], "parameters": { "shortUrl": "={{ $(\"Confirm short URL\").first().json.shorturl }}", "operation": "stats" }, "typeVersion": 1, "id": "create-short-url-and-read-stats-4" } ], "active": false, "settings": {}, "connections": { "On clicking 'execute'": { "main": [ [ { "node": "Set link details", "type": "main", "index": 0 } ] ] }, "Set link details": { "main": [ [ { "node": "Yourls", "type": "main", "index": 0 } ] ] }, "Yourls": { "main": [ [ { "node": "Confirm short URL", "type": "main", "index": 0 } ] ] }, "Confirm short URL": { "main": [ [ { "node": "Yourls1", "type": "main", "index": 0 } ] ] } }, "pinData": {} }