Seth commited on
Commit
7324596
·
1 Parent(s): efc3d9b
Files changed (1) hide show
  1. backend/app/main.py +11 -13
backend/app/main.py CHANGED
@@ -422,28 +422,26 @@ async def push_to_smartlead(request: SmartleadPushRequest, db: Session = Depends
422
  failed_count += 1
423
  continue
424
 
425
- # Build custom variables
426
- custom_variables = {}
 
 
 
 
 
 
 
427
  for i in range(1, 11):
428
  if i in contact.get('subjects', {}):
429
  subject = contact['subjects'][i]
430
  subject_str = safe_str(subject) if subject else ""
431
  if subject_str:
432
- custom_variables[f'subject_{i}'] = subject_str
433
  if i in contact.get('bodies', {}):
434
  body = contact['bodies'][i]
435
  body_str = safe_str(body) if body else ""
436
  if body_str:
437
- custom_variables[f'body_{i}'] = body_str
438
-
439
- # Smartlead API doesn't allow "company" or "title" fields - remove them
440
- # Company and title info can be included in custom_variables if needed
441
- lead = {
442
- "email": email,
443
- "first_name": first_name,
444
- "last_name": last_name,
445
- "custom_variables": custom_variables
446
- }
447
  leads.append(lead)
448
 
449
  except Exception as e:
 
422
  failed_count += 1
423
  continue
424
 
425
+ # Build lead object - Smartlead API expects custom variables at top level, not nested
426
+ # Smartlead API doesn't allow "company", "title", or "custom_variables" nested object
427
+ lead = {
428
+ "email": email,
429
+ "first_name": first_name,
430
+ "last_name": last_name
431
+ }
432
+
433
+ # Add custom variables directly to lead object (subject_1, body_1, etc.)
434
  for i in range(1, 11):
435
  if i in contact.get('subjects', {}):
436
  subject = contact['subjects'][i]
437
  subject_str = safe_str(subject) if subject else ""
438
  if subject_str:
439
+ lead[f'subject_{i}'] = subject_str
440
  if i in contact.get('bodies', {}):
441
  body = contact['bodies'][i]
442
  body_str = safe_str(body) if body else ""
443
  if body_str:
444
+ lead[f'body_{i}'] = body_str
 
 
 
 
 
 
 
 
 
445
  leads.append(lead)
446
 
447
  except Exception as e: