Assign unowned contacts

From TomGranot/hubspot-admin-skills · View interactive version

Assign unowned contacts is an AI agent skill from the GitHub repository TomGranot/hubspot-admin-skills. Assign an owner to marketing contacts that have no owner. Ensures every marketable contact has accountability for follow-up, proper lead routing, and accurate owner-based reporting.

How to use this skill

Skill file

Assign Unowned Marketing Contacts

Assign an owner to all marketing contacts that currently have no owner. Unowned contacts create gaps in reporting, prevent proper lead routing, and mean no one is accountable for follow-up on marketing-generated responses.

Why This Matters

Marketing contacts without an owner are a blind spot. They receive campaigns but no one sees their responses. They appear in aggregate metrics but not in individual pipeline views. In owner-based dashboards and reports, they simply do not exist. For teams using round-robin or territory-based routing, unowned contacts bypass the entire system.

Prerequisites

Scripts

Script paths are relative to this skill's directory. Run them from your project directory so .env, data/, and reports/ resolve there: prefix each path with wherever this skill is installed (skills/assign-unowned-contacts/ in a clone of the repo).

| Stage | Script | Run with |

|-------|--------|----------|

| Before | CODE0 | uv run scripts/before.py |

| Execute | CODE0 | uv run scripts/execute.py |

| After | CODE0 | uv run scripts/after.py |

before.py counts unowned marketing contacts and lists available owners. execute.py batch-assigns them to HUBSPOT_TARGET_OWNER_ID (set in .env; safety threshold 50,000 — high because owner assignment is fully reversible). after.py verifies the count dropped to zero.

Interview: Gather Requirements

Before executing, collect the following information from the user:

Q1: Who should unowned contacts be assigned to?

Q2: Should we use territory-based routing, round-robin, or a single catch-all owner?

Plan

  1. Identify all marketing contacts with no owner (before state)
  2. Decide on the assignment strategy (catch-all user vs. territory rules)
  3. Execute the bulk assignment
  4. Verify all marketing contacts have owners (after state)

Before

Create the Unowned Marketing Contacts List

  1. Go to Contacts > Lists > Create list
  2. Select Active list
  3. Name: CLEANUP: Unowned Marketing Contacts
  4. Add filters:
  1. Save the list and note the count

Script Approach

Run uv run scripts/before.py. The core query:

resp = requests.post(f"{BASE}/crm/v3/objects/contacts/search", headers=HEADERS, json={
    "filterGroups": [{"filters": [
        {"propertyName": "hs_marketable_status", "operator": "EQ", "value": "true"},
        {"propertyName": "hubspot_owner_id", "operator": "NOT_HAS_PROPERTY"},
    ]}],
    "limit": 1,
})
print(f"Unowned marketing contacts: {resp.json()['total']}")

Execute

Assignment Strategy Decision

Choose one of these approaches (requires team lead approval):

Option A: Catch-All User (Simplest)

Option B: Territory/Region Rules

Option C: Round-Robin

Bulk Assignment via UI

  1. Open the unowned marketing contacts list
  2. Click the checkbox in the table header to select all contacts on the page
  3. Click Select all X contacts to select across all pages
  4. Click Edit in the toolbar
  5. In the property dropdown, select Contact owner
  6. Search for and select the chosen owner
  7. Click Update
  8. Confirm the bulk edit
  9. For large numbers (5,000+), HubSpot processes in batches. This may take several minutes.

Bulk Assignment via API

For the catch-all strategy, this is fully scripted: set HUBSPOT_TARGET_OWNER_ID in .env (run before.py to see available owner IDs) and run uv run scripts/execute.py.

# What execute.py does:
# 1. POST /crm/v3/objects/contacts/search — unowned marketing contacts (paginated)
# 2. Build batch payload: {"inputs": [{"id": ..., "properties": {"hubspot_owner_id": OWNER_ID}}]}
# 3. POST /crm/v3/objects/contacts/batch/update in batches of 100

# For territory-based routing (extend the script):
# 1. Search for unowned marketing contacts with country/state/industry properties
# 2. Map each contact to an owner via your territory matrix
# 3. Batch update with the appropriate owner per contact

API notes:

After

Wait 5-10 minutes for HubSpot to finish processing, then verify: uv run scripts/after.py (re-runs the before-state query and compares against the baseline; the count should be 0).

Verification checklist:

  1. The unowned marketing contacts list shows 0 contacts
  2. Re-run the before-state script — count should be 0
  3. Spot-check 5-10 contacts that were previously unowned — confirm they show the assigned owner
  4. Check owner-based dashboards/reports to confirm the previously invisible contacts now appear

Rollback

Key Technical Learnings

Use this skill with your AI agent: Open on Skill Issue to copy, download, or add to your library. Works with Claude, ChatGPT, Gemini, Cursor, Windsurf and more.