{ "nodes": [ { "name": "Webhook", "type": "n8n-nodes-base.webhook", "position": [ 350, 70 ], "webhookId": "727b4887-e7f9-405f-bf94-7889c82a8f0b", "parameters": { "path": "sh", "options": {}, "responseMode": "lastNode" }, "typeVersion": 1 }, { "name": "Extract URL", "type": "n8n-nodes-base.set", "position": [ 650, -80 ], "parameters": { "values": { "string": [ { "name": "url", "value": "={{$node[\"Webhook\"].json[\"query\"][\"url\"]}}" } ] }, "options": {}, "keepOnlySet": true }, "typeVersion": 1 }, { "name": "Check URL", "type": "n8n-nodes-base.if", "position": [ 500, 70 ], "parameters": { "conditions": { "boolean": [ { "value1": "={{Object($node[\"Webhook\"].json[\"query\"]).hasOwnProperty(\"url\")}}", "value2": true } ] } }, "typeVersion": 1 }, { "name": "Crypto", "type": "n8n-nodes-base.crypto", "position": [ 800, -80 ], "parameters": { "type": "SHA256", "value": "={{$node[\"Extract URL\"].json[\"url\"]}}" }, "typeVersion": 1 }, { "name": "Airtable", "type": "n8n-nodes-base.airtable", "position": [ 1550, -30 ], "parameters": { "table": "YOUR TABLE NAME", "options": {}, "operation": "append", "application": "YOUR BASE ID" }, "credentials": { "airtableApi": "Personal Airtable API creds" }, "typeVersion": 1 }, { "name": "Set ID,shortUrl,longUrl", "type": "n8n-nodes-base.set", "position": [ 950, -80 ], "parameters": { "values": { "string": [ { "name": "id", "value": "={{$node[\"Crypto\"].json[\"data\"].substr(0,6)}}" }, { "name": "longUrl", "value": "={{$node[\"Extract URL\"].json[\"url\"]}}" }, { "name": "shortUrl", "value": "=http://n8n.ly/w/go?id={{$node[\"Crypto\"].json[\"data\"].substr(0,6)}}" } ] }, "options": {}, "keepOnlySet": true }, "typeVersion": 1 }, { "name": "Find by ID", "type": "n8n-nodes-base.airtable", "position": [ 1100, -80 ], "parameters": { "limit": 1, "table": "YOUR TABLE NAME", "operation": "list", "returnAll": false, "application": "YOUR BASE ID", "additionalOptions": { "filterByFormula": "=id=\"{{$node[\"Set ID,shortUrl,longUrl\"].json[\"id\"]}}\"" } }, "credentials": { "airtableApi": "Personal Airtable API creds" }, "typeVersion": 1, "alwaysOutputData": true }, { "name": "Already exists ?", "type": "n8n-nodes-base.if", "position": [ 1250, -80 ], "parameters": { "conditions": { "boolean": [ { "value1": "={{$node[\"Find by ID\"].json[\"id\"] != \"\" && $node[\"Find by ID\"].json[\"id\"] != null && $node[\"Find by ID\"].json[\"id\"] != undefined}}", "value2": true } ] } }, "typeVersion": 1 }, { "name": "Set Output", "type": "n8n-nodes-base.set", "position": [ 1400, -180 ], "parameters": { "values": { "string": [ { "name": "shortUrl", "value": "={{$node[\"Set ID,shortUrl,longUrl\"].json[\"shortUrl\"]}}" } ] }, "options": {}, "keepOnlySet": true }, "typeVersion": 1 }, { "name": "Set Error output", "type": "n8n-nodes-base.set", "position": [ 650, 170 ], "parameters": { "values": { "string": [ { "name": "error", "value": "url parameter missing" } ] }, "options": {}, "keepOnlySet": true }, "typeVersion": 1 }, { "name": "Set Output1", "type": "n8n-nodes-base.set", "position": [ 1700, -30 ], "parameters": { "values": { "string": [ { "name": "shortUrl", "value": "={{$node[\"Set ID,shortUrl,longUrl\"].json[\"shortUrl\"]}}" } ] }, "options": {}, "keepOnlySet": true }, "typeVersion": 1 }, { "name": "Set input", "type": "n8n-nodes-base.set", "position": [ 1400, -30 ], "parameters": { "values": { "number": [ { "name": "clicks" } ], "string": [ { "name": "id", "value": "={{$node[\"Crypto\"].json[\"data\"].substr(0,6)}}" }, { "name": "longUrl", "value": "={{$node[\"Extract URL\"].json[\"url\"]}}" }, { "name": "shortUrl", "value": "=http://n8n.ly/w/go?id={{$node[\"Crypto\"].json[\"data\"].substr(0,6)}}" }, { "name": "host", "value": "={{(new URL($node[\"Extract URL\"].json[\"url\"])).host}}" } ] }, "options": {}, "keepOnlySet": true }, "typeVersion": 1 }, { "name": "Webhook1", "type": "n8n-nodes-base.webhook", "position": [ 350, 430 ], "webhookId": "727b4887-e7f9-405f-bf94-7889c82a8f0b", "parameters": { "path": "/go", "options": { "responseHeaders": { "entries": [ { "name": "Content-Type", "value": "text/html" } ] }, "responsePropertyName": "result" }, "responseMode": "lastNode" }, "typeVersion": 1 }, { "name": "Set Error output1", "type": "n8n-nodes-base.set", "position": [ 640, 530 ], "parameters": { "values": { "string": [ { "name": "result", "value": "id parameter missing." } ] }, "options": {}, "keepOnlySet": true }, "typeVersion": 1 }, { "name": "Check Id", "type": "n8n-nodes-base.if", "position": [ 500, 430 ], "parameters": { "conditions": { "boolean": [ { "value1": "={{Object($node[\"Webhook1\"].json[\"query\"]).hasOwnProperty(\"id\")}}", "value2": true } ] } }, "typeVersion": 1 }, { "name": "Find by ID1", "type": "n8n-nodes-base.airtable", "position": [ 800, 330 ], "parameters": { "limit": 1, "table": "YOUR TABLE NAME", "operation": "list", "returnAll": false, "application": "YOUR BASE ID", "additionalOptions": { "filterByFormula": "=id=\"{{$node[\"Extract Id\"].json[\"id\"]}}\"" } }, "credentials": { "airtableApi": "Personal Airtable API creds" }, "typeVersion": 1, "alwaysOutputData": true }, { "name": "Already exists ?1", "type": "n8n-nodes-base.if", "position": [ 950, 330 ], "parameters": { "conditions": { "boolean": [ { "value1": "={{$node[\"Find by ID1\"].json[\"id\"] != \"\" && $node[\"Find by ID1\"].json[\"id\"] != null && $node[\"Find by ID1\"].json[\"id\"] != undefined}}", "value2": true } ] } }, "typeVersion": 1 }, { "name": "Set Output2", "type": "n8n-nodes-base.set", "position": [ 1400, 230 ], "parameters": { "values": { "string": [ { "name": "result", "value": "=\n\n
\n \n \n \n