Spaces:
Runtime error
Runtime error
import requests | |
SALESFORCE_WEBHOOK_URL = "https://your-salesforce-instance/web-to-case" | |
def send_to_salesforce(payload): | |
summary = { | |
"Alert_Type__c": "Intrusion" if any(d["label"] == "person" for d in payload["detections"]) else "Fault", | |
"Thermal_Alert__c": payload["thermal"], | |
"Shadow_Alert__c": payload["shadow_issue"], | |
"Confidence__c": max([d["score"] for d in payload["detections"]], default=0) | |
} | |
headers = {"Content-Type": "application/json"} | |
try: | |
response = requests.post(SALESFORCE_WEBHOOK_URL, json=summary, headers=headers) | |
print("Salesforce Response:", response.status_code) | |
except Exception as e: | |
print("Error sending to Salesforce:", e) | |