Weekly
Flag customers who may stop buying
Each week customers whose orders have dropped off are scored and the high-risk ones are added to a list.
- Runs
- Weekly
- Apps
- Klaviyo
- AI
- Yes, uses the built-in AI allowance
- Access
- read (events) + write (lists)
Send this to your assistant
Create a ClickRuntime automation: every Sunday, look at each Klaviyo customer's Placed Order history, score their churn risk, add high-risk customers to my 'Win-back' list and email me how many were added.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
An online store using Klaviyo knows who bought last month, but not who is quietly slipping away. A customer who used to order every three weeks and has now gone eight weeks without a purchase rarely announces it. By the time the gap shows up in a quarterly review, the discount that might have brought them back has been replaced by an expensive win-back campaign, or nothing at all.
Each week, ClickRuntime pulls Placed Order events for every profile in Klaviyo, looks at how often each person buys and how long it has been since their last order, and scores the likelihood that they are drifting away using ClickRuntime's built-in AI. Profiles it rates high-risk are added to a Klaviyo list, and you get an email summarizing who was flagged and why.
The list can then feed a flow, so a targeted offer reaches exactly those customers.
What you get out of it
Lapsing buyers are found before they are gone
Spotting a loyal customer whose rhythm has changed lets you reach out while the relationship is still alive. Winning back someone at week eight is far cheaper than finding them again after a year of silence.
Discounts go only where they matter
Blanket coupons teach everyone to wait for a sale and cost margin on people who would have bought anyway. A list of high-risk customers keeps incentives for those who need a nudge.
Retention work gets a ready audience
Because flagged profiles land on a Klaviyo list, a win-back flow can be pointed straight at them. There is no weekly export, no manual segment building and no excuse for the campaign to slip.
The email explains the reasoning
A summary that says who was flagged and why, for example a long gap compared with their usual order interval, lets you sanity check the scoring and trust it, instead of treating it as a black box.
Churn trends show across weeks
Seeing 40 flagged customers this week against 15 last week is an early alarm about something, such as a shipping problem or a price change. That prompts questions long before revenue drops visibly.
How it works
What happens, step by step
Once a week ClickRuntime looks at the last year of orders in Klaviyo, customer by customer.
It picks out customers who haven't ordered in more than 60 days and notes how often they used to buy.
AI compares their order history and picks out the ones most likely to stop buying.
Those high-risk customers are added to your win-back list in Klaviyo, and you get an email saying how many were added.
Before it runs live
- Connect Klaviyo
What you get
Build your own
Need it to work differently?
Your own rules
Conditions, thresholds, filters and exceptions, written the way you'd explain them to a colleague.
Any number of apps
One automation can read from one app and update several others. Over 248 apps are ready, and anything with an API works too.
AI where it helps
Summaries, classification, extraction and drafts use ClickRuntime's built-in AI, with no extra key.
On a schedule or on each event
Runs as often as every 5 minutes, or the moment an app sends an event, and keeps track of what it already handled.
Changes you can ask for
- Run it at a different time, more or less often, or only on weekdays
- Change what the AI looks for, or how it writes the result
- Add another app, for example also send it to Slack
- Combine it with other Klaviyo steps into one automation
Under the hood
The code that runs this automation
from collections import defaultdict
from datetime import datetime, timedelta, timezone
from clickruntime import on_trigger, credentials, http, ai, notify
API = "https://a.klaviyo.com/api"
PLACED_ORDER_METRIC_ID = "RESQ6t"
WIN_BACK_LIST_ID = "Wb4Lst"
def klaviyo():
return {"Authorization": f"Klaviyo-API-Key {credentials.secret('KLAVIYO_API_KEY')}",
"revision": "2024-10-15", "accept": "application/vnd.api+json", "content-type": "application/vnd.api+json"}
@on_trigger
def run(event):
h = klaviyo()
since = (datetime.now(timezone.utc) - timedelta(days=365)).strftime("%Y-%m-%dT%H:%M:%SZ")
url, params, orders = f"{API}/events", {"filter": f'equals(metric_id,"{PLACED_ORDER_METRIC_ID}"),greater-than(datetime,{since})',
"fields[event]": "datetime", "page[size]": 200}, defaultdict(list)
while url:
page = http.get(url, headers=h, params=params).json()
for e in page["data"]:
orders[e["relationships"]["profile"]["data"]["id"]].append(datetime.fromisoformat(e["attributes"]["datetime"]))
url, params = page["links"].get("next"), None
now = datetime.now(timezone.utc)
quiet = [(pid, sorted(d)) for pid, d in orders.items() if now - max(d) > timedelta(days=60)]
lines = [f"{i}. orders={len(d)} days_since_last={(now - d[-1]).days} "
f"avg_gap_days={(d[-1] - d[0]).days // max(len(d) - 1, 1)}" for i, (_, d) in enumerate(quiet[:300])]
high_risk = []
if lines:
r = ai.generate("Each line is a customer's order history. Return the numbers of customers at high churn risk.\n"
+ "\n".join(lines), max_output_tokens=800,
json_schema={"type": "object", "properties": {"high": {"type": "array", "items": {"type": "integer"}}}})
high_risk = [quiet[i][0] for i in r.json["high"] if i < len(quiet)]
for i in range(0, len(high_risk), 1000):
http.post(f"{API}/lists/{WIN_BACK_LIST_ID}/relationships/profiles", headers=h,
json={"data": [{"type": "profile", "id": p} for p in high_risk[i:i + 1000]]}).raise_for_status()
notify.email_me("Win-back list updated", f"Added {len(high_risk)} high-risk customers out of {len(orders)} buyers.")
return {"added": len(high_risk)}FAQ
Common questions
How does it decide that someone is likely to churn?
Do I need an OpenAI or Anthropic key for the AI scoring?
What happens to customers who have only ordered once?
What permissions does it need?
Does it need AI?
How many runs does it use?
Can I change how it works?
Related
You might also like
Post yesterday's Klaviyo revenue to Slack
Each morning Slack shows the revenue Klaviyo attributed to campaigns and flows yesterday, compared with the day before.
See how it worksGet a weekly Klaviyo campaign report
Every Monday you see open rate, click rate and revenue for each campaign sent last week.
See how it worksGet warned when your list starts shrinking
You hear about it the day your main list loses profiles or unsubscribes run higher than usual.
See how it worksKeep exploring
Set up “Flag customers who may stop buying” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.
