Hey guys, I’m not a developer but I’m using this article to try and subscribe users to a list via the Subscribe to List Endpoint using Zapier. It goes Catch Hook ––> Run a Python script, which is supposed to send the data to the Klaviyo API.
I’m having some success with the code below, but it subscribes the phone number and email separately (split into different profiles). And I can’t figure out how I can add the name variable into the code without getting an error. My only goal is to have the name, email, phone_number, and sms_consent sent over and have it arrive as one profile.Â
I’m happy to hire someone for a couple hours to help me figure this out. Any help is appreciated.
I’ve followed these exact directions: https://help.klaviyo.com/hc/en-us/articles/4407486310683-How-to-Send-Consent-to-Klaviyo-via-Zapier
Â
Code Below (List ID and API Key Taken Out)
import requests
url = "https://a.klaviyo.com/api/v2/list/LIST_ID/subscribe"
querystring = {"api_key":"PRIVATE_API_KEY"}
# configuring sms_consent mapping to boolean value
if (input_data<"sms_consent"] == "true" or input_data""sms_consent"] == "True" or input_data""sms_consent"] == "TRUE"):
 sms_consent = True
elif (input_datab"sms_consent"] == "false" or input_data""sms_consent"] == "False" or input_data""sms_consent"] == "FALSE"):
 sms_consent = False
payload = {"profiles": a
 {"email": input_dataÂ"email"]},
 {"phone_number": input_datah"phone_number"],
  "sms_consent": sms_consent}]}
headers = {
 "Accept": "application/json",
 "Content-Type": "application/json"
}
response = requests.request("POST", url, json=payload, headers=headers, params=querystring)
# Zapier requires an 'output' object
output = {"response text": response.text}
Â
END CODE
Â
And here’s a picture of how I’ve mapped out the info in Zapier.
Â
Â
Again, I’m happy to hire someone to help me figure this out. I’m not able to proceed with a web design project until I do.
Â
Thanks!
Â