# Klaviyo

Automatically extract lead information from conversations and create or update profiles in Klaviyo. Includes built-in consent handling for email and SMS marketing subscriptions.

## Prerequisites

* A Klaviyo account
* A Klaviyo Private API key

## Getting Your API Key

1. In Klaviyo, go to **Settings > API Keys**
2. Create a new Private API key or copy an existing one
3. See [Klaviyo's guide](https://help.klaviyo.com/hc/en-us/articles/7423954176283) for detailed instructions

## Setup

### Step 1: Connect Klaviyo

1. In Alhena, go to **Settings > Integrations**
2. Find **Klaviyo** and click **Enable**
3. Paste your Klaviyo Private API key
4. Click **Connect**

### Step 2: Configure Attributes

Choose which information to extract from conversations:

1. Click **Add attribute**
2. Enter the **Attribute name** (Klaviyo property key, e.g., `email`, `first_name`, `phone_number`)
3. Add a **Description** to help the AI identify this information
4. Optionally add **Examples** of values

Default attributes (pre-configured):

* `email`
* `first_name`
* `last_name`
* `consent`

***

## What Gets Captured

**Automatic context (no setup needed):**

* `alhena_chat_id` - Conversation identifier
* `page_url` and `page_title` - Where the conversation happened
* Visitor location (city, region, country, timezone, IP)

**Optional attributes you can add:**

* Standard Klaviyo fields (`phone_number`, `organization`, `title`, etc.)
* Custom profile properties
* UTM parameters (`utm_source`, `utm_medium`, `utm_campaign`, `gclid`)

***

## Consent Handling

Consent is handled automatically:

* The `consent` attribute is included by default
* If a user indicates they want to receive marketing communications, Alhena records their consent
* With consent + email: subscribed to Email Marketing
* With consent + phone: subscribed to SMS Marketing (requires Klaviyo SMS to be enabled)
* Without consent: profile is created but not subscribed

***

## Enabled Agents

When you connect Klaviyo, lead capture is enabled for the lead generation agent:

| Agent                     | Description                                                                 |
| ------------------------- | --------------------------------------------------------------------------- |
| **Lead generation agent** | Extracts configured attributes from conversations and syncs them to Klaviyo |

You can configure this agent in **AI Settings > Agents**.

***

## Disconnecting

To disconnect Klaviyo:

1. Go to **Settings > Integrations > Klaviyo**
2. Click **Disconnect**
3. Confirm the disconnection


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://alhena.gitbook.io/docs/integrations/marketing/integrating-klaviyo-with-alhena-ai.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
