{
  "name": "Subreddit Top Watch",
  "description": "Watches a subreddit's top post of the day and notifies you when a new post takes the crown — public JSON, no login.",
  "tags": [
    "reddit",
    "monitor",
    "schedule",
    "alert",
    "notification",
    "top post"
  ],
  "type": "triggered",
  "nodes": [
    {
      "id": "sticky-intro",
      "position": {
        "x": 20,
        "y": 20
      },
      "data": {
        "color": "#fff266",
        "content": "🏆 Follow a subreddit's top post.\n\nOnce a day this reads r/programming's #1 post of the day from Reddit's public JSON, remembers its id in a private Data Store, and notifies you only when a different post reaches the top. To watch another subreddit, edit the URL in 'Fetch top post'.",
        "runned": false,
        "wasRunned": false,
        "failed": false,
        "isRunning": false
      },
      "type": "stickyNote",
      "width": 360,
      "height": 200,
      "measured": {
        "width": 360,
        "height": 200
      }
    },
    {
      "id": "trigger-schedule",
      "position": {
        "x": 120,
        "y": 320
      },
      "data": {
        "instance": {
          "id": "af-base-node:trigger:schedule"
        },
        "label": "Check daily",
        "inputs": {
          "rules": [
            {
              "triggerInterval": "days",
              "daysBetweenTriggers": 1,
              "triggerAtHour": "9",
              "triggerAtMinute": 0
            }
          ]
        },
        "parameters": {
          "notes": "Runs once a day at 9am while the browser is open."
        },
        "runned": false,
        "wasRunned": false,
        "failed": false,
        "isRunning": false
      },
      "type": "trigger",
      "measured": {
        "width": 50,
        "height": 50
      },
      "selected": false
    },
    {
      "id": "fetch-top",
      "position": {
        "x": 440,
        "y": 320
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:httpRequest"
        },
        "label": "Fetch top post",
        "inputs": {
          "method": "GET",
          "url": "https://www.reddit.com/r/programming/top.json?limit=1&t=day"
        },
        "parameters": {
          "notes": "Public, no-auth request for the single top post of the day. Change 'programming' to any subreddit."
        },
        "runned": false,
        "wasRunned": false,
        "failed": false,
        "isRunning": false
      },
      "type": "basic",
      "measured": {
        "width": 50,
        "height": 50
      },
      "selected": false
    },
    {
      "id": "pick-id",
      "position": {
        "x": 665,
        "y": 320
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:pickField"
        },
        "label": "Take the post id",
        "inputs": {
          "fieldPath": "data.data.children.0.data.id",
          "outputFieldName": "postId"
        },
        "parameters": {
          "notes": "Pulls just the top post's id out of Reddit's nested response so we can compare it."
        },
        "runned": false,
        "wasRunned": false,
        "failed": false,
        "isRunning": false
      },
      "type": "basic",
      "measured": {
        "width": 50,
        "height": 50
      },
      "selected": false,
      "dragging": false
    },
    {
      "id": "get-last-seen",
      "position": {
        "x": 1080,
        "y": 320
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:dataStore"
        },
        "label": "Read last-seen id",
        "inputs": {
          "operation": "get",
          "scope": "workflow",
          "key": "last-reddit-id"
        },
        "parameters": {
          "notes": "Reads the post id we alerted on last time. Returns { key, found, value }."
        },
        "runned": false,
        "wasRunned": false,
        "failed": false,
        "isRunning": false
      },
      "type": "basic",
      "measured": {
        "width": 50,
        "height": 50
      },
      "selected": false
    },
    {
      "id": "is-new",
      "position": {
        "x": 1400,
        "y": 320
      },
      "data": {
        "instance": {
          "id": "af-base-node:if:if"
        },
        "label": "Is the top post new?",
        "inputs": {
          "conditions": [
            {
              "leftSide": "{{ $('Take the post id').postId }}",
              "rightSide": "{{ $input.value }}",
              "operator": {
                "operationType": "string",
                "operatorValue": "!="
              }
            }
          ]
        },
        "parameters": {
          "notes": "True (top port) fires when the current top id differs from the stored one. First run has an empty stored value, so it alerts once."
        },
        "runned": false,
        "wasRunned": false,
        "failed": false,
        "isRunning": false
      },
      "type": "if",
      "measured": {
        "width": 50,
        "height": 50
      },
      "selected": false
    },
    {
      "id": "notify",
      "position": {
        "x": 1720,
        "y": 220
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:showNotificationNode"
        },
        "label": "Show the alert",
        "inputs": {
          "title": "New top post in r/programming",
          "message": "{{ $('pick post Title').postTitle }}",
          "options": {
            "priority": "normal"
          }
        },
        "parameters": {
          "notes": "Pops a desktop notification with the new top post's title. Only runs on the True branch."
        },
        "runned": false,
        "wasRunned": false,
        "failed": false,
        "isRunning": false
      },
      "type": "basic",
      "measured": {
        "width": 50,
        "height": 50
      },
      "selected": true
    },
    {
      "id": "save-last-seen",
      "position": {
        "x": 2040,
        "y": 220
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:dataStore"
        },
        "label": "Remember this id",
        "inputs": {
          "operation": "set",
          "scope": "workflow",
          "key": "last-reddit-id",
          "value": "{{ $('Take the post id').postId }}",
          "valueFormat": "text"
        },
        "parameters": {
          "notes": "Stores the id we just alerted on so the next run only notifies for the next new top post."
        },
        "runned": false,
        "wasRunned": false,
        "failed": false,
        "isRunning": false
      },
      "type": "basic",
      "measured": {
        "width": 50,
        "height": 50
      },
      "selected": false
    },
    {
      "id": "0a2bac6b-226d-4e94-a25f-21459a2b08b6",
      "type": "basic",
      "position": {
        "x": 695,
        "y": 465
      },
      "data": {
        "instance": {
          "id": "af-base-node:basic:pickField"
        },
        "label": "pick post Title",
        "inputs": {
          "fieldPath": "data.data.children.0.data.title",
          "outputFieldName": "postTitle"
        },
        "parameters": {
          "notes": "Pulls just the top post's id out of Reddit's nested response so we can compare it."
        },
        "runned": false,
        "wasRunned": false,
        "failed": false,
        "isRunning": false
      },
      "origin": [
        0.5,
        0
      ],
      "measured": {
        "width": 50,
        "height": 50
      },
      "selected": false,
      "dragging": false
    }
  ],
  "edges": [
    {
      "id": "e-schedule-fetch",
      "type": "flowEdge",
      "source": "trigger-schedule",
      "target": "fetch-top",
      "markerEnd": {
        "type": "arrowclosed"
      }
    },
    {
      "id": "e-fetch-pick",
      "type": "flowEdge",
      "source": "fetch-top",
      "target": "pick-id",
      "markerEnd": {
        "type": "arrowclosed"
      }
    },
    {
      "id": "e-last-if",
      "type": "flowEdge",
      "source": "get-last-seen",
      "target": "is-new",
      "markerEnd": {
        "type": "arrowclosed"
      }
    },
    {
      "id": "e-if-notify",
      "type": "flowEdge",
      "source": "is-new",
      "target": "notify",
      "sourceHandle": "output-0",
      "markerEnd": {
        "type": "arrowclosed"
      }
    },
    {
      "id": "e-notify-save",
      "type": "flowEdge",
      "source": "notify",
      "target": "save-last-seen",
      "markerEnd": {
        "type": "arrowclosed"
      }
    },
    {
      "source": "fetch-top",
      "sourceHandle": "output-0",
      "target": "0a2bac6b-226d-4e94-a25f-21459a2b08b6",
      "targetHandle": "input-0",
      "id": "xy-edge__fetch-topoutput-0-0a2bac6b-226d-4e94-a25f-21459a2b08b6input-0",
      "markerEnd": {
        "type": "arrowclosed"
      }
    },
    {
      "source": "pick-id",
      "sourceHandle": "output-0",
      "target": "get-last-seen",
      "targetHandle": "input-0",
      "id": "xy-edge__pick-idoutput-0-get-last-seeninput-0",
      "markerEnd": {
        "type": "arrowclosed"
      }
    }
  ]
}