Skip to content

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.

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

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

  1. Every 10 minutes, ClickRuntime checks your Gmail inbox for new emails.

  2. It looks up each sender in HubSpot and skips anyone who isn't a contact.

  3. AI writes a reply using the email and the customer's HubSpot details.

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

RunsEvery 10 minutes
Draft email replies using the customer's HubSpot recordtoday, 9:00Succeeded
Slack · #inboxReply draft ready for Contoso Retail: Adding five more seats before renewal Draft mentions their Growth plan and the 1 March renewal date.

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.
ai_email_replies_grounded_in_hubspot_data.pyexample
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?
New emails in your inbox from senders who exist as contacts in HubSpot. You can narrow it further, for example to a label or to customers only.
What HubSpot details does it use?
The contact's name, company, lifecycle stage and any properties you choose, such as plan, renewal date or account manager notes.
Does it read the whole email thread?
It reads the latest message, trimmed to the useful part, which keeps replies focused and costs fewer AI tokens.
What permissions does it need?
Gmail gmail.readonly, gmail.compose; HubSpot contacts read. 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 “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.