# Lead Scoring Agent — Setup Guide
**Agentcask** · Version 1.2.0 · Category: Sales

---

## What this agent does

Reads every new HubSpot contact the moment it's created, enriches the record with Clearbit (company size, industry, funding, tech stack), then sends it through Claude for ICP scoring (0–100). The score, tier (A/B/C/D), and a one-line reason are written back to HubSpot and posted to your Slack sales channel — all within ~8 seconds of form submission.

**No more "who picks this up?" pings. No more unscored leads sitting for days.**

---

## What's included

- `lead-scoring-agent.json` — importable n8n workflow (9 nodes)
- This setup guide
- Inline documentation on every node
- Example webhook payload for testing
- 30-day money-back guarantee

---

## Prerequisites

| Tool | Purpose | Free tier? |
|------|---------|------------|
| n8n (self-hosted or cloud) | Workflow runner | Yes |
| HubSpot CRM | Lead source | Yes |
| Clearbit API | Contact enrichment | 100 lookups/mo free |
| Anthropic API (Claude) | ICP scoring | Pay-per-use |
| Slack | Rep notifications | Yes |

---

## Step 1 — Import the workflow

1. Open your n8n instance
2. Click **Workflows → Import from file**
3. Upload `lead-scoring-agent.json`
4. The workflow opens with 9 pre-configured nodes

---

## Step 2 — Add credentials

Go to **Credentials** in n8n and add the following:

### HubSpot OAuth2
1. In HubSpot → Settings → Integrations → Private Apps → Create
2. Scopes needed: `crm.objects.contacts.read`, `crm.objects.contacts.write`
3. Copy the access token into n8n's HubSpot credential

### Clearbit API Key
1. Sign up at clearbit.com
2. Settings → API → copy your secret key
3. In n8n: Credentials → New → HTTP Header Auth
   - Name: `Authorization`
   - Value: `Bearer YOUR_CLEARBIT_KEY`

### Anthropic API Key
1. Sign up at console.anthropic.com
2. API Keys → Create Key
3. In n8n: Credentials → New → Anthropic API
4. Paste your key

### Slack OAuth2
1. api.slack.com/apps → Create New App → From scratch
2. OAuth & Permissions → Scopes → Add: `chat:write`, `chat:write.public`
3. Install to workspace → copy Bot Token
4. In n8n: Credentials → New → Slack OAuth2

---

## Step 3 — Configure the HubSpot webhook

1. Click the **HubSpot Webhook** node
2. Copy the webhook URL (e.g. `https://your-n8n.com/webhook/hubspot-lead-webhook`)
3. In HubSpot → Settings → Integrations → Webhooks
4. Create a new subscription: **Contact Created**
5. Paste the n8n webhook URL
6. Save and activate

---

## Step 4 — Set your Slack channel

1. Click the **Slack Notify Rep** node
2. Change `sales-leads` to your actual Slack channel name
3. Make sure your Slack app is invited to that channel (`/invite @YourAppName`)

---

## Step 5 — Create custom HubSpot properties

The agent writes three values back to HubSpot. Create these custom contact properties:

| Property Name | Type | Label |
|---------------|------|-------|
| `lead_score` | Number | Lead Score |
| `lead_tier` | Single-line text | Lead Tier |
| `score_reason` | Multi-line text | Score Reason |

In HubSpot: Settings → Properties → Create property → Contact → fill in the details above.

---

## Step 6 — Test with a sample payload

Activate the workflow (toggle at top right), then send a test request:

```bash
curl -X POST https://your-n8n.com/webhook/hubspot-lead-webhook \
  -H "Content-Type: application/json" \
  -d '{
    "properties": {
      "email": "john@acmecorp.com",
      "company": "Acme Corp",
      "jobtitle": "VP of Sales",
      "annualrevenue": "5000000",
      "numberofemployees": "120"
    }
  }'
```

Check your Slack channel — within ~8 seconds you should see the scored lead message.

---

## Scoring logic

Claude scores each lead against your ICP using these signals:

| Signal | Weight |
|--------|--------|
| Title seniority (C-level, VP, Director) | High |
| Company size (10–500 employees = ideal) | High |
| Industry match | Medium |
| Has raised funding | Medium |
| English-speaking market | Low |

**Tier mapping:**
- **A** (80–100): Route immediately to AE, high-priority follow-up
- **B** (60–79): Add to sequence, follow up within 24h
- **C** (40–59): Nurture sequence, follow up within 1 week
- **D** (0–39): Filtered out — no Slack notification sent

---

## Customizing the ICP

Edit the **Claude Score Lead** node prompt to match your actual ICP. Example adjustments:

```
Our ICP: E-commerce brands, 50-2000 employees, decision-maker titles 
(CMO, Head of Growth, Marketing Director), US and EU markets only, 
must be running Shopify or WooCommerce.
```

The agent adapts automatically — no code changes needed.

---

## Troubleshooting

**Clearbit returns empty data**
- Check your API key in the credential
- Clearbit may not have data for that email domain — the agent handles this gracefully and still scores with available data

**HubSpot update fails**
- Verify the three custom properties exist (Step 5)
- Check that your HubSpot credential has write scope

**Slack message not appearing**
- Confirm the app is invited to the channel
- Check the channel name matches exactly (no `#` prefix needed in n8n)

---

## Support

Questions? Reach us at **support@agentcask.com** or via your Slack support channel (Team plan).

---

*Agentcask — Production-ready AI agents. agentcask.com*
