Spaces:
Runtime error
Runtime error
Create salesforce_dispatcher.py
Browse files
services/salesforce_dispatcher.py
ADDED
|
@@ -0,0 +1,15 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import json
|
| 3 |
+
|
| 4 |
+
SALESFORCE_WEBHOOK_URL = "https://your-salesforce-instance/services/web-to-case"
|
| 5 |
+
|
| 6 |
+
def send_to_salesforce(payload):
|
| 7 |
+
alert_type = "Intrusion" if any(d["label"] == "person" for d in payload["detections"]) else "Anomaly"
|
| 8 |
+
summary = {
|
| 9 |
+
"Alert_Type__c": alert_type,
|
| 10 |
+
"ThermalFlag__c": payload["thermal"],
|
| 11 |
+
"ShadowFlag__c": payload["shadow_issue"],
|
| 12 |
+
"Confidence_Score__c": max([d["score"] for d in payload["detections"]], default=0)
|
| 13 |
+
}
|
| 14 |
+
headers = {"Content-Type": "application/json"}
|
| 15 |
+
requests.post(SALESFORCE_WEBHOOK_URL, json=summary, headers=headers)
|