{"name":"Send a Slack message when a post goes live","nodes":[{"name":"Posthoop webhook","webhookId":"ab25b0d0-075e-4b8a-aeed-ad1192f450a1","parameters":{"httpMethod":"POST","path":"published-to-slack","responseMode":"responseNode","options":{"rawBody":true}},"type":"n8n-nodes-base.webhook","typeVersion":2,"position":[0,0],"id":"c96063a8-fdcb-450b-abd2-000000000001"},{"name":"Verify Posthoop signature","parameters":{"mode":"runOnceForAllItems","jsCode":"const { createHmac, timingSafeEqual } = require('crypto');\nconst secret = 'REPLACE_WITH_SIGNING_SECRET';\nconst signature = $input.first().json.headers['posthoop-signature'];\nconst body = await this.helpers.getBinaryDataBuffer(0, 'data');\nconst match = /^t=([1-9]\\d{0,15}),v1=([0-9a-f]{64})$/.exec(signature ?? '');\nif (!secret || secret === 'REPLACE_WITH_SIGNING_SECRET' || !match ||\n    Math.abs(Math.floor(Date.now() / 1000) - Number(match[1])) > 300) {\n  throw new Error('Invalid Posthoop signature');\n}\nconst expected = createHmac('sha256', secret).update(match[1] + '.').update(body).digest();\nif (!timingSafeEqual(expected, Buffer.from(match[2], 'hex'))) {\n  throw new Error('Invalid Posthoop signature');\n}\nreturn [{ json: JSON.parse(body.toString('utf8')) }];"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[250,0],"id":"c96063a8-fdcb-450b-abd2-000000000002"},{"name":"Acknowledge event","parameters":{"respondWith":"noData","options":{"responseCode":204}},"type":"n8n-nodes-base.respondToWebhook","typeVersion":1.4,"position":[500,0],"id":"c96063a8-fdcb-450b-abd2-000000000003"},{"name":"Published events only","parameters":{"mode":"runOnceForAllItems","jsCode":"return $input.all().filter(item => item.json.type === 'post.target.published');"},"type":"n8n-nodes-base.code","typeVersion":2,"position":[750,0],"id":"c96063a8-fdcb-450b-abd2-000000000004"},{"name":"Send Slack message","parameters":{"method":"POST","url":"https://hooks.slack.com/services/REPLACE/REPLACE/REPLACE","options":{},"sendBody":true,"specifyBody":"json","jsonBody":"={{ ({ text: 'Published: ' + ($json.data.externalUrl ?? $json.data.postId) }) }}"},"type":"n8n-nodes-base.httpRequest","typeVersion":4.2,"position":[1000,0],"id":"c96063a8-fdcb-450b-abd2-000000000005"}],"connections":{"Posthoop webhook":{"main":[[{"node":"Verify Posthoop signature","type":"main","index":0}]]},"Verify Posthoop signature":{"main":[[{"node":"Acknowledge event","type":"main","index":0}]]},"Acknowledge event":{"main":[[{"node":"Published events only","type":"main","index":0}]]},"Published events only":{"main":[[{"node":"Send Slack message","type":"main","index":0}]]}},"active":false,"settings":{"executionOrder":"v1"}}