Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -79,20 +79,24 @@ def create_salesforce_record(name, email, phone_number):
|
|
| 79 |
'Email__c': email,
|
| 80 |
'Phone_Number__c': phone_number
|
| 81 |
})
|
|
|
|
|
|
|
| 82 |
print(f"Salesforce response: {customer_login}")
|
| 83 |
|
|
|
|
| 84 |
if customer_login.get('id'):
|
| 85 |
print(f"Record created successfully with ID: {customer_login['id']}")
|
| 86 |
return customer_login
|
| 87 |
else:
|
| 88 |
-
print("
|
| 89 |
-
return {"error": "Record creation failed
|
| 90 |
except Exception as e:
|
| 91 |
# Catch and log any exceptions during record creation
|
| 92 |
error_message = str(e)
|
| 93 |
print(f"Error creating Salesforce record: {error_message}")
|
| 94 |
return {"error": f"Failed to create record in Salesforce: {error_message}"}
|
| 95 |
|
|
|
|
| 96 |
@app.route("/")
|
| 97 |
def index():
|
| 98 |
return render_template("index.html")
|
|
@@ -133,12 +137,15 @@ def transcribe():
|
|
| 133 |
# Create record in Salesforce
|
| 134 |
salesforce_response = create_salesforce_record(name, email, phone_number)
|
| 135 |
|
|
|
|
|
|
|
|
|
|
| 136 |
# Check if the response contains an error
|
| 137 |
if "error" in salesforce_response:
|
| 138 |
print(f"Error creating record in Salesforce: {salesforce_response['error']}")
|
| 139 |
return jsonify(salesforce_response), 500
|
| 140 |
|
| 141 |
-
|
| 142 |
return jsonify({"text": transcribed_text, "salesforce_record": salesforce_response})
|
| 143 |
|
| 144 |
except Exception as e:
|
|
|
|
| 79 |
'Email__c': email,
|
| 80 |
'Phone_Number__c': phone_number
|
| 81 |
})
|
| 82 |
+
|
| 83 |
+
# Log the full response from Salesforce
|
| 84 |
print(f"Salesforce response: {customer_login}")
|
| 85 |
|
| 86 |
+
# Check if the response contains an ID (successful creation)
|
| 87 |
if customer_login.get('id'):
|
| 88 |
print(f"Record created successfully with ID: {customer_login['id']}")
|
| 89 |
return customer_login
|
| 90 |
else:
|
| 91 |
+
print(f"Record creation failed: {customer_login}")
|
| 92 |
+
return {"error": "Record creation failed, no ID returned."}
|
| 93 |
except Exception as e:
|
| 94 |
# Catch and log any exceptions during record creation
|
| 95 |
error_message = str(e)
|
| 96 |
print(f"Error creating Salesforce record: {error_message}")
|
| 97 |
return {"error": f"Failed to create record in Salesforce: {error_message}"}
|
| 98 |
|
| 99 |
+
|
| 100 |
@app.route("/")
|
| 101 |
def index():
|
| 102 |
return render_template("index.html")
|
|
|
|
| 137 |
# Create record in Salesforce
|
| 138 |
salesforce_response = create_salesforce_record(name, email, phone_number)
|
| 139 |
|
| 140 |
+
# Log the Salesforce response
|
| 141 |
+
print(f"Salesforce record creation response: {salesforce_response}")
|
| 142 |
+
|
| 143 |
# Check if the response contains an error
|
| 144 |
if "error" in salesforce_response:
|
| 145 |
print(f"Error creating record in Salesforce: {salesforce_response['error']}")
|
| 146 |
return jsonify(salesforce_response), 500
|
| 147 |
|
| 148 |
+
# If creation was successful, return the details
|
| 149 |
return jsonify({"text": transcribed_text, "salesforce_record": salesforce_response})
|
| 150 |
|
| 151 |
except Exception as e:
|