HarborCRM Task Solver
Solve HarborCRM data-processing tasks by fetching the answer template first, then all relevant API data in parallel, then cross-referencing, classifying, and normalizing to produce a single sorted JSON output.
Core Workflow
- Read
input/payloads/answer_template.json — let it define every field and value constraint.
- Read
input/prompt.txt — extract the event_id, show_id, or batch_id and determine the task type.
- Fetch all API endpoints listed in the prompt in parallel, using the base URL provided by the runner.
- Fetch
GET /api/policies — it holds configuration rules for thresholds, amounts, and qualification.
- Process the data following the task-type rules below.
- Produce one JSON object matching the template exactly; no prose outside the JSON.
API Reference
See references/api_endpoints.md for all endpoint shapes, URL patterns, and field definitions.
Domain Rules
See references/domain_model.md for entity relationships, classification logic, matching rules, deduplication, normalization, sorting conventions, and CRM action counting.
Contact Normalization
Use scripts/normalize.py to normalize emails (lowercase, trim) and phones (digits only) consistently:
echo '{"email":" User@Example.Com ","phone":"+1 (415) 555-0188"}' | python scripts/normalize.py
Or import the functions directly in your own code.
Task Type 1: Event CRM Handoff
Triggered when the prompt references an event_id, orders, badges, invoices, campaign_members, and expects sponsor statuses plus qualified lead accounts.
Data to Fetch (all in parallel)
GET /api/events/{event_id}
GET /api/events/{event_id}/orders
GET /api/events/{event_id}/badges
GET /api/finance/invoices?event_id={event_id}
GET /api/crm/accounts
GET /api/crm/contacts
GET /api/crm/opportunities
GET /api/crm/campaign_members?event_id={event_id}
GET /api/policies
Processing Steps
Build sponsor index from orders. Mark orders with status cancelled as inactive — they still own their attendees but do not appear in sponsor_statuses.
Classify sponsor status by cross-referencing each active order with its invoice (match by invoice_id):
- Order
confirmed + invoice fully paid (paid_amount == total_amount) → paid_deferred
- Order
confirmed + invoice not fully paid → open_invoice
- Order
pending or draft (any invoice state or none) → proposal_only
Classify every badge into one of four categories:
- Company matches any sponsor account (including cancelled sponsors) →
sponsor_attendee
badge_type is neither business nor sponsor → non_business_badge
- Company matches a CRM account with
status = disqualified → existing_disqualified
- Everything else →
qualified_non_sponsor_lead
Build qualified lead accounts from qualified_non_sponsor_lead badges:
- Group by company. Match company to CRM account by name (case-insensitive, trimmed).
- Match found →
crm_account_action: update_existing, with the matched account_id.
- No match →
crm_account_action: create_account, account_id: null.
crm_contact_action: create_contact (event handoff always creates contacts for new leads).
campaign_member_action: add_campaign_member.
- Primary contact: the first person from that company among qualified badges. Normalize their email and phone.
opportunity_amount: the event's lead_opportunity_amount (from the event detail).
Compute follow-up dates:
lead_due_date = event.end_date + event.lead_followup_days calendar days, formatted YYYY-MM-DD.
sponsor_finance_due_date = event.end_date + event.sponsor_followup_days calendar days, formatted YYYY-MM-DD.
Counts:
lead_task_count = number of qualified lead accounts.
sponsor_finance_task_count = number of sponsors with status open_invoice or proposal_only.
sponsor_finance_accounts = list of account names for those sponsors, sorted ascending.
CRM action counts: sum create_account / update_existing / create_contact / update_existing / add_campaign_member across all handoff records.
Excluded records: one entry per excluded badge with company_name, contact_name, and reason.
Sponsor revenue totals: sum package_amount by status; open_invoice_balance = sum of open_balance for open_invoice sponsors.
Task Type 2: Trade Show Prospecting
Triggered when the prompt references a show_id, exhibitors, meeting_interest, platform enums (AUV, ROV, Underwater Camera), and expects ranked qualified leads.
Data to Fetch (all in parallel)
GET /api/tradeshows/{show_id}
GET /api/tradeshows/{show_id}/exhibitors
GET /api/tradeshows/{show_id}/meeting_interest
GET /api/crm/accounts
GET /api/crm/contacts
GET /api/policies
Processing Steps
Read policy configuration: prospecting_platforms (list of qualifying platform strings), priority tier score thresholds (typically tier A: 90, tier B: 80), and opportunity amounts per tier (common values: A=120000, B=90000, C=50000).
Join meeting interest to exhibitors by company_id. An exhibitor without a meeting-interest record has requested_demo: false and interest_score: 0.
Qualify exhibitors:
relationship_type must be manufacturer.
- At least one platform in the exhibitor's
platforms list must appear in the policy's prospecting_platforms.
- All others go to excluded list.
Map exclusion reasons from relationship_type:
distributor → distributor_only
service_provider → service_only
sensor_vendor → sensor_vendor_only (or sensor_only — check the template/policies for which form is required)
research → research_only
Assign priority tier using meeting interest and policy thresholds:
A: requested_demo is true AND interest_score >= tier A threshold (typically 90).
B: requested_demo is true AND interest_score >= tier B threshold (typically 80).
C: all other qualified exhibitors.
Map opportunity amounts from the policy tier definitions.
CRM matching: match company_id to CRM accounts by company_id. Set crm_action to update_existing if found, create_account if not. Set crm_account_id to the matched account's account_id or null. Excluded exhibitors get crm_action: no_import.
Rank qualified leads (highest priority first):
requested_demo = true before false.
interest_score descending.
- Platform count (number of qualifying platforms) descending.
company_name ascending (alphabetical tiebreaker).
Platform list ordering within each item: AUV, ROV, Underwater Camera (the enum order from the template).
Compute aggregate counts: qualified total, per-platform counts, per-tier counts, excluded total.
Task Type 3: Import Batch Preparation
Triggered when the prompt references a batch_id, raw_contacts, suppression, and expects clean_contacts with crm_action decisions.
Data to Fetch (all in parallel)
GET /api/import_batches/{batch_id}
GET /api/import_batches/{batch_id}/raw_contacts
GET /api/import_batches/{batch_id}/suppression
GET /api/crm/accounts
GET /api/crm/contacts
GET /api/policies
Processing Steps
Normalize all raw contacts: run every email and phone through the normalization functions (see scripts/normalize.py).
Build suppression set: collect all normalized emails and normalized phones from the suppression endpoint entries.
Deduplicate: group raw contact rows by email:{normalized_email} (skip rows with empty normalized email from grouping). Within each group:
- Winner: row with the most recent
captured_at timestamp.
- Tiebreaker: lowest
row_id alphanumerically.
- All non-winner rows are marked for removal with reason
duplicate.
Apply removals (three reasons):
duplicate: non-winner rows from the dedup step.
missing_contact: rows where contact_name is empty, null, or only whitespace.
suppressed: rows whose normalized email or normalized phone appears in the suppression set.
A single row can be removed for only one reason — check in order and keep the first match.
Clean contacts: the surviving rows after removals.
clean_contact_id = the winning source_row_id (same as row_id for non-duplicate survivors).
- Preserve normalized email and phone from the winning row.
CRM cross-reference for each clean contact:
- Match account by
company_name (case-insensitive, trimmed comparison).
- Match found and account status is
active → crm_action: update_existing, existing_account_id populated.
- No match →
crm_action: create_account, existing_account_id: null.
- Match contact by normalized email within the matched account. If not found, try normalized phone. Populate
existing_contact_id if a match is found.
Import action totals:
create_account: clean contacts with crm_action = create_account.
update_existing: clean contacts with crm_action = update_existing.
no_import: rows removed for duplicate or missing_contact (not suppressed).
suppress: rows removed for suppressed.
campaign_member_import_count = number of clean contacts.
Sort: clean_contacts by clean_contact_id ascending; duplicate_keys by key ascending; removed_rows by row_id ascending.
Key Output Rules
- Read the answer template first. Use its field names, enum values, and sorting instructions exactly as specified. If a template sorting rule differs from the conventions in the domain model, follow the template.
- All USD amounts: integers.
- All dates: YYYY-MM-DD format.
- All counts: integers.
- Empty phone/email: use
"" (empty string), not null, unless the template specifically requires null.
- Do not add fields not declared in the answer template.
- Return one JSON object only, with no explanatory prose outside it.
1---2name: harborcrm-task-solver3description: "HarborCRM API task solver for event CRM handoff, trade show prospecting, and import batch preparation. Use when the task involves: (1) Fetching data from HarborCRM public API endpoints (events, trade shows, CRM, finance, imports, policies), (2) Cross-referencing CRM accounts, contacts, opportunities, campaign members, sponsor orders, invoices, badges, exhibitors, or import batches, (3) Producing a JSON output that conforms to a provided answer template, (4) Post-event CRM reconciliation or lead handoff, (5) Trade show exhibitor prospecting and lead qualification, (6) Import batch deduplication, suppression, and CRM import preparation. Trigger on mentions of HarborCRM, event_id, show_id, batch_id, sponsor_statuses, qualified_lead_accounts, campaign_member_actions, badge_decisions, crm_action, clean_contacts, ranked_leads, or answer_template.json with HarborCRM data."4license: MIT5compatibility: deepagents-code6metadata:7 source: https://skillmd.com/skills/prism-shadow/harborcrm-task-solver8---910# HarborCRM Task Solver1112Solve HarborCRM data-processing tasks by fetching the answer template first, then all relevant API data in parallel, then cross-referencing, classifying, and normalizing to produce a single sorted JSON output.1314## Core Workflow15161. Read `input/payloads/answer_template.json` — let it define every field and value constraint.172. Read `input/prompt.txt` — extract the event_id, show_id, or batch_id and determine the task type.183. Fetch all API endpoints listed in the prompt in parallel, using the base URL provided by the runner.194. Fetch `GET /api/policies` — it holds configuration rules for thresholds, amounts, and qualification.205. Process the data following the task-type rules below.216. Produce one JSON object matching the template exactly; no prose outside the JSON.2223## API Reference2425See [references/api_endpoints.md](references/api_endpoints.md) for all endpoint shapes, URL patterns, and field definitions.2627## Domain Rules2829See [references/domain_model.md](references/domain_model.md) for entity relationships, classification logic, matching rules, deduplication, normalization, sorting conventions, and CRM action counting.3031## Contact Normalization3233Use [scripts/normalize.py](scripts/normalize.py) to normalize emails (lowercase, trim) and phones (digits only) consistently:3435```36echo '{"email":" User@Example.Com ","phone":"+1 (415) 555-0188"}' | python scripts/normalize.py37```3839Or import the functions directly in your own code.4041## Task Type 1: Event CRM Handoff4243Triggered when the prompt references an `event_id`, `orders`, `badges`, `invoices`, `campaign_members`, and expects sponsor statuses plus qualified lead accounts.4445### Data to Fetch (all in parallel)4647- `GET /api/events/{event_id}`48- `GET /api/events/{event_id}/orders`49- `GET /api/events/{event_id}/badges`50- `GET /api/finance/invoices?event_id={event_id}`51- `GET /api/crm/accounts`52- `GET /api/crm/contacts`53- `GET /api/crm/opportunities`54- `GET /api/crm/campaign_members?event_id={event_id}`55- `GET /api/policies`5657### Processing Steps58591. **Build sponsor index** from orders. Mark orders with status `cancelled` as inactive — they still own their attendees but do not appear in `sponsor_statuses`.60612. **Classify sponsor status** by cross-referencing each active order with its invoice (match by `invoice_id`):62 - Order `confirmed` + invoice fully paid (`paid_amount == total_amount`) → `paid_deferred`63 - Order `confirmed` + invoice not fully paid → `open_invoice`64 - Order `pending` or `draft` (any invoice state or none) → `proposal_only`65663. **Classify every badge** into one of four categories:67 - Company matches any sponsor account (including cancelled sponsors) → `sponsor_attendee`68 - `badge_type` is neither `business` nor `sponsor` → `non_business_badge`69 - Company matches a CRM account with `status` = `disqualified` → `existing_disqualified`70 - Everything else → `qualified_non_sponsor_lead`71724. **Build qualified lead accounts** from qualified_non_sponsor_lead badges:73 - Group by company. Match company to CRM account by name (case-insensitive, trimmed).74 - Match found → `crm_account_action`: `update_existing`, with the matched `account_id`.75 - No match → `crm_account_action`: `create_account`, `account_id`: null.76 - `crm_contact_action`: `create_contact` (event handoff always creates contacts for new leads).77 - `campaign_member_action`: `add_campaign_member`.78 - Primary contact: the first person from that company among qualified badges. Normalize their email and phone.79 - `opportunity_amount`: the event's `lead_opportunity_amount` (from the event detail).80815. **Compute follow-up dates**:82 - `lead_due_date` = `event.end_date` + `event.lead_followup_days` calendar days, formatted YYYY-MM-DD.83 - `sponsor_finance_due_date` = `event.end_date` + `event.sponsor_followup_days` calendar days, formatted YYYY-MM-DD.84856. **Counts**:86 - `lead_task_count` = number of qualified lead accounts.87 - `sponsor_finance_task_count` = number of sponsors with status `open_invoice` or `proposal_only`.88 - `sponsor_finance_accounts` = list of account names for those sponsors, sorted ascending.89907. **CRM action counts**: sum `create_account` / `update_existing` / `create_contact` / `update_existing` / `add_campaign_member` across all handoff records.91928. **Excluded records**: one entry per excluded badge with `company_name`, `contact_name`, and reason.93949. **Sponsor revenue totals**: sum `package_amount` by status; `open_invoice_balance` = sum of `open_balance` for open_invoice sponsors.9596## Task Type 2: Trade Show Prospecting9798Triggered when the prompt references a `show_id`, `exhibitors`, `meeting_interest`, platform enums (`AUV`, `ROV`, `Underwater Camera`), and expects ranked qualified leads.99100### Data to Fetch (all in parallel)101102- `GET /api/tradeshows/{show_id}`103- `GET /api/tradeshows/{show_id}/exhibitors`104- `GET /api/tradeshows/{show_id}/meeting_interest`105- `GET /api/crm/accounts`106- `GET /api/crm/contacts`107- `GET /api/policies`108109### Processing Steps1101111. **Read policy configuration**: `prospecting_platforms` (list of qualifying platform strings), priority tier score thresholds (typically tier A: 90, tier B: 80), and opportunity amounts per tier (common values: A=120000, B=90000, C=50000).1121132. **Join meeting interest to exhibitors** by `company_id`. An exhibitor without a meeting-interest record has `requested_demo`: false and `interest_score`: 0.1141153. **Qualify exhibitors**:116 - `relationship_type` must be `manufacturer`.117 - At least one platform in the exhibitor's `platforms` list must appear in the policy's `prospecting_platforms`.118 - All others go to excluded list.1191204. **Map exclusion reasons** from `relationship_type`:121 - `distributor` → `distributor_only`122 - `service_provider` → `service_only`123 - `sensor_vendor` → `sensor_vendor_only` (or `sensor_only` — check the template/policies for which form is required)124 - `research` → `research_only`1251265. **Assign priority tier** using meeting interest and policy thresholds:127 - `A`: `requested_demo` is true AND `interest_score` >= tier A threshold (typically 90).128 - `B`: `requested_demo` is true AND `interest_score` >= tier B threshold (typically 80).129 - `C`: all other qualified exhibitors.1301316. **Map opportunity amounts** from the policy tier definitions.1321337. **CRM matching**: match `company_id` to CRM accounts by `company_id`. Set `crm_action` to `update_existing` if found, `create_account` if not. Set `crm_account_id` to the matched account's `account_id` or null. Excluded exhibitors get `crm_action`: `no_import`.1341358. **Rank qualified leads** (highest priority first):136 1. `requested_demo` = true before false.137 2. `interest_score` descending.138 3. Platform count (number of qualifying platforms) descending.139 4. `company_name` ascending (alphabetical tiebreaker).1401419. **Platform list ordering** within each item: `AUV`, `ROV`, `Underwater Camera` (the enum order from the template).14214310. **Compute aggregate counts**: qualified total, per-platform counts, per-tier counts, excluded total.144145## Task Type 3: Import Batch Preparation146147Triggered when the prompt references a `batch_id`, `raw_contacts`, `suppression`, and expects `clean_contacts` with `crm_action` decisions.148149### Data to Fetch (all in parallel)150151- `GET /api/import_batches/{batch_id}`152- `GET /api/import_batches/{batch_id}/raw_contacts`153- `GET /api/import_batches/{batch_id}/suppression`154- `GET /api/crm/accounts`155- `GET /api/crm/contacts`156- `GET /api/policies`157158### Processing Steps1591601. **Normalize all raw contacts**: run every email and phone through the normalization functions (see [scripts/normalize.py](scripts/normalize.py)).1611622. **Build suppression set**: collect all normalized emails and normalized phones from the suppression endpoint entries.1631643. **Deduplicate**: group raw contact rows by `email:{normalized_email}` (skip rows with empty normalized email from grouping). Within each group:165 - **Winner**: row with the most recent `captured_at` timestamp.166 - **Tiebreaker**: lowest `row_id` alphanumerically.167 - All non-winner rows are marked for removal with reason `duplicate`.1681694. **Apply removals** (three reasons):170 - `duplicate`: non-winner rows from the dedup step.171 - `missing_contact`: rows where `contact_name` is empty, null, or only whitespace.172 - `suppressed`: rows whose normalized email or normalized phone appears in the suppression set.173 A single row can be removed for only one reason — check in order and keep the first match.1741755. **Clean contacts**: the surviving rows after removals.176 - `clean_contact_id` = the winning `source_row_id` (same as `row_id` for non-duplicate survivors).177 - Preserve normalized email and phone from the winning row.1781796. **CRM cross-reference** for each clean contact:180 - Match account by `company_name` (case-insensitive, trimmed comparison).181 - Match found and account status is `active` → `crm_action`: `update_existing`, `existing_account_id` populated.182 - No match → `crm_action`: `create_account`, `existing_account_id`: null.183 - Match contact by normalized email within the matched account. If not found, try normalized phone. Populate `existing_contact_id` if a match is found.1841857. **Import action totals**:186 - `create_account`: clean contacts with `crm_action` = `create_account`.187 - `update_existing`: clean contacts with `crm_action` = `update_existing`.188 - `no_import`: rows removed for `duplicate` or `missing_contact` (not suppressed).189 - `suppress`: rows removed for `suppressed`.1901918. **campaign_member_import_count** = number of clean contacts.1921939. **Sort**: clean_contacts by `clean_contact_id` ascending; duplicate_keys by `key` ascending; removed_rows by `row_id` ascending.194195## Key Output Rules196197- **Read the answer template first.** Use its field names, enum values, and sorting instructions exactly as specified. If a template sorting rule differs from the conventions in the domain model, follow the template.198- **All USD amounts**: integers.199- **All dates**: YYYY-MM-DD format.200- **All counts**: integers.201- **Empty phone/email**: use `""` (empty string), not null, unless the template specifically requires null.202- **Do not add fields** not declared in the answer template.203- **Return one JSON object only**, with no explanatory prose outside it.