agentlyleads docs
Connectors

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.read scope.
  • The target workspace ID (run npx prisma studio to 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

  1. Fetches all products from HubSpot (GET /crm/v3/objects/products).
  2. Upserts each into the agentlyleads Offering table, matching by HubSpot Record ID (stored as externalId), then by SKU.
  3. Prints the created / updated / errored summary.

Field mapping

HubSpot fieldagentlyleads field
namename
hs_skusku
priceprice
hs_cost_of_goods_soldcost
descriptiondescription
hs_recurring_billing_periodbillingPeriod (MONTHLY / YEARLY)
hs_term_in_monthstermMonths
HubSpot Record IDexternalId

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 externalIdsku).
  • Never duplicates a product.

Troubleshooting

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

On this page