Spaces:
Runtime error
Runtime error
import requests | |
import json | |
SALESFORCE_WEBHOOK_URL = "https://your-salesforce-instance/services/web-to-case" | |
def send_to_salesforce(payload): | |
alert_type = "Intrusion" if any(d["label"] == "person" for d in payload["detections"]) else "Anomaly" | |
summary = { | |
"Alert_Type__c": alert_type, | |
"ThermalFlag__c": payload["thermal"], | |
"ShadowFlag__c": payload["shadow_issue"], | |
"Confidence_Score__c": max([d["score"] for d in payload["detections"]], default=0) | |
} | |
headers = {"Content-Type": "application/json"} | |
requests.post(SALESFORCE_WEBHOOK_URL, json=summary, headers=headers) | |