Seth commited on
Commit ·
61b437d
1
Parent(s): 7755272
update
Browse files- backend/app/main.py +11 -13
backend/app/main.py
CHANGED
|
@@ -422,33 +422,31 @@ async def push_to_smartlead(request: SmartleadPushRequest, db: Session = Depends
|
|
| 422 |
failed_count += 1
|
| 423 |
continue
|
| 424 |
|
| 425 |
-
# Build lead object - Smartlead API
|
| 426 |
-
#
|
| 427 |
lead = {
|
| 428 |
"email": email,
|
| 429 |
"first_name": first_name,
|
| 430 |
-
"last_name": last_name
|
| 431 |
-
"custom_variables": []
|
| 432 |
}
|
| 433 |
|
| 434 |
-
#
|
|
|
|
| 435 |
for i in range(1, 11):
|
| 436 |
if i in contact.get('subjects', {}):
|
| 437 |
subject = contact['subjects'][i]
|
| 438 |
subject_str = safe_str(subject) if subject else ""
|
| 439 |
if subject_str:
|
| 440 |
-
|
| 441 |
-
"name": f"subject_{i}",
|
| 442 |
-
"value": subject_str
|
| 443 |
-
})
|
| 444 |
if i in contact.get('bodies', {}):
|
| 445 |
body = contact['bodies'][i]
|
| 446 |
body_str = safe_str(body) if body else ""
|
| 447 |
if body_str:
|
| 448 |
-
|
| 449 |
-
|
| 450 |
-
|
| 451 |
-
|
|
|
|
| 452 |
|
| 453 |
leads.append(lead)
|
| 454 |
|
|
|
|
| 422 |
failed_count += 1
|
| 423 |
continue
|
| 424 |
|
| 425 |
+
# Build lead object - Smartlead API doesn't allow "company" or "title" fields
|
| 426 |
+
# Try using "variables" instead of "custom_variables" - some APIs use different field names
|
| 427 |
lead = {
|
| 428 |
"email": email,
|
| 429 |
"first_name": first_name,
|
| 430 |
+
"last_name": last_name
|
|
|
|
| 431 |
}
|
| 432 |
|
| 433 |
+
# Try "variables" field name (some Smartlead versions may use this instead of custom_variables)
|
| 434 |
+
variables = {}
|
| 435 |
for i in range(1, 11):
|
| 436 |
if i in contact.get('subjects', {}):
|
| 437 |
subject = contact['subjects'][i]
|
| 438 |
subject_str = safe_str(subject) if subject else ""
|
| 439 |
if subject_str:
|
| 440 |
+
variables[f'subject_{i}'] = subject_str
|
|
|
|
|
|
|
|
|
|
| 441 |
if i in contact.get('bodies', {}):
|
| 442 |
body = contact['bodies'][i]
|
| 443 |
body_str = safe_str(body) if body else ""
|
| 444 |
if body_str:
|
| 445 |
+
variables[f'body_{i}'] = body_str
|
| 446 |
+
|
| 447 |
+
# Only add variables if we have any
|
| 448 |
+
if variables:
|
| 449 |
+
lead["variables"] = variables
|
| 450 |
|
| 451 |
leads.append(lead)
|
| 452 |
|