{
  "name": "Covfefe alerts → Discord (market-moving posts only)",
  "nodes": [
    {
      "parameters": {
        "httpMethod": "POST",
        "path": "covfefe",
        "responseMode": "onReceived",
        "options": {
          "rawBody": true
        }
      },
      "id": "5b0a3c6e-2d3f-4c9a-9a51-7c1f0d6b2a01",
      "name": "Covfefe webhook",
      "type": "n8n-nodes-base.webhook",
      "typeVersion": 2,
      "position": [
        0,
        0
      ],
      "webhookId": "covfefe"
    },
    {
      "parameters": {
        "jsCode": "// Verifies Covfefe's X-Covfefe-Signature header, then outputs the parsed event.\n// 1. Paste your signing secret (Covfefe → Webhook settings) below.\n// 2. Self-hosted n8n: allow Node's crypto module by setting the environment\n//    variable NODE_FUNCTION_ALLOW_BUILTIN=crypto and restarting n8n.\nconst SIGNING_SECRET = 'whsec_PASTE_YOUR_SIGNING_SECRET';\nconst TOLERANCE_SECONDS = 300;\n\nconst crypto = require('crypto');\nconst item = $input.first();\nconst header = item.json.headers['x-covfefe-signature'] || '';\nconst parts = Object.fromEntries(header.split(',').map((p) => {\n  const i = p.indexOf('=');\n  return [p.slice(0, i), p.slice(i + 1)];\n}));\nconst timestamp = Number(parts.t);\n// The signature covers the exact bytes Covfefe sent, so verify the raw body,\n// not a re-serialized copy of the parsed JSON.\nconst raw = await this.helpers.getBinaryDataBuffer(0, 'data');\nconst expected = crypto.createHmac('sha256', SIGNING_SECRET)\n  .update(`${timestamp}.`).update(raw).digest('hex');\nconst valid = typeof parts.v1 === 'string' && parts.v1.length === expected.length &&\n  crypto.timingSafeEqual(Buffer.from(expected), Buffer.from(parts.v1));\nif (!valid || !Number.isFinite(timestamp) || Math.abs(Date.now() / 1000 - timestamp) > TOLERANCE_SECONDS) {\n  throw new Error('Invalid Covfefe signature: check the signing secret');\n}\nreturn [{ json: JSON.parse(raw.toString('utf8')) }];"
      },
      "id": "5b0a3c6e-2d3f-4c9a-9a51-7c1f0d6b2a02",
      "name": "Verify signature",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        240,
        0
      ]
    },
    {
      "parameters": {
        "conditions": {
          "options": {
            "caseSensitive": true,
            "leftValue": "",
            "typeValidation": "loose"
          },
          "conditions": [
            {
              "id": "c1",
              "leftValue": "={{ $json.event }}",
              "rightValue": "post.enriched",
              "operator": {
                "type": "string",
                "operation": "equals"
              }
            },
            {
              "id": "c2",
              "leftValue": "={{ $json.enrichment.relevance }}",
              "rightValue": 7,
              "operator": {
                "type": "number",
                "operation": "gte"
              }
            },
            {
              "id": "c3",
              "leftValue": "={{ $json.post.type }}",
              "rightValue": "video",
              "operator": {
                "type": "string",
                "operation": "notEquals"
              }
            }
          ],
          "combinator": "and"
        },
        "options": {}
      },
      "id": "5b0a3c6e-2d3f-4c9a-9a51-7c1f0d6b2a03",
      "name": "Scored 7+ and not a video?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 2,
      "position": [
        480,
        0
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "https://discord.com/api/webhooks/PASTE/YOUR_DISCORD_WEBHOOK",
        "sendBody": true,
        "specifyBody": "keypair",
        "options": {},
        "contentType": "json",
        "bodyParameters": {
          "parameters": [
            {
              "name": "content",
              "value": "={{ ['**Trump post · relevance ' + $json.enrichment.relevance + '/10**', $json.enrichment.plain_english, $json.post.url].join('\\n') }}"
            }
          ]
        }
      },
      "id": "5b0a3c6e-2d3f-4c9a-9a51-7c1f0d6b2a04",
      "name": "Post to Discord",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        720,
        -100
      ]
    }
  ],
  "connections": {
    "Covfefe webhook": {
      "main": [
        [
          {
            "node": "Verify signature",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Verify signature": {
      "main": [
        [
          {
            "node": "Scored 7+ and not a video?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Scored 7+ and not a video?": {
      "main": [
        [
          {
            "node": "Post to Discord",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "active": false,
  "pinData": {}
}
