Ai knowledge and logicHelpers

klaviyo_create_event

Create a custom event in Klaviyo for a customer profile.

klaviyo_create_event(context: dict, email: str, event_name: str, properties: dict = {}) -> dict

Creates a custom event (metric) in Klaviyo for a customer profile. Events can be used to trigger Klaviyo flows or for segmentation.

Requires the Klaviyo integration to be installed for the business.


Parameters

NameTypeRequiredDescription
contextdictYesThe context object passed to your action
emailstrYesThe customer's email address
event_namestrYesThe name of the event/metric in Klaviyo
propertiesdictNoCustom properties to attach to the event (defaults to {})

Returns

dict{"success": true}


Examples

Track a support interaction

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

    klaviyo_create_event(context, email, "Support Conversation Started", {
        "conversationId": context["conversation"]["id"],
        "topic": context["args"].get("topic", "general"),
    })

    return {"success": True}

Track a product inquiry for marketing automation

def execute_action(context):
    email = context["args"]["email"]
    product_name = context["args"]["productName"]

    klaviyo_create_event(context, email, "Product Inquiry", {
        "productName": product_name,
        "source": "chatbot",
    })

    return {"success": True, "message": f"We've noted your interest in {product_name}."}

On this page