home / skills / abdullahbeam / nexus-design-abdullah / heyreach

heyreach skill

/00-system/skills/heyreach

This skill provides a centralized HeyReach toolkit, enabling quick setup checks, API access, and reusable scripts to streamline integration workflows.

npx playbooks add skill abdullahbeam/nexus-design-abdullah --skill heyreach

Review the files below or copy the command above to add this skill to your agents.

Files (19)
SKILL.md
6.4 KB
---
name: heyreach-master
description: "Internal resource library for HeyReach integration. Contains shared API client, operation scripts, and reference documentation."
---

# HeyReach Master (Internal)

Internal resource library containing:
- API client (`heyreach_client.py`)
- Config checker (`check_heyreach_config.py`)
- All operation scripts
- Reference documentation

---

## Architecture: DRY Principle

**Problem solved:** HeyReach skills would have duplicated content (setup instructions, API docs, auth flow, error handling).

**Solution:** Extract shared content into `heyreach-master/references/` and `heyreach-master/scripts/`, then reference from each skill.

**Result:** Single source of truth, reduced context per skill.

---

## Shared Resources

All HeyReach skills reference these resources (progressive disclosure).

### references/

**[setup-guide.md](references/setup-guide.md)** - Complete setup wizard
- Getting API key from HeyReach
- Environment configuration
- Verifying connection

**[api-reference.md](references/api-reference.md)** - HeyReach API patterns
- Base URL and authentication
- All endpoints documented
- Request/response examples
- Pagination patterns

**[error-handling.md](references/error-handling.md)** - Troubleshooting
- Common errors and solutions
- HTTP error codes
- Rate limiting
- Debug tips

### scripts/

#### Authentication & Configuration

**[check_heyreach_config.py](scripts/check_heyreach_config.py)** - Pre-flight validation
```bash
python check_heyreach_config.py [--json]
```
| Argument | Required | Default | Description |
|----------|----------|---------|-------------|
| `--json` | No | False | Output structured JSON for AI consumption |

Exit codes: 0=configured, 1=partial, 2=not configured

**When to Use:** Run this FIRST before any HeyReach operation. Use to validate API key is configured, diagnose authentication issues, or check if setup is needed.

---

**[heyreach_client.py](scripts/heyreach_client.py)** - Shared API client
```python
from heyreach_client import get_client, HeyReachError

client = get_client()
result = client.post("/v2/campaigns/All", {"offset": 0, "limit": 100})
```

Features:
- Automatic retry with exponential backoff
- Rate limit handling (300 req/min)
- Consistent error responses
- API key management from .env

---

## Intelligent Error Detection Flow

When a HeyReach skill fails due to missing configuration, the AI should:

### Step 1: Run Config Check with JSON Output

```bash
python 00-system/skills/heyreach/heyreach-master/scripts/check_heyreach_config.py --json
```

### Step 2: Parse the `ai_action` Field

| ai_action | What to Do |
|-----------|------------|
| `proceed_with_operation` | Config OK, continue with the original operation |
| `prompt_for_api_key` | Ask user: "I need your HeyReach API key from Settings → API" |
| `create_env_file` | Create `.env` file and ask user for credentials |
| `verify_api_key` | Key exists but connection failed - verify it's correct |
| `retry_later` | API timeout - try again |
| `check_network` | Connection error - verify network |

### Step 3: Help User Fix Issues

If `ai_action` is `prompt_for_api_key`:

1. Tell user: "HeyReach integration needs setup. I need your API key."
2. Show them: "Get it from HeyReach: Settings → API"
3. Ask: "Paste your HeyReach API key:"
4. Once they provide it, **write directly to `.env`**:
   ```
   HEYREACH_API_KEY=their-key-here
   ```
5. Re-run config check to verify

---

## Environment Variables

Required in `.env`:
```
HEYREACH_API_KEY=your-api-key-here
```

---

## API Base URL

All API requests go to: `https://api.heyreach.io/api/public`

Authentication header: `X-API-KEY: {api_key}`

Rate limit: 300 requests/minute

---

## Script Usage Patterns

### List Campaigns
```python
from heyreach_client import get_client

client = get_client()
result = client.post("/v2/campaigns/All", {"offset": 0, "limit": 100})
campaigns = result.get("items", [])
```

### Get Campaign Details
```python
result = client.get(f"/v2/campaigns/{campaign_id}")
```

### Add Leads
```python
leads = [
    {"linkedInUrl": "https://linkedin.com/in/user1"},
    {"linkedInUrl": "https://linkedin.com/in/user2"}
]
result = client.post(f"/v2/campaigns/{campaign_id}/leads", {"leads": leads})
```

### Error Handling
```python
from heyreach_client import get_client, HeyReachError

try:
    client = get_client()
    result = client.get("/v2/campaigns/123")
except HeyReachError as e:
    print(f"Error {e.status_code}: {e.message}")
except ValueError as e:
    print(f"Config error: {e}")
```

---

**Version**: 1.0
**Created**: 2025-12-19
**Status**: Production Ready

Overview

This skill is an internal HeyReach resource library that centralizes shared API client code, operation scripts, and reference documentation for all HeyReach integrations. It reduces duplication across skills by providing a single source of truth for setup, auth, error handling, and common operations. Use it to validate configuration, run common API calls, and follow troubleshooting flow for integration failures.

How this skill works

The library exposes a pre-built API client (heyreach_client.py) with automatic retries, rate-limit handling, and consistent error types. A configuration checker script inspects environment variables and returns structured JSON ai_action directives to guide the next steps. Reference docs cover setup, endpoints, request/response examples, pagination, and error troubleshooting.

When to use it

  • Run the config checker before any HeyReach operation to verify API key and network access.
  • Use the shared API client for list, get, and write operations to ensure consistent retries and rate-limit behavior.
  • Follow the Intelligent Error Detection Flow when an integration fails to diagnose and fix auth or network issues.
  • Reference the setup and API docs when onboarding a new HeyReach skill or updating endpoints.
  • Use the scripts to automate pre-flight checks in CI or developer workflows.

Best practices

  • Always run check_heyreach_config.py --json as the first step and parse ai_action to decide next actions.
  • Store HEYREACH_API_KEY in a .env file and use the provided client which reads .env automatically.
  • Handle HeyReachError exceptions from the client and surface status_code and message to users or logs.
  • Respect the documented rate limit (300 req/min) and rely on the client's backoff logic for retries.
  • Re-run the config checker after making config changes to confirm resolution.

Example use cases

  • Validate integration readiness in a CI job by running the config checker and failing early on missing credentials.
  • List campaigns programmatically using the shared client: client.post('/v2/campaigns/All', {...}).
  • Add leads to a campaign with client.post('/v2/campaigns/{id}/leads', {'leads': [...]}) while relying on automatic retry and rate-limit handling.
  • Troubleshoot auth failures by following ai_action from the config checker: prompt for API key, create .env, or verify the key.
  • Implement user-facing prompts that ask for the HeyReach API key and then write HEYREACH_API_KEY to .env before re-checking.

FAQ

What environment variables are required?

HEYREACH_API_KEY must be present in .env. The client reads this value for authentication.

What does the config checker return?

It returns structured JSON with an ai_action field indicating next steps like proceed_with_operation, prompt_for_api_key, create_env_file, verify_api_key, retry_later, or check_network.