{
  "id": "9a5cca03b34646d0",
  "name": "Settled change feed to Discord or Slack",
  "nodes": [
    {
      "parameters": {
        "content": "## Settled change feed to Discord or Slack\n\nCheck an x402 endpoint before your agent pays it. Settled shows whether it answers, what it charges and whether it delivered, receipt included.\n\n### How it works\n\nEvery 15 minutes the workflow reads Settled's free change feed (`GET https://settled.tools/v1/events`): venue verdict flips (a bounty board that started or stopped paying agents), newly suspected honeypot listings, and settlement-integrity changes. Events newer than the last one posted are formatted one per line and sent to a Discord or Slack incoming webhook. The id of the last event posted is kept in workflow static data, so nothing is posted twice.\n\n### Setup steps\n\n- Paste a Discord or Slack incoming-webhook URL into the Webhook Settings node (Discord: Server settings > Integrations > Webhooks; Slack: an app's Incoming Webhook).\n- Activate the workflow. Nothing else is needed: the feed is free and takes no key.\n\n### Customization\n\nChange the schedule in the trigger, or edit the Keep New Events Only node to filter by `kind` (verdict, honeypot, integrity) or by `severity`, or to change the message text. The feed and the venue scorecard behind it: https://settled.tools/venues",
        "height": 680,
        "width": 480
      },
      "id": "8e0c2187-e826-51f1-9440-3a31bfc60c97",
      "name": "Sticky Note",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -800,
        -32
      ]
    },
    {
      "parameters": {
        "content": "## Poll, filter, post\n\nThe schedule fires, the settings node supplies the webhook and the last posted id, the feed is fetched, new events are kept and formatted, and each one is posted.",
        "height": 300,
        "width": 1200,
        "color": 7
      },
      "id": "0a1f78aa-a1dd-565f-9ba9-8547c145d4a7",
      "name": "Sticky Note1",
      "type": "n8n-nodes-base.stickyNote",
      "typeVersion": 1,
      "position": [
        -240,
        -32
      ]
    },
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 15
            }
          ]
        }
      },
      "id": "4f713247-1908-53d6-b61b-d5e2d7937ce7",
      "name": "Every 15 Minutes",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1.2,
      "position": [
        -200,
        100
      ]
    },
    {
      "parameters": {
        "jsCode": "// Edit this one line: an incoming-webhook URL from Discord (Server settings > Integrations > Webhooks)\n// or Slack (an app's Incoming Webhook). Nothing else in the workflow needs changing.\nconst WEBHOOK_URL = 'https://discord.com/api/webhooks/REPLACE-ME';\n\nconst s = $getWorkflowStaticData('global');\nreturn [{ json: { webhook: WEBHOOK_URL, lastId: s.lastId ?? 0 } }];"
      },
      "id": "5666c913-133a-511e-b0f9-9ef36f61c539",
      "name": "Webhook Settings",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        40,
        100
      ]
    },
    {
      "parameters": {
        "url": "https://settled.tools/v1/events?limit=50",
        "options": {}
      },
      "id": "a2fc8104-b7b6-5de1-95e3-f891b2c0ea19",
      "name": "Fetch Settled Change Feed",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        280,
        100
      ]
    },
    {
      "parameters": {
        "jsCode": "// Keep only events newer than the last one posted, oldest first, and remember the newest id.\nconst cfg = $('Webhook Settings').first().json;\nconst body = $input.first().json;\nconst events = (body.events ?? []).filter(e => e.id > cfg.lastId).sort((a, b) => a.id - b.id);\nconst s = $getWorkflowStaticData('global');\nif (events.length) s.lastId = events[events.length - 1].id;\nconst isSlack = cfg.webhook.includes('hooks.slack.com');\nreturn events.map(e => {\n  const line = `Settled: ${e.kind} change \u2014 ${e.summary} (${e.subject}, severity ${e.severity})`;\n  return { json: { webhook: cfg.webhook, payload: isSlack ? { text: line } : { content: line } } };\n});"
      },
      "id": "a08a801b-743e-56ad-87b4-77af716890ee",
      "name": "Keep New Events Only",
      "type": "n8n-nodes-base.code",
      "typeVersion": 2,
      "position": [
        520,
        100
      ]
    },
    {
      "parameters": {
        "method": "POST",
        "url": "={{ $json.webhook }}",
        "sendBody": true,
        "specifyBody": "json",
        "jsonBody": "={{ JSON.stringify($json.payload) }}",
        "options": {}
      },
      "id": "f75d0fa4-4291-5f2a-9a2b-7122594cbe13",
      "name": "Post to Discord or Slack",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4.2,
      "position": [
        760,
        100
      ]
    }
  ],
  "connections": {
    "Every 15 Minutes": {
      "main": [
        [
          {
            "node": "Webhook Settings",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Webhook Settings": {
      "main": [
        [
          {
            "node": "Fetch Settled Change Feed",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Fetch Settled Change Feed": {
      "main": [
        [
          {
            "node": "Keep New Events Only",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Keep New Events Only": {
      "main": [
        [
          {
            "node": "Post to Discord or Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "settings": {
    "executionOrder": "v1"
  },
  "pinData": {},
  "meta": {
    "templateCredsSetupCompleted": false,
    "instanceId": "settled-tools-template"
  },
  "tags": []
}
