Skip to content

Commit

Permalink
Update newsletter signup function to add "newsletter" segment to exis…
Browse files Browse the repository at this point in the history
…ting contacts
  • Loading branch information
eugenchio committed Jan 20, 2025
1 parent 1283765 commit 2cd556c
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions lambda-functions/newsletter_sign_up.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,13 @@ def add_crisp_contact(email):
website_id=website_id,
people_id=email,
)
contact_just_created = True
crisp.website.update_people_profile(
website_id=website_id,
people_id=contact_data['people_id'],
data={
'segments': ['newsletter'] + contact_data['segments'],
},
)
except RouteError:
contact_data = crisp.website.add_new_people_profile(
website_id=website_id,
Expand All @@ -42,8 +48,9 @@ def add_crisp_contact(email):
'segments': ['newsletter'],
},
)
contact_just_created = True

if contact_just_created:
if not contact_just_created:
subscription_status = crisp.website.get_people_subscription_status(
website_id=website_id,
people_id=contact_data['people_id'],
Expand Down

0 comments on commit 2cd556c

Please sign in to comment.