{
  "name": "Palanor morning edition by email (plain Webhook node)",
  "nodes": [
    {
      "id": "b2f0c6c2-1d0e-4c55-9b1a-000000000001",
      "name": "Palanor webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2.2,
      "position": [
        0,
        0
      ],
      "webhookId": "6c1f9b3e-8d2e-4b9f-8b88-0000000000b2",
      "parameters": {
        "httpMethod": "POST",
        "path": "palanor-edition",
        "responseMode": "onReceived",
        "options": {
          "rawBody": true
        }
      }
    },
    {
      "id": "b2f0c6c2-1d0e-4c55-9b1a-000000000002",
      "name": "Check the signature",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        260,
        0
      ],
      "parameters": {
        "jsCode": "// Checks the Palanor signature (Standard Webhooks) over the raw body, then passes the event on.\n// Self-hosted n8n: start n8n with NODE_FUNCTION_ALLOW_BUILTIN=crypto. n8n Cloud allows crypto already.\n// Paste your endpoint's signing secret (whsec_\u2026, shown once when you added the endpoint in Palanor).\nconst crypto = require('crypto');\nconst SECRET = 'whsec_PASTE_YOUR_SECRET';\nconst item = $input.first();\nconst h = item.json.headers;\nconst raw = (await this.helpers.getBinaryDataBuffer(0, 'data')).toString('utf8');\nconst id = h['webhook-id'], ts = h['webhook-timestamp'], sig = h['webhook-signature'] || '';\nif (!id || !ts || Math.abs(Date.now() / 1000 - Number(ts)) > 300) throw new Error('Missing or stale Palanor signature headers');\nconst key = Buffer.from(SECRET.replace(/^whsec_/, ''), 'base64');\nconst want = crypto.createHmac('sha256', key).update(`${id}.${ts}.${raw}`).digest('base64');\nconst ok = sig.split(' ').some((p) => { const v = p.split(',')[1] || ''; return v.length === want.length && crypto.timingSafeEqual(Buffer.from(v), Buffer.from(want)); });\nif (!ok) throw new Error('Palanor signature did not verify');\nreturn [{ json: JSON.parse(raw) }];"
      }
    },
    {
      "id": "b2f0c6c2-1d0e-4c55-9b1a-000000000003",
      "name": "Only edition.ready",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2.2,
      "position": [
        520,
        0
      ],
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "strict",
            "version": 2
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.type }}",
              "rightValue": "edition.ready",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      }
    },
    {
      "id": "b2f0c6c2-1d0e-4c55-9b1a-000000000004",
      "name": "Email the team",
      "type": "n8n-nodes-base.emailSend",
      "typeVersion": 2.1,
      "position": [
        780,
        0
      ],
      "parameters": {
        "fromEmail": "automation@example.com",
        "toEmail": "team@example.com",
        "subject": "={{ $json.data.edition.text }}",
        "emailFormat": "text",
        "text": "={{ $json.data.edition.text }}\n\nRead it in Palanor: {{ $json.links.palanor }}",
        "options": {}
      }
    }
  ],
  "connections": {
    "Palanor webhook": {
      "main": [
        [
          {
            "node": "Check the signature",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Check the signature": {
      "main": [
        [
          {
            "node": "Only edition.ready",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Only edition.ready": {
      "main": [
        [
          {
            "node": "Email the team",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "meta": {
    "templateCredsSetupCompleted": false,
    "palanor": "No community node needed. Activate, copy the Webhook node's production URL, and add it in Palanor: your organization's Settings \u2192 Webhooks \u2192 Add an endpoint, event 'Morning edition ready'. Paste the signing secret into the Code node. The edition's stories stay in Palanor: the event carries the date, the count and the link."
  },
  "pinData": {}
}
