{
  "$schema": "../workflow-recipe.schema.json",
  "format": "revenanas.workflow-recipe/v1",
  "slug": "hubspot-clay-crm-enrichment",
  "title": "How to enrich missing HubSpot company data in Clay",
  "job": "Fill approved gaps in HubSpot company records through conditional Clay enrichment without overwriting trusted CRM values.",
  "tools": ["HubSpot", "Clay"],
  "service": {"name": "The Data Foundation", "url": "https://www.revenanas.com/services/the-data-foundation"},
  "importability": {"clay": "manual-build", "notes": "Use this recipe as the build specification. Publish a tested Clay table link before changing the status to public-template.", "template_url": null},
  "inputs": [
    {"name": "hubspot_company_id", "type": "string", "required": true, "description": "Stable CRM record ID."},
    {"name": "company_domain", "type": "domain", "required": true, "description": "Primary enrichment key."},
    {"name": "current_company_fields", "type": "object", "required": true, "description": "The CRM values used by the missing-field guards."}
  ],
  "outputs": [
    {"name": "employee_count", "type": "integer", "required": false, "description": "Verified employee estimate when the CRM field was empty."},
    {"name": "industry", "type": "string", "required": false, "description": "Normalised industry mapped to the CRM picklist."},
    {"name": "company_linkedin_url", "type": "url", "required": false, "description": "Canonical LinkedIn company URL."},
    {"name": "enrichment_status", "type": "enum", "required": true, "description": "updated, no_change, held, or error."}
  ],
  "steps": [
    {"id": "01-source", "action": "Import the target HubSpot company list", "purpose": "Limit processing to records selected by RevOps.", "configuration": {"source": "HubSpot company list"}},
    {"id": "02-normalise", "action": "Normalise and validate company domains", "purpose": "Prevent provider spend and CRM writes against malformed keys.", "configuration": {"reject": ["free email domains", "blank domains", "invalid domains"]}},
    {"id": "03-enrich", "action": "Run conditional firmographic enrichments", "purpose": "Spend credits only for fields that are blank and approved for automation.", "configuration": {"only_if": "destination field is blank"}},
    {"id": "04-map", "action": "Map provider values to CRM picklists", "purpose": "Stop raw provider categories from fragmenting reporting.", "configuration": {"unknown_value": "Other"}},
    {"id": "05-writeback", "action": "Update blank HubSpot fields", "purpose": "Improve completeness while preserving existing values.", "configuration": {"remove_blank_values": true, "overwrite_existing": false}},
    {"id": "06-report", "action": "Return field-level coverage and errors", "purpose": "Measure which providers and mappings improve usable CRM coverage.", "configuration": {"metrics": ["rows attempted", "fields filled", "no-match rate", "error rate"]}}
  ],
  "guardrails": ["Never overwrite a non-empty CRM field without an approved precedence rule.", "Map every automated value to an allowed HubSpot property value before writeback.", "Test provider order and cost on a representative sample.", "Keep source and enrichment timestamps for auditability."],
  "test_cases": [{"name": "Complete record", "input": {"current_company_fields": {"employee_count": 200, "industry": "Software"}}, "expected_status": "no_change"}]
}
