Check for large Salesforce deals using an agent skill

low complexityCost: Usage-based

Prerequisites

Prerequisites
  • Claude Code or compatible agent
  • Environment variables: SALESFORCE_ACCESS_TOKEN, SALESFORCE_INSTANCE_URL, SLACK_BOT_TOKEN, SLACK_CHANNEL_ID

Create the skill

.claude/skills/large-sf-deal-alert/SKILL.md:

---
name: large-sf-deal-alert
description: Check for recently created Salesforce opportunities over $50K and alert Slack
disable-model-invocation: true
allowed-tools: Bash(python *)
---
 
Check for large Salesforce opportunities created today and post to Slack.
 
Run: `python $SKILL_DIR/scripts/check.py`

Add the script

.claude/skills/large-sf-deal-alert/scripts/check.py:

import os, json, urllib.request, urllib.parse
 
sf_token = os.environ["SALESFORCE_ACCESS_TOKEN"]
sf_url = os.environ["SALESFORCE_INSTANCE_URL"]
slack_token = os.environ["SLACK_BOT_TOKEN"]
channel = os.environ["SLACK_CHANNEL_ID"]
 
# Query Salesforce for large opportunities created today
soql = (
    "SELECT Id, Name, Amount, StageName, Account.Name, Owner.Name, CreatedDate "
    "FROM Opportunity "
    "WHERE CreatedDate = TODAY AND Amount >= 50000"
)
query_url = f"{sf_url}/services/data/v60.0/query?q={urllib.parse.quote(soql)}"
req = urllib.request.Request(query_url, headers={
    "Authorization": f"Bearer {sf_token}",
    "Content-Type": "application/json"
})
with urllib.request.urlopen(req) as resp:
    data = json.loads(resp.read())
 
records = data.get("records", [])
if not records:
    print("No large opportunities created today.")
    exit()
 
print(f"Found {len(records)} large opportunity(ies) created today.")
 
for opp in records:
    opp_url = f"{sf_url}/lightning/r/Opportunity/{opp['Id']}/view"
    account_name = opp.get("Account", {}).get("Name", "Unknown")
    owner_name = opp.get("Owner", {}).get("Name", "Unknown")
 
    text = (
        f":dart: *New Large Opportunity*\n"
        f"*{opp['Name']}*\n"
        f"Amount: *${opp['Amount']:,.0f}*\n"
        f"Stage: {opp['StageName']}\n"
        f"Owner: {owner_name}\n"
        f"Account: {account_name}\n"
        f"<{opp_url}|View in Salesforce>"
    )
 
    slack_data = json.dumps({"channel": channel, "text": text}).encode()
    slack_req = urllib.request.Request(
        "https://slack.com/api/chat.postMessage",
        data=slack_data,
        headers={
            "Authorization": f"Bearer {slack_token}",
            "Content-Type": "application/json"
        }
    )
    with urllib.request.urlopen(slack_req) as slack_resp:
        result = json.loads(slack_resp.read())
        if result.get("ok"):
            print(f"  Posted: {opp['Name']}")
        else:
            print(f"  Failed: {opp['Name']}{result.get('error')}")

Run

/large-sf-deal-alert

Best used as a periodic check before pipeline reviews or at the end of the business day.

Need help implementing this?

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