Spaces:
Runtime error
Runtime error
Update services/salesforce_dispatcher.py
Browse files
services/salesforce_dispatcher.py
CHANGED
@@ -1,18 +1,15 @@
|
|
1 |
import requests
|
|
|
2 |
|
3 |
-
SALESFORCE_WEBHOOK_URL = "https://your-salesforce-instance/web-to-case"
|
4 |
|
5 |
def send_to_salesforce(payload):
|
|
|
6 |
summary = {
|
7 |
-
"Alert_Type__c":
|
8 |
-
"
|
9 |
-
"
|
10 |
-
"
|
11 |
}
|
12 |
-
|
13 |
headers = {"Content-Type": "application/json"}
|
14 |
-
|
15 |
-
response = requests.post(SALESFORCE_WEBHOOK_URL, json=summary, headers=headers)
|
16 |
-
print("Salesforce Response:", response.status_code)
|
17 |
-
except Exception as e:
|
18 |
-
print("Error sending to Salesforce:", e)
|
|
|
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 |
+
fault_type = payload["fault_details"][0]["fault_type"] if payload["faults"] else "None"
|
8 |
summary = {
|
9 |
+
"Alert_Type__c": fault_type or "No Fault",
|
10 |
+
"FaultFlag__c": payload["faults"],
|
11 |
+
"Confidence_Score__c": max([f["confidence"] for f in payload["fault_details"]], default=0),
|
12 |
+
"Snapshot_URL__c": "temp.jpg"
|
13 |
}
|
|
|
14 |
headers = {"Content-Type": "application/json"}
|
15 |
+
requests.post(SALESFORCE_WEBHOOK_URL, json=summary, headers=headers)
|
|
|
|
|
|
|
|