{
  "name": "Post-event lead routing",
  "nodes": [
    {
      "parameters": {
        "rule": {
          "interval": [
            {
              "field": "hours",
              "hoursInterval": 1
            }
          ]
        }
      },
      "id": "trigger-cron",
      "name": "Every hour",
      "type": "n8n-nodes-base.scheduleTrigger",
      "typeVersion": 1,
      "position": [
        240,
        320
      ]
    },
    {
      "parameters": {
        "operation": "list",
        "folderId": "={{$env.EVENT_DROP_FOLDER_ID}}",
        "options": {
          "q": "mimeType='text/csv' and modifiedTime > '{{ $now.minus({hours:1}).toISO() }}'"
        }
      },
      "id": "drive-watch",
      "name": "List new CSVs in Drive",
      "type": "n8n-nodes-base.googleDrive",
      "typeVersion": 3,
      "position": [
        460,
        320
      ],
      "credentials": {
        "googleDriveOAuth2Api": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {
        "conditions": {
          "number": [
            {
              "value1": "={{$json[\"files\"].length}}",
              "operation": "larger",
              "value2": 0
            }
          ]
        }
      },
      "id": "has-files",
      "name": "Any new files?",
      "type": "n8n-nodes-base.if",
      "typeVersion": 1,
      "position": [
        680,
        320
      ]
    },
    {
      "parameters": {
        "command": "=cd /opt/gtm-engineering && python automations/02-event-automation/post_event.py --csv /tmp/{{$json[\"name\"]}} --event \"{{$json[\"name\"].split('.')[0]}}\" --slack --out /tmp/digest_{{$json[\"id\"]}}.md"
      },
      "id": "run-postevent",
      "name": "Run post_event.py",
      "type": "n8n-nodes-base.executeCommand",
      "typeVersion": 1,
      "position": [
        900,
        240
      ]
    },
    {
      "parameters": {
        "channel": "#sdr-handoff",
        "text": "=Post-event digest ready: `{{$json[\"name\"]}}`. Hot leads syncing to HubSpot now."
      },
      "id": "notify-slack",
      "name": "Notify SDR channel",
      "type": "n8n-nodes-base.slack",
      "typeVersion": 2,
      "position": [
        1120,
        240
      ],
      "credentials": {
        "slackApi": {
          "name": "<your credential>"
        }
      }
    },
    {
      "parameters": {},
      "id": "noop",
      "name": "No new files",
      "type": "n8n-nodes-base.noOp",
      "typeVersion": 1,
      "position": [
        900,
        400
      ]
    }
  ],
  "connections": {
    "Every hour": {
      "main": [
        [
          {
            "node": "List new CSVs in Drive",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "List new CSVs in Drive": {
      "main": [
        [
          {
            "node": "Any new files?",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Any new files?": {
      "main": [
        [
          {
            "node": "Run post_event.py",
            "type": "main",
            "index": 0
          }
        ],
        [
          {
            "node": "No new files",
            "type": "main",
            "index": 0
          }
        ]
      ]
    },
    "Run post_event.py": {
      "main": [
        [
          {
            "node": "Notify SDR channel",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "post-event-v1",
  "tags": [
    "events",
    "post-event",
    "sdr"
  ]
}