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.
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
Every 15 minutes, ClickRuntime checks HubSpot for deals that have moved to Closed Won.
It keeps a list of deals it has already welcomed, so each customer is emailed only once.
It assigns the deal to your customer success manager and looks up the customer's main contact.
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
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
- 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
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?
What does the welcome email include?
Who does the email go to?
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
Draft email replies using the customer's HubSpot record
When a customer emails you, a reply draft that knows their account is waiting in Gmail and you get a Slack message to review it.
See how it worksTurn lead notification emails into HubSpot contacts and deals
Lead emails from your shop, property portal or directory listing become HubSpot contacts with a deal attached, without any copying and pasting.
See how it worksDraft personal outreach emails for a HubSpot list
Each contact in your HubSpot outreach list gets a tailored email waiting in your Gmail drafts, ready for you to check and send.
See how it worksKeep exploring
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.