# Pipedrive + Dizo

> Enrich new Pipedrive persons: a Pipedrive webhook calls your small function, which queries Dizo and writes back through the Pipedrive API.

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

## Steps
1. Deploy the function below on any serverless host, with `DIZO_API_KEY`, `PIPEDRIVE_TOKEN`, your company domain and a custom field key as env vars.
2. In Pipedrive, open Tools and apps → Webhooks and create a webhook for the person object and the create action, pointing at the function's URL.
3. Set the webhook's optional HTTP auth username and password, and store the matching Basic header as `PD_HOOK_AUTH` so the function rejects anything else.
4. Add a test person with a work email and confirm the title field and phone fill in.

## Where to go
Tools and apps → **Webhooks**: create a webhook for added persons that points at your function.

Open the Pipedrive webhooks docs: https://support.pipedrive.com/en/article/webhooks

## enrich-person.mjs (Node 18+)
```
export default async function handler(req) {
  // PD_HOOK_AUTH = "Basic " + base64("user:password") set on the webhook
  if (req.headers.get("authorization") !== process.env.PD_HOOK_AUTH) return new Response("unauthorized", { status: 401 });
  const body = await req.json();
  // Webhooks v2: meta.action / meta.entity, the person is in data
  if (body.meta?.entity !== "person" || body.meta?.action !== "create") return new Response("skip");
  const p = body.data;
  const email = p.emails?.[0]?.value;
  if (!email) return new Response("no email");

  const res = 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": `pd-person-${p.id}` },
    body: JSON.stringify({ email, include: ["phone"], max_credits: 12 }),
  });
  if (res.status === 404) return new Response("not found (not charged)");
  const { person } = await res.json();

  const update = { custom_fields: { [process.env.PD_TITLE_FIELD]: person.title } };
  if (person.phones?.[0]?.number && person.phones[0].dnc === false)
    update.phones = [...(p.phones ?? []), { value: person.phones[0].number, primary: false, label: "mobile" }];

  await fetch(`https://${process.env.PD_DOMAIN}.pipedrive.com/api/v2/persons/${p.id}?api_token=${process.env.PIPEDRIVE_TOKEN}`, {
    method: "PATCH", headers: { "Content-Type": "application/json" }, body: JSON.stringify(update),
  });
  return new Response("ok");
}
```

## No-code alternative
```
Trigger:  Pipedrive webhook → n8n Webhook node (or Zapier / Make)
Step 1:   HTTP Request → POST https://api.dizo.ai/v1/people/enrich
          Authorization: Bearer dz_live_...   body { "email": ..., "max_credits": 2 }
