Skip to main content
This script polls your deals pipeline for recently updated entries, compares them against a local state file to detect stage changes, and sends a Slack notification when a deal moves. Run it every 5 minutes with cron.

How it works

  1. Fetch all pipeline entries from Supersonic.
  2. Load the previous state from a local JSON file.
  3. Compare: find entries where the stage changed.
  4. Post a Slack message for each change.
  5. Save the current state for the next run.

The script

Setup

1

Install dependencies

2

Set environment variables

3

Run once to initialize state

The first run creates the state file. No notifications are sent since there’s nothing to compare against.
Check that the state file was created:
4

Schedule with cron

Run every 5 minutes:

Sending email instead of Slack

Replace the notify_slack function with an email sender. Here’s one using smtplib:
The state file stores one snapshot of all entry stages. If the script misses a run (e.g., the machine was off), it will detect changes on the next run. It won’t detect intermediate stage changes that happened between runs.
For new deals entering the pipeline, check for entry IDs that exist in the current state but not in the old state. Add this after the comparison loop: