Weekly
Get realistic close dates for open deals
Every week, AI estimates a realistic close date for each open deal, saves it in Salesforce and logs the old and new dates in a sheet.
- Runs
- Weekly
- Apps
- Google Sheets, Salesforce
- AI
- Yes, uses the built-in AI allowance
- Access
- api write; sheet edit
Send this to your assistant
Create a ClickRuntime automation: every week, estimate a realistic close date for each open Salesforce opportunity based on its stage and history, save it to a Predicted Close Date field, and log the old and new dates in my sheet.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
Close dates in most CRMs are hopeful. Reps set them at the end of the month or quarter, push them when they pass, and the forecast assumes deals will close far sooner than they do. Finance plans cash and hiring around those dates.
This automation gives each open deal a second opinion every week: a realistic close date based on its stage, age, activity and how often it's been pushed. It's saved next to the rep's date in Salesforce and logged in a sheet, so you can compare the two over time.
What you get out of it
A second forecast
Comparing the rep's date with the predicted one shows which parts of the pipeline are optimistic.
The rep's date is untouched
Predictions go into a separate field, so nothing the rep entered is overwritten.
A history to learn from
The weekly log in the sheet shows how predictions and real dates moved, which helps judge how reliable each is.
Grounded in the deal's own history
Stage, age, pushes and last activity all feed the estimate, not a flat rule.
How it works
What happens, step by step
Every week the automation reads your open opportunities from Salesforce.
AI estimates a realistic close date for each one from its stage, age, pushes and activity.
Each estimate is saved to a Predicted Close Date field on the deal.
A row per deal is added to your sheet with today's date, the rep's close date and the predicted one.
Before it runs live
- Connect your Google Sheets account and pick the spreadsheets it may use
- 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 Google Sheets and Salesforce steps into one automation
Under the hood
The code that runs this automation
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from datetime import date
from clickruntime import on_trigger, credentials, http, ai
SHEET_ID = "your-spreadsheet-id"
INSTANCE = "https://yourcompany.my.salesforce.com"
API = f"{INSTANCE}/services/data/v61.0"
SCHEMA = {"type": "object", "properties": {"dates": {"type": "array", "items": {"type": "string"}}}, "required": ["dates"]}
@on_trigger
def run(event):
headers = {"Authorization": f"Bearer {credentials.connection('salesforce', 'work')}"}
opps = http.get(f"{API}/query", headers=headers, params={"q": "SELECT Id, Name, StageName, Amount, CloseDate, "
"CreatedDate, PushCount, LastActivityDate FROM Opportunity WHERE IsClosed = false LIMIT 60"}).json()["records"]
if not opps:
return {"updated": 0}
lines = "\n".join(f"{i + 1}. {o['Name']} | {o['StageName']} | {o['Amount']} | created {o['CreatedDate'][:10]} | "
f"close {o['CloseDate']} | pushed {o['PushCount']} | last activity {o['LastActivityDate']}" for i, o in enumerate(opps))
dates = ai.generate(f"Today is {date.today()}. Estimate a realistic close date (YYYY-MM-DD) for each numbered deal, in order.\n"
+ lines, json_schema=SCHEMA, max_output_tokens=900).json["dates"]
log = []
for o, new in zip(opps, dates):
http.patch(f"{API}/sobjects/Opportunity/{o['Id']}", headers=headers,
json={"Predicted_Close_Date__c": new}).raise_for_status()
log.append([str(date.today()), o["Name"], o["StageName"], o["CloseDate"], new])
sheets = build("sheets", "v4", credentials=Credentials(credentials.connection("google", "work")),
cache_discovery=False).spreadsheets()
sheets.values().append(spreadsheetId=SHEET_ID, range="Close dates!A1", valueInputOption="RAW",
body={"values": log}).execute()
return {"updated": len(log)}FAQ
Common questions
Do I need a new Salesforce field?
Can it update the real close date instead?
How many deals does it handle per run?
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
Log review sentiment in a sheet and open cases for bad ones
New customer reviews are labelled positive, neutral or negative in a Google Sheet, and negative ones become Salesforce cases.
See how it worksAudit open deals against rules kept in a sheet
Every Monday, open Salesforce deals are checked against the rules in your Google Sheet and every breach is listed on a Findings tab.
See how it worksBuild a white-space table of what key accounts haven't bought
Each month, a Google Sheet shows every key account against your product list, marking what they own and counting the gaps.
See how it worksKeep exploring
Set up “Get realistic close dates for open deals” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.