File size: 613 Bytes
30b1c77
b531be9
30b1c77
b531be9
30b1c77
 
b531be9
30b1c77
b531be9
 
 
 
30b1c77
 
b531be9
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
import requests
import json

SALESFORCE_WEBHOOK_URL = "https://your-salesforce-instance/services/web-to-case"

def send_to_salesforce(payload):
    fault_type = payload["fault_details"][0]["fault_type"] if payload["faults"] else "None"
    summary = {
        "Alert_Type__c": fault_type or "No Fault",
        "FaultFlag__c": payload["faults"],
        "Confidence_Score__c": max([f["confidence"] for f in payload["fault_details"]], default=0),
        "Snapshot_URL__c": "temp.jpg"
    }
    headers = {"Content-Type": "application/json"}
    requests.post(SALESFORCE_WEBHOOK_URL, json=summary, headers=headers)