Every 10 minutes
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.
- Runs
- Every 10 minutes
- Apps
- Gmail, HubSpot
- AI
- Yes, uses the built-in AI allowance
- Access
- Gmail gmail.readonly, gmail.compose; HubSpot contacts read
Send this to your assistant
Create a ClickRuntime automation: when a customer emails me, look them up in HubSpot and draft a reply in Gmail using their account details, then tell me in Slack so I can check it.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
An account manager looks after sixty customers. Every reply means opening HubSpot to check their plan, renewal date, open deals and the last conversation before writing a word. Ten emails in, the context-switching is the slow part, not the writing.
This looks up each sender in HubSpot as their email arrives and drafts a reply that already knows who they are, what they pay for and what's in progress. You read the draft, adjust it and send it, and Slack tells you when one is ready.
What you get out of it
Replies start with the right context
The draft mentions the customer's plan, open deals or renewal date where it matters, so you don't have to look it up.
Nothing is sent without you
Replies are saved as Gmail drafts, so you always review before sending.
Only known contacts get a draft
Emails from people who aren't in HubSpot are left alone, so newsletters and cold pitches don't fill your drafts.
You know when a draft is ready
A short Slack message names the customer and subject, so you can deal with it while it's fresh.
How it works
What happens, step by step
Every 10 minutes, ClickRuntime checks your Gmail inbox for new emails.
It looks up each sender in HubSpot and skips anyone who isn't a contact.
AI writes a reply using the email and the customer's HubSpot details.
The reply is saved as a Gmail draft in the same conversation, and you get a Slack message to review it.
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
from email.message import EmailMessage
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from email.utils import parseaddr
from clickruntime import on_trigger, credentials, http, state, ai, notify, report_fetched
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 {})
@on_trigger
def run(event):
g = build("gmail", "v1", credentials=Credentials(credentials.connection("google", "work")), cache_discovery=False).users()
seen = set(state.get("seen") or [])
ids = [m["id"] for m in g.messages().list(userId="me", q="in:inbox newer_than:1d").execute().get("messages", []) if m["id"] not in seen]
report_fetched(len(ids))
if not ids:
return {"drafts": 0}
for mid in ids:
m = g.messages().get(userId="me", id=mid, format="full").execute()
h = {x["name"]: x["value"] for x in m["payload"]["headers"]}; sender = parseaddr(h.get("From", ""))[1]
hit = hs("POST", "/crm/v3/objects/contacts/search", json={"filterGroups": [{"filters": [{"propertyName": "email", "operator": "EQ", "value": sender}]}],
"properties": ["firstname", "company", "lifecyclestage", "plan", "renewal_date"]})["results"]
if hit:
reply = ai.generate(f"Customer record: {hit[0]['properties']}\nTheir email: {m['snippet'][:1500]}\nDraft a helpful, brief reply.", max_output_tokens=400).text
msg = EmailMessage(); msg["To"] = sender; msg["Subject"] = "Re: " + h.get("Subject", ""); msg.set_content(reply)
g.drafts().create(userId="me", body={"message": {"raw": base64.urlsafe_b64encode(msg.as_bytes()).decode(), "threadId": m["threadId"]}}).execute()
notify.slack(f"Reply draft ready for {hit[0]['properties'].get('company')}: {h.get('Subject')}", channel="#inbox")
state.set("seen", (list(seen) + ids)[-500:])
return {"checked": len(ids)}FAQ
Common questions
Which emails get a draft?
What HubSpot details does it use?
Does it read the whole email thread?
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
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.
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 “Draft email replies using the customer's HubSpot record” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.