import os, requests, time
HS = os.environ["HUBSPOT_ACCESS_TOKEN"]
MV = os.environ["MAVERA_API_KEY"]
MH = {"Authorization": f"Bearer {MV}", "Content-Type": "application/json"}
ROLES = [
{"role": "Economic Buyer", "desc": "C-level controlling budget. Cares about ROI and strategic alignment."},
{"role": "Technical Evaluator", "desc": "Engineering/IT lead. Evaluates integration, security, scalability."},
{"role": "End User Champion", "desc": "Day-to-day user and internal advocate. Cares about UX and time savings."},
{"role": "Procurement Gatekeeper", "desc": "Legal/procurement. Reviews compliance, terms, and risk."},
]
# 1. Target companies
companies = requests.post("https://api.hubapi.com/crm/v3/objects/companies/search",
headers={"Authorization": f"Bearer {HS}"},
json={
"filterGroups": [{"filters": [{"propertyName": "numberofemployees", "operator": "GTE", "value": "100"}]}],
"properties": ["name", "industry", "numberofemployees", "annualrevenue", "domain"],
"sorts": [{"propertyName": "annualrevenue", "direction": "DESCENDING"}],
"limit": 5,
}).json().get("results", [])
all_personas = []
for co in companies:
p = co.get("properties", {})
name = p.get("name", "Unknown")
# 2. Enrich with Mave
enrichment = requests.post("https://app.mavera.io/api/v1/mave/chat", headers=MH,
json={"message": f"Research {name} ({p.get('industry','N/A')}, ~{p.get('numberofemployees','?')} employees). Strategic priorities? Key challenges? Recent news? Buying committee for B2B SaaS?"}
).json()
context = enrichment.get("content", "")[:300]
# 3. Create buying committee personas
for role in ROLES:
persona = requests.post("https://app.mavera.io/api/v1/personas", headers=MH, json={
"name": f"{name} — {role['role']}",
"description": f"{role['desc']} Context: {p.get('industry','N/A')}, ~{p.get('numberofemployees','?')} employees. {context}",
"demographic": {"industries": [p.get("industry", "Technology")]},
}).json()
all_personas.append({"company": name, "role": role["role"], "id": persona["id"]})
time.sleep(0.2)
time.sleep(0.5)
print(f"Created {len(all_personas)} ABM personas for {len(companies)} companies")
for p in all_personas:
print(f" {p['company']} | {p['role']} | {p['id']}")