---
name: klaviyo-insight-to-draft
description: >
  EXPERIMENTAL: preview skill, unsupported and may change. Turn a finding already in the conversation
  into one approved draft change in Klaviyo: a segment plus draft campaign, revised campaign copy, or
  an edited flow message. Use when the user says "fix it", "set that up", "act on that", or "target
  the people who did X" right after a performance report or account overview surfaced a problem. Not
  for building a segment or campaign from scratch with no finding behind it. Never sends a campaign; its only send is a test email to an address the user confirms. Requires the
  Klaviyo MCP server.
---

> Reading this skill from the web rather than installing it? Each file it mentions is published next to this SKILL.md: a Markdown file at the same path, and any other file at its path plus `.md`, wrapped in a fenced code block. Fetch a file only when a step needs it, and write a code file out by saving just the contents of its code block. Steps that run `$SKILL/...` mean the skill's directory; if the skill isn't installed, fetch those files first.

# Turn an insight into a draft

Turns one finding from a report into one draft change in Klaviyo, after the user approves it: a segment and draft campaign, revised campaign copy, or an edited flow message.

If the Klaviyo MCP server's tools are not available in this session, say so and stop. Do not guess at results.

## When to use

- Right after a report or the klaviyo-account-overview skill surfaced a problem or opportunity
- "Okay, fix the abandoned cart flow"
- "Can you set that up?"
- "Target the people who clicked but didn't buy"

If no finding is in the conversation yet, get one first with a performance report or the klaviyo-account-overview skill. Do not invent a problem to solve. If the user wants a segment or campaign built from scratch, with no finding behind it, a dedicated segment or campaign skill is a better fit.

## Data rules

- **Event metrics.** Accounts often have the same event from more than one source, such as one Placed Order from Shopify and another from the API. Before building a condition on an event, check each copy's count with `query_metric_aggregates` (`measurements: ["count"]`, `interval: "month"`) and use the copy that has events.
- **Timeframes.** Report tools (`get_campaign_report`, `get_flow_report`) take either a preset `{"key": "last_90_days"}` or a custom range `{"start": "<ISO datetime>", "end": "<ISO datetime>"}`, with no wrapper object. `query_metric_aggregates` is different: its range goes in the `filter` list as two strings, `greater-or-equal(datetime,<ISO datetime>)` and `less-than(datetime,<ISO datetime>)`.
- **Names, not IDs.** Find objects by name with the list tools. Never guess an ID. If a name matches more than one object, ask.
- **Segment definitions.** Condition groups are ANDed; conditions inside a group are ORed. Each thing that must be true gets its own group. Shape, from the `create_or_update_segment` schema:

  ```json
  {"condition_groups": [
    {"conditions": [{"type": "profile-metric", "metric_id": "<started checkout id>",
      "measurement": "count", "measurement_filter": {"type": "numeric", "operator": "greater-than-or-equal", "value": 1},
      "timeframe_filter": {"type": "date", "operator": "in-the-last", "unit": "day", "quantity": 60}}]},
    {"conditions": [{"type": "profile-metric", "metric_id": "<placed order id>",
      "measurement": "count", "measurement_filter": {"type": "numeric", "operator": "equals", "value": 0},
      "timeframe_filter": {"type": "date", "operator": "in-the-last", "unit": "day", "quantity": 60}}]},
    {"conditions": [{"type": "profile-marketing-consent",
      "consent": {"channel": "email", "can_receive_marketing": true, "consent_status": {"subscription": "any"}}}]}
  ]}
  ```

## Instructions

Work in this order. One approval covers one row of the proposal table, with every tool call that row needs.

1. Restate the finding in one sentence, with the metric value behind it (for example "123 checkouts started in the last 60 days, 0 recovery emails sent"). If several findings are open, recommend one and ask which to act on.
2. Check whether the real fix is a change this skill makes, a change the server can make another way, or something only Klaviyo's UI can do:
   - **Flow trigger, trigger filters, or profile filters.** `update_flow` changes only a flow's status. Call `report_unsupported_task` (`blocker_type: "tool_too_narrow"`, `area: "flows"`, `action: "update"`), then offer the supported route: read the flow with `get_flow` (`additional_fields_flow: ["definition"]`), and build a copy with `create_flow` that keeps the actions and uses the new trigger. The copy is created in draft. Tell the user to review it in Klaviyo, set it live, and set the old flow to manual or draft themselves. Do not change the old flow.
   - **Form changes.** `create_or_update_form` can edit a form, but that is outside this skill. Say so and stop.
   - Otherwise, pick the smallest change below.
