Skip to content

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.

Paste it into your assistant. It tells you what it will send or change before it runs live.

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

  1. Every week the automation reads your open opportunities from Salesforce.

  2. AI estimates a realistic close date for each one from its stage, age, pushes and activity.

  3. Each estimate is saved to a Predicted Close Date field on the deal.

  4. 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

RunsWeekly
Get realistic close dates for open dealstoday, 9:00Succeeded
Google Sheets · Close dates2026-10-19 | Northwind fleet rollout | Negotiation | 2026-10-31 | 2026-12-12

Build your own

Need it to work differently?

This template is a starting point. Copy the prompt and change it, or describe a different automation from scratch, with your own conditions, more apps or an AI step. Your assistant writes it, tests it and runs it on ClickRuntime.
  • 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

This is the Python script that runs each time the automation starts. Your AI assistant writes it for you when you send the prompt, and you allow each step in your assistant. To change how the automation works, describe the change to your assistant and it updates the script for you. For every function it can use, see the script reference.
predict_close_dates_and_update_salesforce.pyexample
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?
Yes, a date field on Opportunity called Predicted_Close_Date__c. Writing to a separate field keeps the rep's own close date as it is.
Can it update the real close date instead?
It can, but we'd advise against it: reps lose track of their own dates, and the history of pushes becomes harder to read.
How many deals does it handle per run?
Up to 60 open deals in a single AI call. If you have more, ask for a version that works in batches or filters to the current quarter.
What permissions does it need?
api write; sheet edit. Nothing else in your accounts is used.
Does it need AI?
Yes. It uses ClickRuntime's built-in AI, so you don't need an OpenAI or Anthropic key. Every plan includes a monthly AI allowance.
How many runs does it use?
One run each time it runs (weekly). Checks that find nothing to do and stop right away aren't counted.
Can I change how it works?
Yes. Describe the change to your AI assistant, for example a different schedule, channel or filter. It updates the automation, tests it and tells you what changed.

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.