{ "name": "PostPBSUpdate_new", "nodes": [ { "parameters": { "action": "hmac", "binaryData": true, "type": "SHA256", "dataPropertyName": "computed-sha256", "secret": "gqdSG9s8Lt8qYMgpxtSaeGM6nbYQAqq3X" }, "type": "n8n-nodes-base.crypto", "typeVersion": 1, "position": [ -1088, 176 ], "id": "6bdf8b9f-f928-4614-8433-b0cd2ca3aad7", "name": "x-hash-create", "alwaysOutputData": false }, { "parameters": { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "376cee8d-570b-4f25-bd45-c349a23061ae", "leftValue": "={{ $json.headers['x-pbs-signature'] }}", "rightValue": "={{ 'sha256=' + $json['computed-sha256'] }}", "operator": { "type": "string", "operation": "equals" } } ], "combinator": "and" }, "looseTypeValidation": "={{ false }}", "options": {} }, "type": "n8n-nodes-base.if", "typeVersion": 2.3, "position": [ -864, 176 ], "id": "14278d6e-b856-43ce-9457-3109544acfb7", "name": "xhash-check" }, { "parameters": { "errorMessage": "hash error" }, "type": "n8n-nodes-base.stopAndError", "typeVersion": 1, "position": [ -352, 256 ], "id": "555c813d-b40e-4e3f-bba9-f04d52a8c0fc", "name": "Stop and Error" }, { "parameters": { "httpMethod": "POST", "path": "e53cd013-b4c3-4110-be41-c8c412d29e23", "options": { "rawBody": true } }, "type": "n8n-nodes-base.webhook", "typeVersion": 2.1, "position": [ -1344, 176 ], "id": "079615e4-e43f-4659-9703-cd102a7442ad", "name": "WebH-listen for PBS update", "webhookId": "e53cd013-b4c3-4110-be41-c8c412d29e23" }, { "parameters": { "rules": { "values": [ { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "leftValue": "={{ $json.body.categories }}", "rightValue": "={{ 'recipes' }}", "operator": { "type": "array", "operation": "contains", "rightType": "any" }, "id": "0ef2f922-a8ea-4952-9fe1-ac0213e552bb" } ], "combinator": "and" }, "renameOutput": true, "outputKey": "Recipe Update" }, { "conditions": { "options": { "caseSensitive": true, "leftValue": "", "typeValidation": "strict", "version": 3 }, "conditions": [ { "id": "470240b2-3e66-4a88-b892-b87e54d6d240", "leftValue": "={{ $json.body.categories }}", "rightValue": "={{ \"post\" }}", "operator": { "type": "array", "operation": "contains", "rightType": "any" } } ], "combinator": "and" }, "renameOutput": true, "outputKey": "Post Update" } ] }, "options": {} }, "type": "n8n-nodes-base.switch", "typeVersion": 3.4, "position": [ -608, 64 ], "id": "b5ff3369-89c7-481c-9b23-18b17ee1621a", "name": "Switch on Tag" }, { "parameters": { "operation": "executeQuery", "query": "INSERT INTO pbs_recipes (post_id, recipe_title, recipe_url, keyword)\nVALUES (\n $1, $2, $3, $4\n)\nON DUPLICATE KEY UPDATE\n recipe_title = VALUES(recipe_title),\n recipe_url = VALUES(recipe_url),\n keyword = COALESCE(keyword, VALUES(keyword));", "options": { "queryReplacement": "={{ [$json.body.post_id, $json.body.title, $json.body.url, $json.body.tags.length > 0 ? $json.body.tags[0] : null] }}" } }, "type": "n8n-nodes-base.mySql", "typeVersion": 2.5, "position": [ -336, -48 ], "id": "9c016955-dbe1-41fe-95dc-145c8065b1d3", "name": "Update_recipe", "credentials": { "mySql": { "id": "4ETlVumrAq95ispJ", "name": "MySQL account" } } }, { "parameters": { "mode": "raw", "jsonOutput": "={\n \"title\": \"⛔ Hash Verification FAILED 🚨\",\n \"message\": \"Incoming webhook 'PostPBSUpdate failed signature check. Possible spoofed or malicious request. Check n8n logs immediately.\",\n \"timestamp\": \"{{ $now.toFormat('MMM dd, HH:mm:ss') }}\",\n \"space\": \"insta\"\n}", "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ -704, 352 ], "id": "963df8ce-4e18-4d9c-98d6-2c96bfc4a383", "name": "set_xhash_error" }, { "parameters": { "workflowId": { "__rl": true, "value": "P465jEMJyKNZGOHVppbv2", "mode": "list", "cachedResultUrl": "/workflow/P465jEMJyKNZGOHVppbv2", "cachedResultName": "SendPBSChat_New" }, "workflowInputs": { "mappingMode": "defineBelow", "value": {}, "matchingColumns": [], "schema": [], "attemptToConvertTypes": false, "convertFieldsToString": true }, "options": {} }, "type": "n8n-nodes-base.executeWorkflow", "typeVersion": 1.3, "position": [ 208, -48 ], "id": "8be01273-8509-44f9-9f1e-3b5496b8974c", "name": "Call 'SendPBSChat'1" }, { "parameters": { "mode": "raw", "jsonOutput": "={\n \"title\": \"PBS-Update: Success ✅\",\n \"message\": \"Updated Hub Content with new PBS recipe. {{ $('WebH-listen for PBS update').item.json.body.title }}\",\n \"timestamp\": \"{{ $now.toFormat('MMM dd, HH:mm:ss') }}\",\n \"space\": \"insta\"\n}", "options": {} }, "type": "n8n-nodes-base.set", "typeVersion": 3.4, "position": [ 16, -48 ], "id": "474889e9-d8ec-4919-a140-871a1f95ffc6", "name": "set_pbs_update_success" }, { "parameters": { "workflowId": { "__rl": true, "value": "P465jEMJyKNZGOHVppbv2", "mode": "list", "cachedResultUrl": "/workflow/P465jEMJyKNZGOHVppbv2", "cachedResultName": "SendPBSChat_New" }, "workflowInputs": { "mappingMode": "defineBelow", "value": {}, "matchingColumns": [], "schema": [], "attemptToConvertTypes": false, "convertFieldsToString": true }, "options": {} }, "type": "n8n-nodes-base.executeWorkflow", "typeVersion": 1.3, "position": [ -544, 368 ], "id": "0af25ba2-cdf9-4436-a004-29ad59dcb9b7", "name": "Call 'SendPBSChat_New'" }, { "parameters": { "method": "POST", "url": "https://api.cloudflare.com/client/v4/zones/5b64a56e652d7ffeb7b790ce2d915192/purge_cache", "authentication": "genericCredentialType", "genericAuthType": "httpBearerAuth", "sendBody": true, "specifyBody": "json", "jsonBody": "={\n \"files\": [\"{{ $json.body.url }}\"]\n}", "options": {} }, "type": "n8n-nodes-base.httpRequest", "typeVersion": 4.3, "position": [ -160, -48 ], "id": "a96df5e0-54b6-43e3-a4ab-c64f6420cf6d", "name": "CF-Post-Purge", "credentials": { "httpBearerAuth": { "id": "Hmo79vo4h9ZGPh3i", "name": "CF Cache Purge" } } } ], "pinData": { "WebH-listen for PBS update": [ { "json": { "headers": { "host": "n8n.plantbasedsoutherner.com", "user-agent": "WordPress/6.9.4; https://plantbasedsoutherner.com", "content-length": "201", "accept": "*/*", "accept-encoding": "deflate, gzip, br, zstd", "content-type": "application/json", "origin": "https://n8n.plantbasedsoutherner.com", "x-forwarded-for": "172.238.188.247", "x-forwarded-host": "n8n.plantbasedsoutherner.com", "x-forwarded-port": "443", "x-forwarded-proto": "https", "x-forwarded-server": "874112b5743e", "x-pbs-signature": "sha256=94218559d5eb16ccf5d4d475cf64f7e2748785854fa481c156142f24f610ce59", "x-real-ip": "172.238.188.247" }, "params": {}, "query": {}, "body": { "post_id": 2437, "title": "A Little Southern Luck for St. Paddy's Day", "url": "https://plantbasedsoutherner.com/a-little-southern-luck-for-st-paddys-day/", "tags": [], "categories": [ "recipes", "roundup" ] }, "webhookUrl": "https://n8n.plantbasedsoutherner.com/webhook/e53cd013-b4c3-4110-be41-c8c412d29e23", "executionMode": "production" }, "binary": { "data": { "data": "eyJwb3N0X2lkIjoyNDM3LCJ0aXRsZSI6IkEgTGl0dGxlIFNvdXRoZXJuIEx1Y2sgZm9yIFN0LiBQYWRkeSdzIERheSIsInVybCI6Imh0dHBzOlwvXC9wbGFudGJhc2Vkc291dGhlcm5lci5jb21cL2EtbGl0dGxlLXNvdXRoZXJuLWx1Y2stZm9yLXN0LXBhZGR5cy1kYXlcLyIsInRhZ3MiOltdLCJjYXRlZ29yaWVzIjpbInJlY2lwZXMiLCJyb3VuZHVwIl19", "mimeType": "application/json" } }, "pairedItem": { "item": 0 } } ] }, "connections": { "x-hash-create": { "main": [ [ { "node": "xhash-check", "type": "main", "index": 0 } ] ] }, "xhash-check": { "main": [ [ { "node": "Switch on Tag", "type": "main", "index": 0 } ], [ { "node": "set_xhash_error", "type": "main", "index": 0 } ] ] }, "WebH-listen for PBS update": { "main": [ [ { "node": "x-hash-create", "type": "main", "index": 0 } ] ] }, "Switch on Tag": { "main": [ [ { "node": "Update_recipe", "type": "main", "index": 0 } ] ] }, "Update_recipe": { "main": [ [ { "node": "CF-Post-Purge", "type": "main", "index": 0 } ] ] }, "set_xhash_error": { "main": [ [ { "node": "Call 'SendPBSChat_New'", "type": "main", "index": 0 } ] ] }, "set_pbs_update_success": { "main": [ [ { "node": "Call 'SendPBSChat'1", "type": "main", "index": 0 } ] ] }, "Call 'SendPBSChat_New'": { "main": [ [ { "node": "Stop and Error", "type": "main", "index": 0 } ] ] }, "CF-Post-Purge": { "main": [ [ { "node": "set_pbs_update_success", "type": "main", "index": 0 } ] ] } }, "active": true, "settings": { "executionOrder": "v1", "availableInMCP": false }, "versionId": "e9eb9c21-754e-4825-9afc-5e77f07f51c9", "meta": { "templateCredsSetupCompleted": true, "instanceId": "eeb18e777509f7207ee9abd45845e7fbf014989719160f3ed6ae633d872bf6c4" }, "id": "fLN1C9mloAhLhdK7zM5I1", "tags": [] }