Skip to content

Every 15 minutes

Welcome new customers when a HubSpot deal is won

As soon as a deal closes, the customer gets a personal welcome email from your Gmail and an account manager is assigned in HubSpot.

Runs
Every 15 minutes
Apps
Gmail, HubSpot
AI
Yes, uses the built-in AI allowance
Access
HubSpot deals/contacts read+write; Gmail gmail.send

Send this to your assistant

Create a ClickRuntime automation: when a HubSpot deal moves to Closed Won, assign a customer success manager and send the customer a personalised welcome email from my Gmail.

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

The moment a customer signs is when they are most engaged and most unsure about what happens next. In many small teams, though, the salesperson celebrates, moves on to the next deal, and the customer waits days for someone to explain the next step.

This watches HubSpot for deals that have just been won, hands the account to your customer success manager and sends the customer a welcome email written around what they actually bought, so onboarding starts the same day.

What you get out of it

  • Onboarding starts the day they sign

    Customers hear from you within minutes of the deal closing, not after the next team meeting.

  • Every email fits the customer

    AI uses the deal name and the contact's details, so the welcome mentions what they bought rather than reading like a form letter.

  • Ownership is clear from day one

    The deal is assigned to your customer success manager in HubSpot, so nobody wonders who is looking after the account.

  • No customer is missed or welcomed twice

    Each won deal is handled once, even if several close in the same afternoon.

How it works

What happens, step by step

  1. Every 15 minutes, ClickRuntime checks HubSpot for deals that have moved to Closed Won.

  2. It keeps a list of deals it has already welcomed, so each customer is emailed only once.

  3. It assigns the deal to your customer success manager and looks up the customer's main contact.

  4. AI writes a short welcome email based on the deal, and it is sent from your Gmail address.

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 HubSpot

What you get

RunsEvery 15 minutes
Welcome new customers when a HubSpot deal is wontoday, 9:00Succeeded
Gmail · SentTo: Priya Shah, Contoso Retail Welcome aboard, Priya. Thanks for choosing the Growth plan. Alex, your account manager, will be in touch today to book your kickoff call.

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

  • Act only on the items that match your own rules, and skip the rest
  • 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 HubSpot 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.
new_customer_onboarding_emails.pyexample
import base64, time
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, report_fetched
CSM_OWNER_ID = "12345678"
def hs(method, path, **kw):
    r = http.request(method, f"https://api.hubapi.com{path}", headers={"Authorization": f"Bearer {credentials.connection('hubspot', 'work')}"}, **kw)
    return r.raise_for_status() or (r.json() if r.content else {})
def send(to, subject, body):
    msg = EmailMessage(); msg["To"] = to; msg["Subject"] = subject; msg.set_content(body)
    build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).users().messages().send(userId="me", body={"raw": base64.urlsafe_b64encode(msg.as_bytes()).decode()}).execute()
@on_trigger
def run(event):
    since = str(state.get("since") or int((time.time() - 86400) * 1000))
    deals = hs("POST", "/crm/v3/objects/deals/search", json={"filterGroups": [{"filters": [{"propertyName": "dealstage", "operator": "EQ", "value": "closedwon"},
               {"propertyName": "closedate", "operator": "GTE", "value": since}]}], "properties": ["dealname"], "limit": 50})["results"]
    done = set(state.get("done") or []); deals = [d for d in deals if d["id"] not in done]
    report_fetched(len(deals))
    if not deals: return {"welcomed": 0}
    for d in deals:
        hs("PATCH", f"/crm/v3/objects/deals/{d['id']}", json={"properties": {"hubspot_owner_id": CSM_OWNER_ID}})
        for link in hs("GET", f"/crm/v4/objects/deals/{d['id']}/associations/contacts").get("results", [])[:1]:
            c = hs("GET", f"/crm/v3/objects/contacts/{link['toObjectId']}?properties=email,firstname")["properties"]
            body = ai.generate(f"Write a short, warm welcome email to {c.get('firstname')}, who just bought {d['properties']['dealname']}. Say a kickoff call comes next.", max_output_tokens=300).text
            send(c["email"], "Welcome aboard", body)
        done.add(d["id"])
    state.set("done", list(done)[-500:]); state.set("since", int(time.time() * 1000) - 3600000)
    return {"welcomed": len(deals)}

FAQ

Common questions

Who is assigned as the account manager?
You choose the HubSpot owner to assign, for example your customer success manager. You can also pick one by deal size or pipeline if you have more than one.
What does the welcome email include?
AI writes a short, friendly email using the deal and contact details, plus anything you always want included, such as a link to book a kickoff call or your help centre.
Who does the email go to?
The first contact associated with the deal in HubSpot. If a deal has no contact, it is skipped and noted in the run log.
What permissions does it need?
HubSpot deals/contacts read+write; Gmail gmail.send. 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 checks. Checks that find nothing new 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 “Welcome new customers when a HubSpot deal is won” from your assistant

Copy the prompt above, or connect your assistant first. Free plan, no credit card.