---
name: what-changed-analysis-basic
description: Show current vs previous period changes in ad spend, ad sales, total sales, ACOS and TACOS at the account level for an Intentwise account — one table, account totals only. Use for "what changed", period-over-period change checks, or /what-changed-analysis-basic.
---

# What Changed Analysis

One table, account totals, current period vs the previous period, shown in chat. No campaign
rows, no product rows, no files. Read-only — this skill never changes bids, budgets, or
campaign states.

| Metric | Source |
|---|---|
| Ad spend | ads |
| Ad sales | ads |
| Total sales | vendor_central / seller_central |
| ACOS | derived: ad spend ÷ ad sales |
| TACOS | derived: ad spend ÷ total sales |

Account grain only. If the user asks what's driving the change, or for campaign or product
detail, offer it — don't pull extra entities unasked.

## Step 1 — Resolve the account

Call `get_organization`, then `get_intentwise_accounts`. One account → use it. More than one →
ask which, and ask nothing else. Use anything the user already said earlier in the conversation
— account, channel, dates — instead of asking again.

**Channel is `amazon`, ads data source is `ads`.** Never ask which platform. Only switch if the
user explicitly names a different one.

Check `available_data_sources` for `vendor_central` or `seller_central` — total sales comes from
the retail side. If neither is connected, the skill still runs: drop the total-sales and TACOS
rows and say in one line that total sales isn't available for this account.

## Step 2 — Set the window

Default to the **last 7 days vs the prior 7 days**. If the user names a period, use it and
compare against the immediately preceding window of equal length. State what you used; don't ask.

## Step 3 — Pull the data

Two calls, issued **in parallel** in a single turn — they don't depend on each other. Same
account, same windows. Express both periods in one call; the insights service returns current
and previous together, so never make two calls per period.

| Call | entity | Ask for |
|---|---|---|
| A. Account ads | `account` | Ad spend and ad sales, current and previous period, `data_source='ads'` |
| B. Account total sales | `account` | Total (ordered / shipped) revenue, current and previous period, from `vendor_central` or `seller_central` |

Things that cost a retry if you skip them:

- **Ad metrics and total sales live on different tables at account level.** Pull A and B
  separately and join client-side. They are not available from one call at this grain.
- If B returns nothing but the retail source is connected, fall back to the `product` entity —
  it carries both advertising and total sales — pulled with no row limit, and take its
  grand-total row as account total sales. Never sum a top-N product list for an account total;
  a subset won't tie out.
- **The first row of most results is a grand total** with null grouping columns. At account
  grain that row is the answer, not a row to skip.
- If a call returns nothing, don't retry with a different entity. Note the gap and show the rest.

## Step 4 — Compute the changes (client-side)

- **Change** = current − previous, shown as both the absolute delta and the percent change.
- **Derive rates from summed bases**, never by averaging. ACOS = ad spend ÷ ad sales;
  TACOS = ad spend ÷ total sales; compute each from that period's totals.
- **Rate changes are percentage points.** ACOS moving 30% → 24% is **−6.0 pts**, not −20%.
- Read direction by meaning, not by sign: falling ACOS and TACOS are good, and the wording
  should say so.

## Step 5 — Present the results

One line naming the account, channel, and both date ranges. Then a single markdown table:

`Metric · Current · Previous · Change · % Change`

One row each: Ad spend, Ad sales, Total sales, ACOS, TACOS.

Formatting: money as `$15,846`, ACOS and TACOS as `21.8%`, percent changes as `+12.4%`, rate
changes as `−6.0 pts`.

Close with two or three short bullets on what actually moved — whether ad sales followed spend,
and whether total sales moved with ads or independently of them. The divergences are the story:
spend up with ad sales flat, total sales up while ad spend fell, TACOS moving in the opposite
direction to ACOS. Say which one is worth a closer look, and offer the campaign and product
breakdown if they want it. Don't restate the table.

## Rules

- Never invent a number. A missing metric is a note, not a guess.
- One account per run.
- Same two date windows for every metric.
- Account grain only — no campaign, keyword, or product rows.
- Read-only.