3. Pick the smallest change that addresses it:
   - **Audience** (sends to a small or full list, low engagement, or a group that responds): a segment, then a draft campaign aimed at it.
   - **Weak campaign message**: a new draft with a revised subject line, preview text and body outline, modeled on the account's best campaign.
   - **Weak or missing flow step**: new copy or timing for that specific message.
4. For a segment, check that the audience exists before proposing it. Count unique profiles for each event condition over the window you plan to use, with `query_metric_aggregates` `measurements: ["unique"]`. This is an upper bound, not the segment size: it ignores the AND between conditions and the consent condition. If any count is zero, the segment would be empty. Widen the window to cover when the events actually happened, or say the audience does not exist yet and stop. Always add a condition group requiring that profiles can receive email marketing. Write the logic out in plain language with AND and OR, for example "started checkout in the last 60 days AND no placed order in the last 60 days AND can receive email marketing".
5. For copy, gather the brand inputs before writing: `get_brand_voice`, `get_brand_email_defaults`, and the account's best recent campaign (`get_campaign_report` for `last_90_days`, then `get_campaign_message` on the top conversion-rate campaign with at least about 100 recipients). Write subject line, preview text and body outline in that voice.
6. For a flow message, read the action with `get_flow` and `get_flow_message` and note its status. If the action is **draft or manual**, the edit is a draft and goes through `update_flow_action`. If the action is **live**, an edit would reach customers immediately, so this skill never edits it: create the revised copy as a standalone template with `create_email_template` named `{flow} - {message} - revised`, leave the live message untouched, and tell the user how to swap it in Klaviyo.
7. Check the sender. Read `get_account_details` for the default sender and `get_sending_domains` for a verified branded domain. If the default sender is on a free mailbox domain (gmail.com, yahoo.com, outlook.com and similar) and no branded domain is verified, say so in the proposal: campaigns from that sender are likely to be filtered or blocked, so the draft should not be sent until a branded domain is set up. Do not block the draft on it.
8. Show the full proposal before any write: what will be created or changed, its name, the audience and its estimated size (labeled as an upper bound until the segment exists), the copy, and each tool you will call. Wait for an explicit yes.
9. Write only what was approved:
   - **Segment:** `create_or_update_segment` with no `id`. Segments process asynchronously. Once `is_processing` is false, read the size with `get_segment` (`additional_fields_segment: ["profile_count"]`) and report it. If it is still processing, say so rather than reporting zero. Use this count, not the step 4 estimate, in the campaign proposal.
   - **Campaign:** `create_email_template` (or `create_or_update_dnd_email_template` for a drag-and-drop template), then `create_campaign` with the audience and one message whose variation sets `template_id`. If the template was not attached inline, use `assign_template_to_campaign_message`. Then `refresh_campaign_recipient_estimation` and `get_campaign_recipient_estimation` for the real recipient count. Preview with `render_email_template` and offer a test send with `create_template_preview_send_job`. A test send is the one email this skill ever sends, so confirm the recipient address with the user before calling it and send to no one else.
   - **Existing campaign copy:** read first with `get_campaign_message` or `get_email_template`, then `update_campaign_message` or `update_email_template`. For a campaign that was already sent, use `create_campaign_clone` and edit the clone.
   - **Flow message:** per step 6. Never change the flow's status.
10. After each write, read the object back and confirm it by name. If a write fails, explain the error in plain language, list what was already created in this run by name so nothing is orphaned silently, and stop. Do not retry with guessed IDs or fields.
11. Close with what was created, where to review it in Klaviyo (segments at `https://www.klaviyo.com/lists/{SEGMENT_ID}`, campaigns at `https://www.klaviyo.com/campaign/{CAMPAIGN_ID}/wizard`), and how to tell whether it worked: the metric, the baseline, and when to check. For example, "Ask me for a weekly brief in two weeks."

## Output

- Finding: one sentence with the metric value behind it.
- Proposal: a table with Change, Name, Audience (with size and whether it is an estimate), Tool calls.
- After writes: a checklist of what was created or updated, each by its Klaviyo name, with the review link.
- How to measure: the metric, the baseline, and when to check.

## Boundaries

- This skill ends at a draft. It does not send a campaign, schedule one or set a flow live. Its only send is the test email in step 9, to an address the user confirms. If the user explicitly asks to send or schedule, follow that instruction outside this skill: first confirm audience, sender and send time in one message, and wait for a clear yes.
- This skill never edits a live flow action. The revised copy is always delivered as a standalone template (step 6).
- If no one can reply in this session (for example an API call, a non-interactive run, or a scheduled task), stop after presenting the proposal and write nothing. An approval cannot be assumed.
- One finding per run. Several changes are done one at a time, each with its own approval.
- Never delete anything. If a change seems to need a deletion, explain that and stop.
- Do not claim the change will lift a metric by a specific amount.
