viep-fault-detection / services /salesforce_dispatcher.py
Sanjayraju30's picture
Rename salesforce_dispatcher.py to services/salesforce_dispatcher.py
30b1c77 verified
raw
history blame
728 Bytes
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)