Ai knowledge and logicHelpers

klaviyo_subscribe_to_list

Subscribe an email to a Klaviyo mailing list.

klaviyo_subscribe_to_list(context: dict, email: str, list_id: str) -> dict

Subscribes an email address to a specific Klaviyo mailing list.

Requires the Klaviyo integration to be installed for the business.


Parameters

NameTypeDescription
contextdictThe context object passed to your action
emailstrThe customer's email address
list_idstrThe Klaviyo list ID to subscribe to

Returns

dict{"success": true}


Examples

Subscribe a customer to a newsletter

def execute_action(context):
    email = context["args"]["email"]
    klaviyo_subscribe_to_list(context, email, "WbBHEg")
    return {"success": True, "message": "You've been subscribed to our newsletter!"}

Subscribe to a list chosen by the customer

def execute_action(context):
    email = context["args"]["email"]
    list_id = context["args"]["listId"]

    klaviyo_subscribe_to_list(context, email, list_id)
    return {"success": True}

On this page