Notify Slack when a HubSpot deal over $50K is created using code

medium complexityCost: $0

Prerequisites

Prerequisites
  • Node.js or Python
  • HubSpot private app token
  • Slack Bot Token
  • Server for webhook or cron for polling

Webhook approach

Subscribe to deal.creation events via HubSpot webhooks, then filter by amount in your handler:

from flask import Flask, request, jsonify
from slack_sdk import WebClient
import requests, os
 
app = Flask(__name__)
slack = WebClient(token=os.environ["SLACK_BOT_TOKEN"])
HEADERS = {"Authorization": f"Bearer {os.environ['HUBSPOT_TOKEN']}"}
THRESHOLD = 50000
 
@app.route("/webhook", methods=["POST"])
def handle():
    for event in request.json:
        deal_id = event["objectId"]
        deal = requests.get(
            f"https://api.hubapi.com/crm/v3/objects/deals/{deal_id}",
            headers=HEADERS,
            params={"properties": "dealname,amount"}
        ).json()
 
        amount = float(deal["properties"].get("amount") or 0)
        if amount < THRESHOLD:
            continue
 
        slack.chat_postMessage(
            channel=os.environ["SLACK_CHANNEL_ID"],
            text=f"New large deal: {deal['properties']['dealname']}",
            blocks=[
                {"type": "section", "text": {"type": "mrkdwn",
                    "text": f"🎯 *New Large Deal*\n*{deal['properties']['dealname']}*\nAmount: ${amount:,.0f}"}},
                {"type": "context", "elements": [{"type": "mrkdwn",
                    "text": f"<https://app.hubspot.com/contacts/YOUR_PORTAL_ID/deal/{deal_id}|View in HubSpot>"}]}
            ]
        )
    return jsonify({"ok": True})

Polling alternative

If you can't host webhooks, poll every 5 minutes for deals created in the last 5 minutes with amount > 50000:

# crontab
*/5 * * * * python check_large_deals.py

Cost

  • Free — hosting only.

Need help implementing this?

We build and optimize automation systems for mid-market businesses. Let's discuss the right approach for your team.