Sanjayraju30 commited on
Commit
a9354da
·
verified ·
1 Parent(s): b2a6c9b

Create services/salesforce_dispatcher.py

Browse files
Files changed (1) hide show
  1. services/salesforce_dispatcher.py +15 -0
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
+ 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)