Solved

Add/update SMS consent with zapier

  • 5 October 2022
  • 1 reply
  • 62 views

Badge

Hi 🙂 My goal is to get SMS consent after subscription of a Klaviyo signup form. I want to use Zapier since Klaviyo do not sent OPT-IN to europe contries. 

I have followed this guide: 
https://help.klaviyo.com/hc/en-us/articles/4407486310683-How-to-Send-Consent-to-Klaviyo-via-Zapier

When testing the code in Zapier no errors happens. However inside Klaviyo the profiles do not get marked with SMS-consent. Do any of you guys know any common issues and a fix? :-) 

Underneath you can see a screenshot of my code in Zapier:


Heres the code: 

import requests

url = "https://a.klaviyo.com/api/v2/list/WXxhcB/subscribe"
querystring = {"api_key":"pk_fd3964481165b5fd3ee112dafea8f7dd7b"}

# 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_data["sms_consent"] == "false" or input_data["sms_consent"] == "False" or input_data["sms_consent"] == "FALSE"):
sms_consent = False

payload = {"profiles": [
{"email": input_data["email"], "phone_number": input_data["phone_number"], "sms_consent": input_data["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}

Best regards
Lasse, Lykke by Lykke

icon

Best answer by alex.hong 5 October 2022, 23:42

View original

1 reply

Userlevel 7
Badge +57

Hi there @lykkebylykke ,

Unfortunately, passing SMS Consent with Zapier into Klaviyo is not possible at this time. It would need to be done through an API call. We would recommend working with a developer or if you yourself are a developer, then we would recommend reviewing this section of the doc to understand how to subscribe & pass SMS consent in your API request:https://apidocs.klaviyo.com/reference/lists-segments#subscribe
 
If you do not have access to a developer, then please consider our robust community of partner agencies to assist with this. You can browse our Klaviyo Agency Directory to decide which option is best suited for you.

Reply