# HubSpot + Dizo

> Auto-enrich new HubSpot contacts: a workflow webhook calls a small function that queries Dizo and writes fields back.

Type: REST recipe — base URL `https://api.dizo.ai/v1`. No native app needed.

## Steps
1. Create a HubSpot private app with `crm.objects.contacts.write` scope.
2. Build a contact-based workflow that sends a webhook (or runs a custom code action) on create.
3. The function calls Dizo enrich, then PATCHes the contact via the HubSpot CRM API.

## Custom code action (Node)
```
const enrich = await fetch("https://api.dizo.ai/v1/people/enrich", {
  method: "POST",
  headers: { Authorization: `Bearer ${process.env.DIZO_API_KEY}`, "Content-Type": "application/json",
             "Idempotency-Key": event.object.objectId.toString() },
  body: JSON.stringify({ email: event.inputFields.email, include: ["phone"], max_credits: 12 }),
});
if (enrich.status === 404) return callback({ outputFields: { dizo: "not_found" } });
const { person } = await enrich.json();

await fetch(`https://api.hubapi.com/crm/v3/objects/contacts/${event.object.objectId}`, {
  method: "PATCH",
  headers: { Authorization: `Bearer ${process.env.HUBSPOT_TOKEN}`, "Content-Type": "application/json" },
  body: JSON.stringify({ properties: { jobtitle: person.title, mobilephone: person.phones?.[0]?.number } }),
});
callback({ outputFields: { dizo: "enriched" } });
```

## Notes
- Custom code actions need a HubSpot tier that supports them; otherwise point a webhook action at a serverless function with the same code.
- Add job-change signals to watch your customer champions and create tasks when they move.

## Related API docs
- [/docs/people-enrich](https://dizo.ai/docs/people-enrich.md)
- [/docs/signals](https://dizo.ai/docs/signals.md)
- [/docs/webhooks](https://dizo.ai/docs/webhooks.md)
