Every 10 minutes
Turn 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.
- Runs
- Every 10 minutes
- Apps
- Gmail, HubSpot
- AI
- Yes, uses the built-in AI allowance
- Access
- Gmail gmail.readonly; HubSpot contacts+deals write
Send this to your assistant
Create a ClickRuntime automation: when a lead notification email arrives in my Gmail, pull out the person's details and create a HubSpot contact and a deal for them.
First time? Adding ClickRuntime to your assistant takes about two minutes.
Why use it
Why teams use this automation
Plenty of lead sources don't connect to a CRM. A property portal, a marketplace listing or a booking site sends you an email with the enquirer's name, phone number and what they want, and someone has to copy it into HubSpot. On a busy week some never make it in.
This reads those notification emails as they arrive, uses AI to pull out the contact details and what they asked for, and creates the contact and a deal in HubSpot linked together, so every enquiry is in your pipeline within minutes.
What you get out of it
No more copying from emails
Name, email, phone and the enquiry are taken from the email and entered for you.
Every enquiry becomes a deal
A deal is created and linked to the contact, so it shows in your pipeline straight away.
Handles messy formats
AI reads the email the way a person would, so changes in the portal's layout don't break it.
Existing contacts are updated, not duplicated
Contacts are matched on email, so repeat enquirers get a new deal on their existing record.
How it works
What happens, step by step
Every 10 minutes, ClickRuntime checks Gmail for new lead notification emails from the senders you choose.
It remembers which emails it has handled, so each lead is created once.
AI reads each email and pulls out the person's name, email, phone and what they're interested in.
A contact is created or updated in HubSpot, and a new deal is added and linked to 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
from google.oauth2.credentials import Credentials
from googleapiclient.discovery import build
from clickruntime import on_trigger, credentials, http, state, ai, report_fetched
QUERY = 'from:leads@portal.example newer_than:2d'
SCHEMA = {"type": "object", "properties": {k: {"type": "string"} for k in ["name", "email", "phone", "interest"]}, "required": ["email"]}
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)
seen = set(state.get("seen") or [])
ids = [m["id"] for m in g.users().messages().list(userId="me", q=QUERY).execute().get("messages", []) if m["id"] not in seen]
report_fetched(len(ids))
if not ids:
return {"created": 0}
for mid in ids:
snippet = g.users().messages().get(userId="me", id=mid, format="full").execute()["snippet"]
lead = ai.generate("Extract the lead's details from this email:\n" + snippet[:2000], json_schema=SCHEMA, max_output_tokens=150).json
if lead.get("email"):
c = hs("POST", "/crm/v3/objects/contacts/batch/upsert", json={"inputs": [{"idProperty": "email", "id": lead["email"],
"properties": {"email": lead["email"], "firstname": lead.get("name", ""), "phone": lead.get("phone", "")}}]})["results"][0]
hs("POST", "/crm/v3/objects/deals", json={"properties": {"dealname": f"{lead.get('name')}: {lead.get('interest', '')}"[:100], "dealstage": "appointmentscheduled", "pipeline": "default"},
"associations": [{"to": {"id": c["id"]}, "types": [{"associationCategory": "HUBSPOT_DEFINED", "associationTypeId": 3}]}]})
state.set("seen", (list(seen) + ids)[-500:])
return {"created": len(ids)}FAQ
Common questions
Which emails does it read?
What happens if an email has no email address in it?
Which pipeline and stage do new deals go into?
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 worksDraft 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 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 “Turn lead notification emails into HubSpot contacts and deals” from your assistant
Copy the prompt above, or connect your assistant first. Free plan, no credit card.