Weekly
Get a weekly email of customers at risk of leaving
Each week you get an email listing customers whose health looks poor, with a score, the reason and how it changed since last week.
- Runs
- Weekly
- Apps
- Gmail, Salesforce
- AI
- Yes, uses the built-in AI allowance
- Access
- api; gmail.send
Send this to your assistant
Create a ClickRuntime automation: every week, score each customer's health from Salesforce activity, renewals and support cases, and email me the ones at risk with the reason.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
The head of customer success at a growing SaaS company has a hundred customers and a team of three. Most weeks there's no time to check every account, so the ones in trouble surface when they ask to cancel.
This automation looks at every customer in Salesforce each week, gives them a health score from their activity, upcoming renewal and recent support cases, and emails you the ones scoring low, with why and how the score has changed.
What you get out of it
Every customer checked, every week
Accounts nobody has looked at in a while get the same attention as the noisy ones.
Trend, not just a number
Each at-risk account shows last week's score too, so you can see who is getting worse.
A reason to start the conversation
The one-line reason, such as several urgent cases in the last month, tells your team what to raise.
Quiet when things are fine
If no account scores low, no email is sent.
How it works
What happens, step by step
Every week the automation reads your customer accounts from Salesforce with their last activity, renewal date and recent cases.
AI gives each customer a health score from 1 to 10 with a reason.
Scores are compared with last week's to show the trend.
Customers scoring 4 or below are emailed to you from your Gmail account.
Before it runs live
- Connect Google through your own Google app (a one-time, 10-minute setup), so it works with your own Gmail
- Connect Salesforce
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 Gmail and Salesforce steps into one automation
Under the hood
The code that runs this automation
import base64
from email.message import EmailMessage
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials, http, state, ai
ME, INSTANCE = "me@northwind.example", "https://yourcompany.my.salesforce.com"
SCHEMA = {"type": "object", "properties": {"accounts": {"type": "array", "items": {"type": "object", "properties": {
"n": {"type": "integer"}, "health": {"type": "integer"}, "reason": {"type": "string"}}}}}, "required": ["accounts"]}
def send(subject, body):
msg = EmailMessage()
msg["To"], msg["Subject"] = ME, subject
msg.set_content(body)
gmail = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False)
gmail.users().messages().send(userId="me", body={"raw": base64.urlsafe_b64encode(msg.as_bytes()).decode()}).execute()
@on_trigger
def run(event):
headers = {"Authorization": f"Bearer {credentials.connection('salesforce', 'work')}"}
accts = http.get(f"{INSTANCE}/services/data/v61.0/query", headers=headers, params={"q": "SELECT Id, Name, LastActivityDate, Renewal_Date__c, "
"(SELECT Priority FROM Cases WHERE CreatedDate = LAST_N_DAYS:90) FROM Account WHERE Type = 'Customer' LIMIT 80"}).json()["records"]
lines = [f"{i + 1}. {a['Name']} | last activity {a['LastActivityDate']} | renews {a['Renewal_Date__c']} | "
f"cases 90d: {[c['Priority'] for c in (a.get('Cases') or {}).get('records', [])]}" for i, a in enumerate(accts)]
scored = ai.generate("Score each customer's health 1 (about to churn) to 10 (healthy) with a one-line reason.\n" + "\n".join(lines),
json_schema=SCHEMA, max_output_tokens=1800).json["accounts"]
before = state.get("health") or {}
risky = [f"{accts[s['n'] - 1]['Name']}: {s['health']}/10 (last week {before.get(accts[s['n'] - 1]['Id'], 'n/a')}) - {s['reason']}\n"
f"{INSTANCE}/{accts[s['n'] - 1]['Id']}" for s in scored if s["health"] <= 4]
state.set("health", {accts[s["n"] - 1]["Id"]: s["health"] for s in scored})
if risky:
send(f"{len(risky)} customers at risk this week", "\n\n".join(risky))
return {"scored": len(scored), "at_risk": len(risky)}FAQ
Common questions
Which customers are scored?
What counts as at risk?
Can it include product usage?
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
Get a monthly strategy brief for your key accounts
Each month you get an email with upsell gaps, competitor risks and a suggested next move for each of your top accounts.
See how it worksGet a weekly email of your team's Salesforce activity
Every Monday you get an email showing each rep's tasks, meetings, deals moved and revenue won last week, with short coaching notes.
See how it worksGet an email when deals start to stall
Each day you get an email listing newly at-risk deals, with the warning signs for each.
See how it worksKeep exploring
Set up “Get a weekly email of customers at risk of leaving” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.