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 = {}) -> dictCreates 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
| Name | Type | Required | Description |
|---|---|---|---|
context | dict | Yes | The context object passed to your action |
email | str | Yes | The customer's email address |
event_name | str | Yes | The name of the event/metric in Klaviyo |
properties | dict | No | Custom 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}."}