# Send new leads to HubSpot automatically, set up from your AI assistant

Source: https://clickruntime.com/use-cases/form-leads-to-crm

> Your assistant builds an automation that receives each lead from your form, creates or updates the HubSpot contact, adds a note with the message, and tells sales in Slack when it's worth a call.

## Can ChatGPT or Claude add new leads to HubSpot automatically?

An assistant can create a HubSpot contact while you're chatting, but it can't catch leads as they arrive at 2 a.m. With ClickRuntime, the assistant sets up an automation with a trigger link for your form. Each lead creates or updates the HubSpot contact by email, with the message added as a note, without anyone opening a chat.

### Why the assistant can't do this on its own

- Leads arrive when you aren't chatting. Something has to be listening at a URL all the time.
- Your HubSpot key has to live somewhere safe. ClickRuntime keeps it as a secret in the ClickRuntime dashboard, and the chat never sees it.
- Duplicates need a lookup first. The script searches HubSpot by email before creating anything, which a one-off chat message can't guarantee every time.

## Set it up from your AI assistant

Prompt to copy:

> Create a ClickRuntime automation: when my website form posts a lead (name, email, company, message), create or update the contact in HubSpot by email, set lifecycle stage to lead, and add the message as a note on the contact.

1. **Connect ClickRuntime to your assistant.** Add ClickRuntime as a connector (MCP server) in ChatGPT, Claude, Cursor or another MCP client, using https://clickruntime.com/api/mcp. You sign in with Google or email; there is no API key to copy. This is done once per assistant.
2. **Paste the prompt.** Start a new chat and paste: “Create a ClickRuntime automation: when my website form posts a lead (name, email, company, message), create or update the contact in HubSpot by email, set lifecycle stage to lead, and add the message as a note on the contact.” Change the details (times, channels, addresses) to yours.
3. **Read the draft.** The assistant restates what will happen, asks for anything missing, such as your timezone or which channel to post to, and saves a draft automation. A draft never runs on its own, so nothing happens until you agree.
4. **Connect accounts and save keys.** The assistant asks you to create a HubSpot private app with the contacts and notes scopes and save its token as HUBSPOT_TOKEN in the ClickRuntime dashboard. It gives you the trigger link to set as your form's webhook URL, plus a shared secret so the link only accepts your form.
5. **Test it.** The assistant sends a test lead to the trigger link with an address like test+lead@yourcompany.com, then checks HubSpot shows the contact with the note. You can delete the test contact afterwards.
6. **Turn it on.** The assistant tells you what will run, when, and which services it will contact, then asks your permission to turn it on. From then on it runs on ClickRuntime's servers, and you can close the chat.
7. **Check it in the ClickRuntime dashboard.** Each lead appears as an incoming event with the run that handled it and its result, such as “created 123456” or “updated 123456”. Failed runs keep the event, so after a fix you replay the lead instead of losing it.

Connector setup for each assistant: https://clickruntime.com/assistants

## What the assistant writes

`lead_to_hubspot.py`

```python
from clickruntime import on_event, credentials, http, state, log

API = "https://api.hubapi.com"

def hs(method, path, token, **kw):
    r = http.request(method, API + path, headers={"Authorization": "Bearer " + token}, **kw)
    r.raise_for_status()
    return r.json() if r.content else {}

@on_event
def handle(event):
    if not event.is_verified:
        return {"skipped": "not verified"}
    if state.get("lead:" + event.event_id):
        return {"skipped": "duplicate delivery"}

    lead = event.json or {}
    email = (lead.get("email") or "").strip().lower()
    if not email:
        return {"skipped": "no email"}
    token = credentials.secret("HUBSPOT_TOKEN")

    found = hs("POST", "/crm/v3/objects/contacts/search", token, json={
        "filterGroups": [{"filters": [{"propertyName": "email", "operator": "EQ", "value": email}]}],
        "limit": 1,
    })["results"]
    first, _, last = (lead.get("name") or "").partition(" ")
    props = {"email": email, "firstname": first, "lastname": last, "company": lead.get("company", "")}
    if found:
        contact_id = found[0]["id"]
        hs("PATCH", "/crm/v3/objects/contacts/" + contact_id, token, json={"properties": props})
        action = "updated"
    else:
        props["lifecyclestage"] = "lead"
        contact_id = hs("POST", "/crm/v3/objects/contacts", token, json={"properties": props})["id"]
        action = "created"

    if lead.get("message"):
        hs("POST", "/crm/v3/objects/notes", token, json={
            "properties": {"hs_note_body": lead["message"][:5000], "hs_timestamp": event.received_at},
            "associations": [{"to": {"id": contact_id},
                              "types": [{"associationCategory": "HUBSPOT_DEFINED", "associationTypeId": 202}]}],
        })

    state.set("lead:" + event.event_id, contact_id)
    log.info("Lead handled", {"action": action, "contact": contact_id})
    return {"action": action, "contact": contact_id}
```

