Skip to content

Klaviyo

Set up Klaviyo → JustAI data ingestion so JustAI can measure email performance (sends, opens, clicks) and optimize content over time. This is one-time setup — all templates will share this configuration.

JustAI ingests Klaviyo engagement events via an SFTP export → AWS Glue pipeline. This provides the core metrics needed for analysis and variant ranking.

  • Confirm which Klaviyo account you’re connecting.
  • Identify your JustAI org slug (usually your company name in all lower case — ask us if unsure).
  • Make sure you have permissions to create API keys and edit Flows in Klaviyo.

In Klaviyo:

  1. Go to Settings → API Keys → Create Private API Key.
  2. Name it JustAI.
  3. Grant the following scopes:
    • Flows: Read
    • Campaigns: Read
    • Metrics: Read
    • Profiles: Write (for writing generated content back to profiles)
  4. Copy the private key.

In the JustAI console:

  1. Open Org Integration Settings.
  2. Select Klaviyo as the ESP integration.
  3. Paste the Klaviyo private API key and save.

Generate a JustAI API key.

Store the key securely — you’ll use it in the Klaviyo webhook step.

Klaviyo integration uses a Flow with a Webhook step that calls JustAI to generate content, writes it to the recipient’s Klaviyo profile, then renders it in a downstream email step.

In Klaviyo, create or edit a Flow with this structure:

  1. Trigger — e.g., “Added to List”, metric trigger, or segment entry.
  2. Webhook step — calls JustAI to generate content (configured below).
  3. Time Delay — 2–5 minutes (gives JustAI time to write profile properties).
  4. Email step — renders the generated content from profile properties.

In the Webhook step:

  • Destination URL: https://worker.justwords.ai/api/generate/<org_slug>
  • Headers:
    • Content-Type: application/json
    • X-Api-Key: <JUSTAI_API_KEY>
  • JSON Body:
{
"template_id": "<template_id>",
"user_id": "{{ person.KlaviyoID }}",
"tracking_id": "{{ person.KlaviyoID }}.<flow_id>.<treatment_action_id>"
}

In the Klaviyo email step, reference the profile properties written by JustAI:

FieldKlaviyo Liquid
Subject Line{{ person|lookup:'jai_subject'|default:"Your weekly update" }}
Preview Text{{ person|lookup:'jai_preheader'|default:"" }}
Body (HTML){{ person|lookup:'jai_body'|safe }}

The |default: filters provide fallback content if the profile property hasn’t been written yet. The |safe filter renders raw HTML.

In the JustAI console, open the template’s Integration Settings:

  1. Select the Flow from the dropdown (synced from your Klaviyo account).
  2. Select the Treatment Message — the email action that renders JustAI-generated content.
  3. If using an external A/B split, select the Control Message as well.
  4. Save changes.

Pass additional user attributes to JustAI using the attrs field in the webhook body. JustAI uses these for variant ranking and content selection.

{
"template_id": "<template_id>",
"user_id": "{{ person.KlaviyoID }}",
"tracking_id": "{{ person.KlaviyoID }}.<flow_id>.<treatment_action_id>",
"attrs": {
"persona": "{{ person|lookup:'persona' }}",
"plan": "{{ person|lookup:'plan_type' }}"
}
}

For personalization fields that should be inserted into content without affecting variant selection, use fields:

{
"fields": {
"first_name": "{{ person.first_name }}"
}
}

You can combine both in the same request:

{
"attrs": {
"persona": "{{ person|lookup:'persona' }}"
},
"fields": {
"first_name": "{{ person.first_name }}"
}
}
  • Webhook not firing: Confirm the Flow is live (not in draft) and the webhook step is active.
  • Profile properties empty: Check that the Klaviyo API key has Profiles: Write scope. Also verify the time delay between the webhook and email steps is sufficient (2–5 minutes).
  • Wrong profile ID: Make sure you’re using {{ person.KlaviyoID }}, not {{ person.id }}.
  • Flows/campaigns not showing in JustAI: Click “Refresh Klaviyo Data” in Integration Settings. If they still don’t appear, verify the API key has Flows: Read and Campaigns: Read scopes.