Step 2:   Pipedrive API → PATCH /api/v2/persons/{id} with the fields you want
```

## Notes
- Pipedrive's built-in `job_title` field needs contact sync enabled, so this example writes the title to a custom field instead.
- The code sends the person's existing phones along with the new one so nothing is dropped; check Pipedrive's API reference for how it treats arrays.

## Related API docs
- [/docs/people-enrich](https://dizo.ai/docs/people-enrich.md)
- [/docs/phone-find](https://dizo.ai/docs/phone-find.md)
- [/docs/keys](https://dizo.ai/docs/keys.md)


## Pipedrive and the honest way to connect it

Pipedrive is a pipeline-focused CRM. Deals move through stages, and people and organizations hang off those deals. Its automation layer can react to changes, and Pipedrive can send webhooks: when an event such as a person being created happens, it POSTs a JSON payload to a public URL you choose, optionally with HTTP Basic credentials.

What Pipedrive does not document is a workflow step that calls an outside API and then uses the response inside Pipedrive. Its Automations webhook action sends data out, on Growth and higher plans, but the help center does not describe reading the reply. So the dependable path has three parts: a Pipedrive webhook announces the new person, a small function you host calls Dizo's REST API, and that function writes the result back through Pipedrive's own API. There is no native Dizo app in the Pipedrive marketplace, and you do not need one.

## Why add Dizo to a Pipedrive pipeline

Pipedrive rewards activity: calls, emails and meetings that move a deal forward. That only works when the person on the deal has a phone number and a title that tells the rep who they are talking to. People added from a web form or an email thread usually arrive with a name and an address and nothing else, so reps fill the gaps by hand, or skip the call.

Dizo's [person enrich](/docs/people-enrich) endpoint fills those gaps in one request. Send the email and get title, seniority, department, location and work history for 2 credits when a person is matched. Add `include: ["phone"]` and Dizo also looks for a mobile or direct dial, charging 10 more credits only if a number is found. Each phone carries line type, a confidence score and a US Do Not Call flag, which a calling-heavy team needs before a number reaches the dialer. An email that matches nobody returns `404` and costs nothing.

## What you can do with it

The page's function enriches a new person. Swapping the endpoint or the trigger covers most Pipedrive data jobs:

- Write title and seniority to custom fields on every new person, so filters and views can sort by role.
- Append a mobile number to people on deals in late stages, skipping any number flagged `dnc`.
- Find a work email for a person added with only a name and an organization, using `POST /v1/email/find` at 1 credit if found.
- Enrich a new organization from its website with `POST /v1/companies/enrich` and store headcount and industry.
- Re-find people whose emails bounced with `POST /v1/email/find` at 1 credit per email found.
- Watch won-deal contacts for job changes with `POST /v1/signals/watch` and create a follow-up deal when one moves.

## Setting it up

Deploy the function first, since Pipedrive needs a public URL. Any serverless host that runs Node 18 or later works, because the code only uses `fetch`. Give it four environment variables: `DIZO_API_KEY`, `PIPEDRIVE_TOKEN` (your Pipedrive API token), `PD_DOMAIN` (your company subdomain) and `PD_TITLE_FIELD`, the key of a custom person field for the title. Pipedrive custom field keys are 40-character hashes, and its built-in `job_title` field can only be written when contact sync is enabled, which is why the example uses a custom field.

Next, create the webhook. In Pipedrive, go to Tools and apps, then Webhooks, and add one for the person object with the create action. Pipedrive's current default is webhooks v2, where the payload has a `meta` block with the action and entity and a `data` block with the object itself. Set the optional HTTP auth username and password, and reject requests in the function that do not carry them.

The function reads the first email from `data.emails`, calls Dizo with `max_credits: 12` and an `Idempotency-Key` built from the person ID, then sends a `PATCH` to `/api/v2/persons/{id}` with the title in `custom_fields` and the phone added to the existing `phones` list. [Sign up](/signup) for a live key. Work email signups get 250 free credits. A `dz_test_` key returns synthetic data and never spends credits.

## No-code version with n8n, Zapier or Make

If you would rather not host code, point the Pipedrive webhook at a workflow tool instead. In [n8n](/integrations/n8n), a Webhook node receives the event, an HTTP Request node calls Dizo with a Header Auth credential holding `Bearer dz_live_...`, and a final node updates the person through the Pipedrive API. [Zapier](/integrations/zapier) and Make follow the same shape with their own webhook and HTTP steps.

The logic is identical either way. Stop on a `404`, because nothing was found and nothing was charged. Keep `max_credits` in the body. Write only the fields you want, and check the `dnc` flag before a phone number lands where your dialer will pick it up.

## Controlling spend

Pipedrive fires the webhook for every new person, including people created by imports. Put three limits in place. Send `max_credits` on each request: 2 for profile only, 12 with a phone. Create a dedicated key in [API keys](/docs/keys) with `data:read` scope, daily and monthly credit caps, a per-request ceiling and an allow-list of the endpoints the function uses. Set an account-wide monthly USD cap; auto-refill never goes past it, and calls return `402 monthly_cap_reached` once it is hit.

Hypothetical numbers at $0.025 per credit, the $10–$499 tier, assuming 70% of new people match and half of those have a phone found:

- **500 new people a month, profile only:** 350 matches × 2 = 700 credits, or $17.50.
- **Same 500 with phones requested:** 700 + (175 × 10) = 2,450 credits, or $61.25.
- **Phones only for 100 late-stage contacts:** at most 100 × 12 = 1,200 credits, or $30.

## Example workflows

**Inbound person triage.** A form creates a person and a deal. The webhook fires, the function enriches the person without a phone and writes seniority to a custom field. A Pipedrive filter shows director-and-above people from the last week, and reps start there. Cost: 2 credits per matched person.

**Stage-gated phone append.** Rather than paying for phones on every person, trigger only when a deal enters a stage where calls happen. Your function looks up the deal's person, calls [phone finder](/docs/phone-find), keeps the `mobile` and `direct` numbers from the up to three it returns, and adds a number only when `dnc` is false. You spend 10 credits per lookup that finds numbers and nothing for misses.

**Organization firmographics.** A second webhook on the organization object fires when a new organization is created with a website. The function sends the domain to [company enrich](/docs/company-enrich), which returns headcount, revenue band, industry, HQ, latest funding round and technologies for 1 credit if matched, and writes them to organization custom fields. Deal filters can then segment the pipeline by company size, and 300 new organizations a month cost at most 300 credits, or $7.50 at the entry tier.

## Troubleshooting and security

If the function never runs, check the webhook status in Pipedrive's webhooks list, and make sure the URL is public and accepts POST. If Dizo returns 401, the `Authorization` header is malformed: it must be `Bearer`, a space, then the key. If the Pipedrive update fails with 403, you may be writing `job_title` without contact sync; use a custom field. A 402 from Dizo means a cap was reached, and the free `GET /v1/billing` endpoint shows the balance and limits.

Keep both tokens in your host's secret store, never in the code. Use a Dizo key that exists only for this function, so you can revoke it without affecting other tools, and keep billing scopes off it. If an enriched number is disconnected or an email bounces, report it through `POST /v1/feedback`; confirmed reports are credited back. Dizo's [trust](/trust) page covers opt-outs and data-subject requests.

## FAQ

### Is there a Dizo app in the Pipedrive Marketplace?
No. You connect them with a Pipedrive webhook and a small function, or a workflow tool such as n8n, that calls Dizo's REST API and writes back through the Pipedrive API.

### Can Pipedrive Automations call Dizo directly?
The Automations webhook action can send data out on Growth and higher plans, but Pipedrive's docs do not describe using the response in later steps. To write Dizo's answer back to the person, you need a function or workflow tool in between.

### Why does the example write the title to a custom field?
Pipedrive's API only accepts the built-in `job_title` field when contact sync is enabled. A custom person field works on any setup; if you use contact sync, you can write `job_title` instead.

### What does it cost when nobody is found?
Nothing. Person enrich returns `404` for an unmatched email and charges no credits. Phones cost 10 credits only when a number is actually found.

### How do I keep Do Not Call numbers out of my pipeline?
Every phone Dizo returns has a `dnc` flag based on the US National Do Not Call Registry. The example only writes a number when `dnc` is false. This is not legal advice; check your own calling obligations.

### How do I enrich people already in Pipedrive?
Export them, send the emails to `POST /v1/batch` as one job of up to 10,000 lookups, and import the results file. A `dry_run` on the batch quotes the maximum cost first.
