Spaces:
Runtime error
Runtime error
File size: 728 Bytes
30b1c77 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 |
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)
|