- The trigger link checks a shared HMAC secret before the script runs, so `event.is_verified` is true only for your form.
- Search by email first, then update or create: one contact per person, however many times they fill in the form.
- HubSpot's v3 CRM API is called directly over HTTPS; no extra package is needed.

## Trigger link, not a schedule

Use the trigger link when your form or website can send a webhook. Leads reach HubSpot in seconds.

If leads land somewhere without webhooks (a shared inbox or a spreadsheet), use a schedule that checks every 15 minutes and remembers the last lead it handled.

## Limits

- Each lead is one run.
- HubSpot private app tokens are limited to the scopes you give them; add the notes scope or the note step fails with 403.
- HubSpot's own API rate limits apply; a single lead uses three or four calls.

## Troubleshooting

### Runs fail with 401 from HubSpot.

The token was rotated or mistyped. Save the new one as HUBSPOT_TOKEN in the ClickRuntime dashboard and replay the failed events.

### Notes don't show on the contact.

The association is missing or the token lacks the notes scope. Ask your assistant to check the run log; it compares the call with HubSpot's API docs.

### Every event is skipped as not verified.

The form isn't sending the signature header the trigger link expects. Ask the assistant to show the trigger link's signature settings and match them in your form tool.

## Related

- [HubSpot automations](https://clickruntime.com/apps/hubspot)
- [Typeform automations](https://clickruntime.com/apps/typeform)
- [Slack automations](https://clickruntime.com/apps/slack)
- [Salesforce automations](https://clickruntime.com/apps/salesforce)
- [Pipedrive automations](https://clickruntime.com/apps/pipedrive)
- [data-checks-on-new-hubspot-contacts-and-companies](https://clickruntime.com/templates/data-checks-on-new-hubspot-contacts-and-companies)
- [weekly-hubspot-lead-and-revenue-report-in-slack](https://clickruntime.com/templates/weekly-hubspot-lead-and-revenue-report-in-slack)
- [Form submissions to Google Sheets](https://clickruntime.com/use-cases/form-to-google-sheets)
- [Webhook automation](https://clickruntime.com/use-cases/webhook-automation)
- [AI triage and summaries](https://clickruntime.com/use-cases/ai-classify-and-summarise)
- [Zapier alternative](https://clickruntime.com/alternatives/zapier)
- [Make alternative](https://clickruntime.com/alternatives/make)
- [Docs: trigger-links](https://clickruntime.com/docs/trigger-links)
- [Docs: connections-and-secrets](https://clickruntime.com/docs/connections-and-secrets)

## Extend it: what you can add next

The first version is rarely the last. Because the automation is a Python script with memory, AI and any API available, you grow it by asking your assistant for the change. Each change is a new version, and a failed deploy never replaces the working one.

- **Score each lead against your ideal customer and set a HubSpot property** (Built-in AI)
  Prompt: "Change my website leads to HubSpot automation so it scores each lead 1 to 10 against our ideal customer (B2B SaaS, 20–200 staff) and saves the score on the contact."
- **Alert #sales in Slack for leads scoring 8 or more** (Any app or API)
  Prompt: "Add to my website leads to HubSpot automation: when a lead's score is 8 or more, post the name, company and message to #sales in Slack."
- **Summarise long messages into a one-line note title** (Built-in AI)
  Prompt: "Change my website leads to HubSpot automation so the note starts with a one-line summary of the message, followed by the full text."
- **Assign the contact owner by country or company size** (Multi-step logic)
  Prompt: "Change my website leads to HubSpot automation so it sets the contact owner to Maya for UK leads and to Sam for everyone else."
- **Count leads per day and email you if a day has none** (Memory between runs)
  Prompt: "Add to my website leads to HubSpot automation: count leads per day, and email me at 18:00 if no lead arrived that day, in case the form broke."
- **A Monday summary of last week's leads by source** (Schedules)
  Prompt: "Add to my website leads to HubSpot automation: every Monday at 8, email me how many leads came in last week and from which pages."
- **Send each new lead a welcome email through your email service** (Any app or API)
  Prompt: "Add to my website leads to HubSpot automation: send new contacts a welcome email through Resend from hello@ourcompany.com."

## Questions

### Can ChatGPT add leads to HubSpot automatically?

With ClickRuntime connected, yes. ChatGPT sets up an automation with a trigger link; your form sends each lead there and the script creates or updates the HubSpot contact.

### Will it create duplicate contacts?

No. The script searches HubSpot by email first and updates the existing contact when there is one. Repeated deliveries of the same event are skipped.

### Does it work with Salesforce or Pipedrive?

Yes. Ask for that CRM instead; the assistant uses its API with a key or OAuth connection you add in the ClickRuntime dashboard.

### Where does the HubSpot token go?

Into the ClickRuntime dashboard as a secret. It never goes into the chat and is masked in logs.

### Can it qualify leads with AI?

Yes. The built-in AI can score or label each lead, no API key needed, including on the free plan. See the Extend it list.
