Spaces:
Runtime error
Runtime error
| import requests | |
| def create_case_in_salesforce(message): | |
| # Example payload for creating a Case record in Salesforce | |
| case_data = { | |
| "subject": "Customer Inquiry from Chatbot", | |
| "description": message, | |
| "status": "New", | |
| "priority": "Medium", | |
| "origin": "Web Chat", | |
| } | |
| # Send POST request to Salesforce API to create a Case record | |
| response = requests.post( | |
| "https://your_instance.salesforce.com/services/data/vXX.0/sobjects/Case/", | |
| headers={ | |
| "Authorization": f"Bearer {SALESFORCE_API_KEY}", | |
| "Content-Type": "application/json", | |
| }, | |
| json=case_data, | |
| ) | |
| if response.status_code == 201: | |
| print("Case created successfully!") | |
| else: | |
| print("Failed to create case:", response.text) | |