{
  "name": "Pharlo — Webhook to Slack",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "pharlo-webhook",
        "options": { "rawBody": true }
      },
      "id": "c3000000-0000-4000-8000-000000000001",
      "name": "Pharlo Webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [240, 300],
      "webhookId": "pharlo-webhook"
    },
    {
      "parameters": {
        "jsCode": "// Requires NODE_FUNCTION_ALLOW_BUILTIN=crypto on the n8n instance.\nconst crypto = require('crypto');\nconst secret = $env.PHARLO_WEBHOOK_SECRET;\nconst header = $input.first().json.headers['x-webhook-signature-256'] || '';\nconst rawBody = $input.first().json.body; // raw because webhook rawBody=true\nconst expected = 'sha256=' + crypto.createHmac('sha256', secret).update(rawBody).digest('hex');\nconst a = Buffer.from(header);\nconst b = Buffer.from(expected);\nif (a.length !== b.length || !crypto.timingSafeEqual(a, b)) {\n  throw new Error('Invalid Pharlo webhook signature');\n}\nreturn $input.all();"
      },
      "id": "c3000000-0000-4000-8000-000000000002",
      "name": "Verify signature",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [460, 300]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{$env.SLACK_WEBHOOK_URL}}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify({ text: 'Pharlo event: ' + ($json.headers['x-webhook-event'] || 'unknown') }) }}",
        "options": {}
      },
      "id": "c3000000-0000-4000-8000-000000000003",
      "name": "Post to Slack",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [680, 300]
    }
  ],
  "connections": {
    "Pharlo Webhook": { "main": [[{ "node": "Verify signature", "type": "main", "index": 0 }]] },
    "Verify signature": { "main": [[{ "node": "Post to Slack", "type": "main", "index": 0 }]] }
  },
  "active": false,
  "settings": { "executionOrder": "v1" },
  "pinData": {},
  "meta": {}
}
