Spaces:
Build error
Build error
| 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) |