Claude-skill-registry lead-gen-email
Skill for Lead Generation and Email Marketing automation in n8n. Use for creating leads, scoring, enrichment, email campaigns, and nurturing sequences. Activate when working on lead capture forms, email workflows, MQL/SQL qualification, or marketing automation.
git clone https://github.com/majiayu000/claude-skill-registry
T=$(mktemp -d) && git clone --depth=1 https://github.com/majiayu000/claude-skill-registry "$T" && mkdir -p ~/.claude/skills && cp -r "$T/skills/data/lead-gen-email" ~/.claude/skills/majiayu000-claude-skill-registry-lead-gen-email && rm -rf "$T"
skills/data/lead-gen-email/SKILL.mdLead Gen + Email Marketing Skill
Overview
This skill covers the Lead Generation and Email Marketing module of the AI Marketing Department. It provides patterns, templates, and best practices for building lead capture, scoring, enrichment, and email automation workflows.
Database Schema Reference
Core Tables
-- Leads table (main CRM) leads ( id UUID PRIMARY KEY, tenant_id UUID NOT NULL, email TEXT NOT NULL, phone TEXT, first_name TEXT, last_name TEXT, company TEXT, job_title TEXT, source TEXT, -- 'form', 'linkedin', 'meta_ads', 'google_ads', 'organic' source_detail TEXT, score INTEGER DEFAULT 0, score_breakdown JSONB, qualification_status TEXT, -- 'new', 'mql', 'sql', 'customer', 'disqualified' email_status TEXT, -- 'subscribed', 'unsubscribed', 'bounced' enriched_data JSONB, tags TEXT[], created_at TIMESTAMPTZ, updated_at TIMESTAMPTZ ) -- Lead events (for scoring) lead_events ( id UUID PRIMARY KEY, tenant_id UUID NOT NULL, lead_id UUID NOT NULL, event_type TEXT, -- 'form_submit', 'email_open', 'email_click', etc. event_data JSONB, score_delta INTEGER, source TEXT, created_at TIMESTAMPTZ ) -- Email sequences email_sequences ( id UUID PRIMARY KEY, tenant_id UUID NOT NULL, name TEXT, trigger_type TEXT, -- 'lead_created', 'tag_added', 'score_reached', 'manual' trigger_config JSONB, status TEXT -- 'draft', 'active', 'paused' ) -- Sequence steps sequence_steps ( id UUID PRIMARY KEY, sequence_id UUID NOT NULL, step_order INTEGER, delay_days INTEGER, delay_hours INTEGER, action_type TEXT, -- 'send_email', 'add_tag', 'update_score', 'notify_team' action_config JSONB ) -- Sequence enrollments sequence_enrollments ( id UUID PRIMARY KEY, sequence_id UUID NOT NULL, lead_id UUID NOT NULL, current_step INTEGER, status TEXT, -- 'active', 'completed', 'exited' next_action_at TIMESTAMPTZ )
Workflow Patterns
1. Lead Capture Entry Point
Purpose: Normalize leads from any source (forms, ads, LinkedIn, etc.)
Pattern:
Webhook Trigger → Source Detection → Data Normalization → Dedup Check → Create/Update Lead → Log Event → Trigger Sub-workflows
Source Detection Logic:
function detectSource(headers, body) { // LinkedIn Lead Gen if (headers['x-linkedin-webhook'] || body.leadgen_id) { return { source: 'linkedin', source_detail: body.form_name }; } // Meta Ads if (body.leadgen_id && body.field_data) { return { source: 'meta_ads', source_detail: body.ad_name }; } // Google Ads if (body.google_key) { return { source: 'google_ads', source_detail: body.campaign_name }; } // Default: form return { source: 'form', source_detail: body.form_name || 'Web Form' }; }
2. Lead Enrichment Agent
Purpose: AI-powered data enrichment using external sources
Pattern:
Execute Workflow Trigger → Get Lead → Check if needs enrichment → AI Agent (with Perplexity tool) → Parse structured output → Calculate score adjustments → Update Lead → Log Event
AI Output Schema:
{ "company_name": "string", "company_size": "1-10 | 10-50 | 50-200 | 200-1000 | 1000+", "industry": "string", "is_decision_maker": "boolean", "decision_maker_level": "C-Level | Director | Manager | IC", "linkedin_company_url": "string | null", "company_website": "string | null", "technologies_used": ["array"], "enrichment_confidence": "high | medium | low", "notes": "string" }
3. Lead Scoring Engine
Purpose: Calculate lead score based on events and attributes
Pattern:
Execute Workflow Trigger → Get Lead → Get Scoring Rules → Get Lead Events → Calculate Score → Update Lead → Check Status Change → Trigger MQL Alert if needed
Scoring Rule Types:
: Points for specific actions (form_submit: +10, email_open: +2)event
: Points for lead characteristics (decision_maker: +15)attribute
: Negative points for inactivity (-5 after 30 days)decay
Thresholds:
- MQL: score >= 50
- SQL: score >= 100
4. Email Campaign Builder (AI)
Purpose: Generate complete email campaigns using AI
Input Schema:
{ "campaign_name": "Welcome Campaign", "campaign_type": "broadcast | promotional | educational | re-engagement", "tenant_id": "uuid", "tone": "professional | friendly | urgent", "cta_goal": "book_demo | download | visit_page | reply", "product_name": "Your Product", "company_name": "Your Company", "brand_voice": "optional brand guidelines" }
Output: Subject lines (3 variants), preview text, HTML content, plain text
5. Nurturing Sequence Processor
Purpose: Scheduled automation that processes sequence steps
Pattern:
Schedule (15 min) → Get Pending Enrollments → For Each: Get Next Step → Get Lead → Check Subscribed → Route by Action Type → Execute Action → Calculate Next Action Time → Update Enrollment
Action Types:
: Send personalized emailsend_email
: Add tag to leadadd_tag
: Adjust score by deltaupdate_score
: Send Slack notificationnotify_team
: Call external URLwebhook
6. MQL Alert System
Purpose: Notify sales team when leads qualify
Pattern:
Execute Workflow Trigger → Get Lead → Check Qualification → Build Rich Notification → Send Slack + Email → Log Event
Personalization Tokens
Use in email content:
- Lead's first name{{first_name}}
- Lead's last name{{last_name}}
- Company name{{company}}
- Email address{{email}}
- Unsubscribe link{{unsubscribe_url}}
Supabase Query Patterns
Get leads needing nurturing action:
filterString: "status=eq.active&next_action_at=lte.{{ $now.toISO() }}"
Get leads by score range:
filterString: "tenant_id=eq.{{ $json.tenant_id }}&score=gte.50&score=lt.100"
Get subscribed leads only:
filterString: "email_status=eq.subscribed"
Error Handling Best Practices
- Always check email_status before sending emails
- Log all events to lead_events for audit trail
- Use continueOnFail on Slack/email nodes
- Validate email format on lead capture
- Check enriched_at to avoid duplicate enrichment
Multi-tenant Considerations
- All tables have
columntenant_id - RLS policies enforce tenant isolation
- Store
in workflow config nodetenant_id - Pass
to all sub-workflowstenant_id
Testing Checklist
- Lead capture from different sources
- Duplicate detection working
- Enrichment populates enriched_data
- Score calculation correct
- MQL threshold triggers alert
- Sequence steps execute in order
- Unsubscribed leads skip emails
- Personalization tokens replaced