Use HubSpot CRM records as evidence for sales, pipeline, and customer analysis. — Claude Skill
A Claude Skill for Claude Code by FunnelEnvy — run /hubspot-crm in Claude·Updated Jun 14, 2026·vmain@1804741
Connects HubSpot contacts, companies, lists, and deal fields to business workflows so teams can pull CRM evidence, check fields, and sync cleanly before analysis.
- Pulls HubSpot contact, company, list, and deal context into analysis workflows.
- Explains which CRM fields are needed before a sales or competitive question can be answered.
- Helps avoid bad analysis caused by missing owner, lifecycle stage, deal reason, or segment data.
- Keeps API and sync limitations visible for operators who maintain the CRM connection.
Teams export HubSpot data and start analysis before checking whether key fields are complete.
Run /hubspot-crm to define the records, fields, filters, and hygiene checks needed before analysis.
Who this is for
What it does
Use HubSpot deal notes and fields to support competitive analysis.
Filter opportunities by segment, competitor, source, or lifecycle stage.
Find missing owners, reasons, stages, or fields that would distort a report.
How it works
Define the business question and the HubSpot records needed to answer it.
Identify required objects, filters, fields, owner data, lifecycle stages, and date ranges.
Pull or paste exported HubSpot evidence into the analysis workflow.
Check for missing, duplicate, or stale fields before using the data.
Return a business-ready readout plus any CRM cleanup needed.
Input options
The sales, pipeline, customer, or competitive question to answer.
Example
Need to analyze competitive losses from HubSpot for Q2. Objects available: deals, companies, contacts. Fields: - dealstage - closedate - competitor_name - closed_lost_reason - amount - owner - company_size - segment Known issue: some deals have competitor_name empty but notes mention LearnPro or GuidePilot. Need: field checklist, filters, export plan, and warnings before using this data in a battlecard refresh.
Use closed-lost deals from Q2 where competitor_name is LearnPro or GuidePilot, plus deals where notes mention those names. Segment by company_size and owner before drawing conclusions.
| Field | Why it matters | Risk if missing | |---|---|---| | competitor_name | Main grouping for battlecard refresh | Losses may be undercounted | | closed_lost_reason | Explains why deals were lost | Output becomes anecdotal | | segment/company_size | Shows which market is affected | Enterprise and SMB patterns get mixed | | amount | Helps prioritize high-value losses | Small deals may dominate the story | | owner | Enables follow-up with seller | Evidence cannot be validated |
Export closed-lost Q2 deals with required fields, then add a notes keyword pass for LearnPro and GuidePilot. Keep the notes extract separate from structured competitor_name so the team can see which findings are inferred.
Do not report exact competitor loss rate until empty competitor_name fields are reviewed. If closed_lost_reason is generic, use call notes or owner follow-up before turning it into battlecard guidance.
Create a CRM cleanup task: require competitor_name and closed_lost_reason for competitive closed-lost deals above $25k ARR.
Metrics this improves
Works with
Want to use HubSpot CRM?
Choose how to get started.
Install and run this skill locally on your computer.
Open a terminal on your computer and paste this command:
This downloads the skill with all its files to your computer:
Add -g at the end to make it available in all your projects.
Start Claude Code, then type the command:
HubSpot CRM Integration
Sync contacts and lists to HubSpot using the REST API.
Environment Variables
HUBSPOT_API_TOKEN="pat-na1-..." # Private App token from HubSpot
Quick Start
import os
import json
from urllib.request import Request, urlopen
from urllib.error import HTTPError
class HubSpotClient:
"""Simple HubSpot API client."""
def __init__(self):
self.token = os.environ.get('HUBSPOT_API_TOKEN')
if not self.token:
raise ValueError("HUBSPOT_API_TOKEN environment variable not set")
self.base_url = "https://api.hubapi.com"
def _request(self, method: str, endpoint: str, data: dict = None) -> dict:
url = f"{self.base_url}{endpoint}"
headers = {
"Authorization": f"Bearer {self.token}",
"Content-Type": "application/json"
}
body = json.dumps(data).encode('utf-8') if data else None
request = Request(url, data=body, headers=headers, method=method)
with urlopen(request, timeout=30) as response:
return json.loads(response.read().decode('utf-8'))
Create Static List
def create_static_list(client, name: str) -> str:
"""Create a static list for contacts. Returns list ID."""
payload = {
"name": name,
"objectTypeId": "0-1", # REQUIRED: 0-1 = contacts
"processingType": "MANUAL"
}
result = client._request("POST", "/crm/v3/lists", payload)
# Response is nested: {"list": {"listId": "..."}}
list_data = result.get("list", result)
list_id = list_data.get("listId")
print(f"✅ Created list: {name} (ID: {list_id})")
return list_id
Search Contact by Email
def search_contact(client, email: str) -> str | None:
"""Find contact by email. Returns contact ID or None."""
payload = {
"filterGroups": [{
"filters": [{
"propertyName": "email",
"operator": "EQ",
"value": email
}]
}],
"properties": ["email"],
"limit": 1
}
result = client._request("POST", "/crm/v3/objects/contacts/search", payload)
results = result.get("results", [])
return results[0]["id"] if results else None
Create Contact
def create_contact(client, email: str, firstname: str = None, lastname: str = None) -> str:
"""Create a new contact with email only (vanilla upload).
Only uses standard HubSpot properties (email, firstname, lastname)
to avoid errors from missing custom properties in the target account.
"""
properties = {"email": email}
if firstname:
properties["firstname"] = firstname
if lastname:
properties["lastname"] = lastname
result = client._request("POST", "/crm/v3/objects/contacts", {"properties": properties})
return result["id"]
Important: Do NOT pass arbitrary CSV columns as properties. HubSpot will reject any property names that don't exist in the target account. Only use standard fields (email, firstname, lastname) unless you've confirmed custom properties exist.
Add Contacts to List
def add_to_list(client, list_id: str, contact_ids: list[str]):
"""Add contacts to a static list. Batches in groups of 100."""
endpoint = f"/crm/v3/lists/{list_id}/memberships/add"
batch_size = 100
total_added = 0
for i in range(0, len(contact_ids), batch_size):
batch = contact_ids[i:i + batch_size]
# IMPORTANT: Payload is a simple array, NOT {"recordIdsToAdd": [...]}
result = client._request("PUT", endpoint, batch)
added = len(result.get("recordsIdsAdded", []))
total_added += added
print(f" Added batch: {added} contacts")
print(f"✅ Added {total_added} total contacts to list")
Full Upload Flow
def upload_users_to_hubspot(emails: list[str], list_name: str) -> str:
"""Upload a list of email addresses to HubSpot."""
client = HubSpotClient()
# Create list
list_id = create_static_list(client, list_name)
# Find or create contacts
contact_ids = []
for email in emails:
contact_id = search_contact(client, email)
if not contact_id:
contact_id = create_contact(client, email)
contact_ids.append(contact_id)
# Add to list
add_to_list(client, list_id, contact_ids)
print(f"\n✅ Complete!")
print(f" List: https://app.hubspot.com/contacts/lists/{list_id}")
return list_id
Usage Example
# Upload at-risk users from analysis
at_risk_emails = [
"[email protected]",
"[email protected]",
"[email protected]"
]
list_id = upload_users_to_hubspot(
emails=at_risk_emails,
list_name="At-Risk Trial Users - Dec 2024"
)
Using the Integration Script
For CSV files, use the provided script:
.venv/bin/python demos/04-trial-to-paid/scripts/hubspot_integration.py \
path/to/users.csv \
"List Name Here"
The CSV must have an email column.
API Gotchas
- List creation requires
objectTypeId: Always include"objectTypeId": "0-1"for contacts - Response is nested: List ID is at
result["list"]["listId"], notresult["listId"] - Add-to-list payload format: Use simple array
["id1", "id2"], NOT{"recordIdsToAdd": [...]} - Contact IDs are strings: Even though they look numeric, treat them as strings
- Batch limit: Add contacts in batches of 100 max
Error Handling
from urllib.error import HTTPError
try:
result = client._request("POST", endpoint, payload)
except HTTPError as e:
error_body = e.read().decode('utf-8')
print(f"HubSpot API error: {e.code}")
print(f" {error_body}")
Getting Your HubSpot Private App Token
- Go to Settings (gear icon) in HubSpot
- Navigate to Integrations > Private Apps
- Click Create a private app
- Give it a name (e.g., "AI Agent Integration")
- Under Scopes, enable:
crm.lists.readcrm.lists.writecrm.objects.contacts.readcrm.objects.contacts.write
- Click Create app and copy the token
- Set as
HUBSPOT_API_TOKENenvironment variable
Reference documents
name: hubspot-crm description: Use when syncing contacts or lists to HubSpot CRM. Automatically uses HUBSPOT_API_TOKEN from environment.
HubSpot CRM Integration
Sync contacts and lists to HubSpot using the REST API.
Environment Variables
HUBSPOT_API_TOKEN="pat-na1-..." # Private App token from HubSpot
Quick Start
import os
import json
from urllib.request import Request, urlopen
from urllib.error import HTTPError
class HubSpotClient:
"""Simple HubSpot API client."""
def __init__(self):
self.token = os.environ.get('HUBSPOT_API_TOKEN')
if not self.token:
raise ValueError("HUBSPOT_API_TOKEN environment variable not set")
self.base_url = "https://api.hubapi.com"
def _request(self, method: str, endpoint: str, data: dict = None) -> dict:
url = f"{self.base_url}{endpoint}"
headers = {
"Authorization": f"Bearer {self.token}",
"Content-Type": "application/json"
}
body = json.dumps(data).encode('utf-8') if data else None
request = Request(url, data=body, headers=headers, method=method)
with urlopen(request, timeout=30) as response:
return json.loads(response.read().decode('utf-8'))
Create Static List
def create_static_list(client, name: str) -> str:
"""Create a static list for contacts. Returns list ID."""
payload = {
"name": name,
"objectTypeId": "0-1", # REQUIRED: 0-1 = contacts
"processingType": "MANUAL"
}
result = client._request("POST", "/crm/v3/lists", payload)
# Response is nested: {"list": {"listId": "..."}}
list_data = result.get("list", result)
list_id = list_data.get("listId")
print(f"✅ Created list: {name} (ID: {list_id})")
return list_id
Search Contact by Email
def search_contact(client, email: str) -> str | None:
"""Find contact by email. Returns contact ID or None."""
payload = {
"filterGroups": [{
"filters": [{
"propertyName": "email",
"operator": "EQ",
"value": email
}]
}],
"properties": ["email"],
"limit": 1
}
result = client._request("POST", "/crm/v3/objects/contacts/search", payload)
results = result.get("results", [])
return results[0]["id"] if results else None
Create Contact
def create_contact(client, email: str, firstname: str = None, lastname: str = None) -> str:
"""Create a new contact with email only (vanilla upload).
Only uses standard HubSpot properties (email, firstname, lastname)
to avoid errors from missing custom properties in the target account.
"""
properties = {"email": email}
if firstname:
properties["firstname"] = firstname
if lastname:
properties["lastname"] = lastname
result = client._request("POST", "/crm/v3/objects/contacts", {"properties": properties})
return result["id"]
Important: Do NOT pass arbitrary CSV columns as properties. HubSpot will reject any property names that don't exist in the target account. Only use standard fields (email, firstname, lastname) unless you've confirmed custom properties exist.
Add Contacts to List
def add_to_list(client, list_id: str, contact_ids: list[str]):
"""Add contacts to a static list. Batches in groups of 100."""
endpoint = f"/crm/v3/lists/{list_id}/memberships/add"
batch_size = 100
total_added = 0
for i in range(0, len(contact_ids), batch_size):
batch = contact_ids[i:i + batch_size]
# IMPORTANT: Payload is a simple array, NOT {"recordIdsToAdd": [...]}
result = client._request("PUT", endpoint, batch)
added = len(result.get("recordsIdsAdded", []))
total_added += added
print(f" Added batch: {added} contacts")
print(f"✅ Added {total_added} total contacts to list")
Full Upload Flow
def upload_users_to_hubspot(emails: list[str], list_name: str) -> str:
"""Upload a list of email addresses to HubSpot."""
client = HubSpotClient()
# Create list
list_id = create_static_list(client, list_name)
# Find or create contacts
contact_ids = []
for email in emails:
contact_id = search_contact(client, email)
if not contact_id:
contact_id = create_contact(client, email)
contact_ids.append(contact_id)
# Add to list
add_to_list(client, list_id, contact_ids)
print(f"\n✅ Complete!")
print(f" List: https://app.hubspot.com/contacts/lists/{list_id}")
return list_id
Usage Example
# Upload at-risk users from analysis
at_risk_emails = [
"[email protected]",
"[email protected]",
"[email protected]"
]
list_id = upload_users_to_hubspot(
emails=at_risk_emails,
list_name="At-Risk Trial Users - Dec 2024"
)
Using the Integration Script
For CSV files, use the provided script:
.venv/bin/python demos/04-trial-to-paid/scripts/hubspot_integration.py \
path/to/users.csv \
"List Name Here"
The CSV must have an email column.
API Gotchas
- List creation requires
objectTypeId: Always include"objectTypeId": "0-1"for contacts - Response is nested: List ID is at
result["list"]["listId"], notresult["listId"] - Add-to-list payload format: Use simple array
["id1", "id2"], NOT{"recordIdsToAdd": [...]} - Contact IDs are strings: Even though they look numeric, treat them as strings
- Batch limit: Add contacts in batches of 100 max
Error Handling
from urllib.error import HTTPError
try:
result = client._request("POST", endpoint, payload)
except HTTPError as e:
error_body = e.read().decode('utf-8')
print(f"HubSpot API error: {e.code}")
print(f" {error_body}")
Getting Your HubSpot Private App Token
- Go to Settings (gear icon) in HubSpot
- Navigate to Integrations > Private Apps
- Click Create a private app
- Give it a name (e.g., "AI Agent Integration")
- Under Scopes, enable:
crm.lists.readcrm.lists.writecrm.objects.contacts.readcrm.objects.contacts.write
- Click Create app and copy the token
- Set as
HUBSPOT_API_TOKENenvironment variable