HubSpot CLI Connector
The HubSpot CLI connector is a Node.js script that pulls products from HubSpot into an agentlyleads workspace. It's the operational counterpart to the UI connector — built for developers and administrators who prefer a terminal workflow or want to automate the import from a CI/CD pipeline.
Want a no-terminal option? The HubSpot UI Connector runs the same import from Settings → Integrations.
Before you begin
- Access to the agentlyleads server environment (local dev or SSH).
- A HubSpot Private App token with the
crm.objects.products.readscope. - The target workspace ID (run
npx prisma studioto find it).
Import products
Set your HubSpot token
Export your Private App access token as HUBSPOT_TOKEN:
export HUBSPOT_TOKEN="pat-na1-xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx"Run the import
Pass the target workspace with --workspace:
npm run products:import -- --workspace <workspaceId>You can also set the workspace via the WORKSPACE_ID environment variable instead of the flag. If the database has exactly one workspace, omit both and the script picks it automatically. With multiple workspaces and neither provided, it exits and lists the available IDs.
Read the summary
The script prints a one-line summary of what changed:
Products import: {"created":42,"updated":8,"errors":0}Rows that fail validation are counted in errors and logged individually — the rest of the batch still succeeds.
What it does
- Fetches all products from HubSpot (
GET /crm/v3/objects/products). - Upserts each into the agentlyleads
Offeringtable, matching by HubSpot Record ID (stored asexternalId), then by SKU. - Prints the created / updated / errored summary.
Field mapping
| HubSpot field | agentlyleads field |
|---|---|
name | name |
hs_sku | sku |
price | price |
hs_cost_of_goods_sold | cost |
description | description |
hs_recurring_billing_period | billingPeriod (MONTHLY / YEARLY) |
hs_term_in_months | termMonths |
| HubSpot Record ID | externalId |
Products with a recurring billing period are created with type: SUBSCRIPTION.
HubSpot has no native product category, so imported products are uncategorized. Assign categories afterward in Offerings.
Idempotency
The import is fully idempotent. Run it as often as you like — for example, a nightly cron to keep the catalog in sync:
- Creates products that don't exist yet.
- Updates existing products (matched by
externalId→sku). - Never duplicates a product.
Troubleshooting
| Error | Cause |
|---|---|
HUBSPOT_TOKEN is not set. | The environment variable is missing. |
Pass --workspace <id>. Found N workspaces: … | Multiple workspaces exist — specify --workspace (or WORKSPACE_ID). |
That HubSpot token didn't work. | The token is invalid or missing the crm.objects.products.read scope. |
HubSpot UI Connector
Link HubSpot from Settings → Integrations and sync products, contacts, and companies into your workspace — no terminal required.
MCP Connector
Connect ChatGPT or Claude to your agentlyleads CRM via the Model Context Protocol (MCP) — query contacts, log communications, manage tasks, and more from any AI assistant.