{
  "name": "Notify Slack on New Postgres Row",
  "nodes": [
    {
      "id": "a1b2c3d4-0001-0001-0001-000000000001",
      "name": "Schedule Trigger",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [
        100,
        200
      ],
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "minutes",
              "minutesInterval": 5
            }
          ]
        }
      }
    },
    {
      "id": "a1b2c3d4-0002-0002-0002-000000000002",
      "name": "Query New Rows",
      "type": "n8n-nodes-base.postgres",
      "typeVersion": 2,
      "position": [
        300,
        200
      ],
      "parameters": {
        "operation": "executeQuery",
        "query": "SELECT * FROM events WHERE created_at > NOW() - INTERVAL '5 minutes'",
        "options": {}
      },
      "credentials": {
        "postgres": {
          "name": "<your credential>"
        }
      }
    },
    {
      "id": "a1b2c3d4-0003-0003-0003-000000000003",
      "name": "Filter Non-Empty",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        500,
        200
      ],
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{ $items().length }}",
              "operation": "larger",
              "value2": 0
            }
          ]
        }
      }
    },
    {
      "id": "a1b2c3d4-0004-0004-0004-000000000004",
      "name": "Format Message",
      "type": "n8n-nodes-base.set",
      "typeVersion": 2,
      "position": [
        700,
        200
      ],
      "parameters": {
        "mode": "manual",
        "duplicateItem": false,
        "assignments": {
          "assignments": [
            {
              "id": "field-1",
              "name": "text",
              "value": "={{ $json.id }} \u2014 new event: {{ $json.type }} at {{ $json.created_at }}",
              "type": "string"
            }
          ]
        }
      }
    },
    {
      "id": "a1b2c3d4-0005-0005-0005-000000000005",
      "name": "Post to Slack",
      "type": "n8n-nodes-base.httpRequest",
      "typeVersion": 4,
      "position": [
        900,
        200
      ],
      "parameters": {
        "method": "POST",
        "url": "https://hooks.slack.com/services/T000/B000/XXXX",
        "sendBody": true,
        "bodyParameters": {
          "parameters": [
            {
              "name": "text",
              "value": "={{ $json.text }}"
            }
          ]
        }
      },
      "credentials": {
        "httpCustomAuth": {
          "name": "<your credential>"
        }
      }
    }
  ],
  "connections": {
    "Schedule Trigger": {
      "main": [
        [
          {
            "node": "Query New Rows",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Query New Rows": {
      "main": [
        [
          {
            "node": "Filter Non-Empty",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Filter Non-Empty": {
      "main": [
        [
          {
            "node": "Format Message",
            "type": "main",
            "index": 0
          }
        ],
        []
      ]
    },
    "Format Message": {
      "main": [
        [
          {
            "node": "Post to Slack",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  }
}