Dup_Chatbot / utils.py
jithenderchoudary's picture
Create utils.py
73ebd8d verified
raw
history blame contribute delete
811 Bytes
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)