Automatically enhance and enrich contact data using AI to fill in missing information, generate insights, and create detailed buyer personas. Supports multiple AI providers (OpenAI, Anthropic, etc.) with automatic logging to Supabase.
This workflow transforms incomplete contact records into rich, actionable profiles. By leveraging AI, it can infer job roles, company information, likely pain points, communication preferences, and buying motivations from minimal input data. Perfect for sales and marketing teams looking to improve data quality and personalize outreach.
Key Benefits:
Use Cases:
Add these to your n8n environment settings:
AI_PROVIDER=openai # or 'anthropic', 'custom'
AI_API_KEY=your_api_key_here
AI_MODEL=gpt-3.5-turbo # or 'gpt-4', 'claude-3-sonnet-20240229'
AI_ENDPOINT= # Only for custom providers
Recommended Models:
gpt-3.5-turbo
(fast, affordable, good for basic enrichment)gpt-4
or claude-3-sonnet-20240229
(better inference, deeper insights)claude-3-opus-20240229
(best for complex persona generation)How to set environment variables:
.env
file or docker-compose configurationCreate the logging table in your Supabase database:
CREATE TABLE workflow_logs (
id BIGSERIAL PRIMARY KEY,
workflow_name TEXT NOT NULL,
data JSONB NOT NULL,
ai_response JSONB NOT NULL,
created_at TIMESTAMP WITH TIME ZONE DEFAULT NOW()
);
CREATE INDEX idx_workflow_logs_created_at ON workflow_logs(created_at);
CREATE INDEX idx_workflow_logs_workflow_name ON workflow_logs(workflow_name);
-- Optional: Create a view for enriched contacts
CREATE VIEW enriched_contacts AS
SELECT
id,
data->>'email' as email,
data->>'name' as name,
data->>'company' as company,
ai_response as enrichment_data,
created_at
FROM workflow_logs
WHERE workflow_name = 'AI Contact Enrichment'
ORDER BY created_at DESC;
To run this SQL:
Supabase API
Send a test POST request to the webhook:
curl -X POST https://your-n8n-instance.com/webhook/contact-enrichment \
-H "Content-Type: application/json" \
-d '{
"email": "[email protected]",
"name": "John Doe",
"company": "Acme Corporation",
"linkedin_url": "https://linkedin.com/in/johndoe"
}'
Successful Response:
{
"success": true,
"workflow": "AI Contact Enrichment",
"timestamp": "2025-01-14T12:00:00.000Z"
}
The webhook accepts JSON with basic contact information:
{
"email": "string (required or name required)",
"name": "string (required or email required)"
}
{
"email": "string",
"name": "string",
"company": "string",
"job_title": "string",
"linkedin_url": "string",
"phone": "string",
"location": "string",
"website": "string"
}
{
"email": "[email protected]",
"name": "Sarah Chen",
"company": "TechStartup Inc.",
"job_title": "VP of Marketing",
"linkedin_url": "https://linkedin.com/in/sarahchen",
"phone": "+1-555-0123",
"location": "San Francisco, CA",
"website": "https://techstartup.io",
"industry": "B2B SaaS",
"company_size": "50-200 employees",
"notes": "Met at SaaS conference 2024"
}
Field Guidelines:
email
or name
linkedin_url
for best resultscompany
helps with firmographic enrichmentModify the "Prepare AI Request" node to customize enrichment:
// Enhanced prompt for contact enrichment
const systemPrompt = `You are an expert sales intelligence analyst.
Analyze the provided contact information and generate a comprehensive enrichment including:
1. INFERRED DETAILS: Fill in missing information based on available data
- Full job title and seniority level
- Department and reporting structure
- Years of experience (estimated)
- Professional background
2. COMPANY INSIGHTS: If company name provided
- Industry and sub-industry
- Company size and revenue (estimated)
- Key products/services
- Recent news or developments
3. BUYER PERSONA: Create a detailed profile
- Primary responsibilities
- Likely pain points and challenges
- Key priorities and goals
- Decision-making authority
- Budget influence level
4. ENGAGEMENT STRATEGY: Provide outreach recommendations
- Best communication channels
- Optimal outreach timing
- Key talking points
- Personalization suggestions
- Content interests
5. LEAD SCORE: Rate 1-10 based on:
- Fit for product/service (specify your ICP)
- Seniority and decision power
- Company size and maturity
- Engagement potential
Return as structured JSON with clear sections.`;
const userMessage = `Contact Information:\n${JSON.stringify($json.data, null, 2)}`;
const aiConfig = {
provider: $env.AI_PROVIDER || 'openai',
apiKey: $env.AI_API_KEY,
model: $env.AI_MODEL || 'gpt-3.5-turbo',
endpoint: $env.AI_ENDPOINT,
messages: [
{ role: 'system', content: systemPrompt },
{ role: 'user', content: userMessage }
]
};
return { json: { aiConfig, data: $json } };
Enhance enrichment with third-party APIs:
After "Process Data" node, add:
Then merge all data before AI enrichment for best results
Auto-update contacts after enrichment:
Salesforce Integration:
// Add after "Call AI API" node
// Update Salesforce contact with enriched data
const enrichedData = JSON.parse($json.ai_response);
return {
json: {
contactId: $json.data.salesforce_id,
updates: {
Description: enrichedData.buyer_persona,
Custom_Score__c: enrichedData.lead_score,
Pain_Points__c: enrichedData.pain_points
}
}
};
HubSpot Integration:
Pipedrive Integration:
Add scoring logic after enrichment:
// Calculate lead score based on enrichment
const enrichment = JSON.parse($json.ai_response);
let score = 0;
// Job title scoring
if (enrichment.seniority === 'C-Level') score += 30;
else if (enrichment.seniority === 'VP/Director') score += 20;
else if (enrichment.seniority === 'Manager') score += 10;
// Company size scoring
if (enrichment.company_size === 'Enterprise') score += 25;
else if (enrichment.company_size === 'Mid-Market') score += 15;
// Decision authority scoring
if (enrichment.decision_authority === 'High') score += 25;
else if (enrichment.decision_authority === 'Medium') score += 15;
// Budget influence
if (enrichment.budget_influence === 'Direct') score += 20;
return { json: { ...enrichment, lead_score: score } };
Insert before AI processing:
// Check for opt-out or compliance flags
const email = $json.email.toLowerCase();
// Check against suppression list
const suppressedDomains = ['competitor.com', 'spam.com'];
const domain = email.split('@')[1];
if (suppressedDomains.includes(domain)) {
throw new Error('Contact on suppression list');
}
// Verify email format
const emailRegex = /^[^\s@]+@[^\s@]+\.[^\s@]+$/;
if (!emailRegex.test(email)) {
throw new Error('Invalid email format');
}
return { json: $json };
Process multiple contacts:
Issue: "Enrichment is too generic"
Issue: "AI_API_KEY is undefined"
Issue: "Enrichment contradicts actual data"
Issue: "Too slow for real-time use"
Issue: "Supabase credentials not found"
Query and analyze your enriched contacts:
-- Get all enriched contacts
SELECT * FROM enriched_contacts
ORDER BY created_at DESC;
-- Find high-value leads (assuming scoring implemented)
SELECT
email,
name,
company,
ai_response->>'lead_score' as score
FROM enriched_contacts
WHERE (ai_response->>'lead_score')::int > 70
ORDER BY (ai_response->>'lead_score')::int DESC;
-- Analyze enrichment by company
SELECT
data->>'company' as company,
COUNT(*) as contact_count,
AVG((ai_response->>'lead_score')::int) as avg_score
FROM workflow_logs
WHERE workflow_name = 'AI Contact Enrichment'
AND ai_response->>'lead_score' IS NOT NULL
GROUP BY data->>'company'
ORDER BY contact_count DESC;
-- Find contacts needing follow-up
SELECT
email,
name,
ai_response->>'engagement_strategy' as strategy,
created_at
FROM enriched_contacts
WHERE created_at > NOW() - INTERVAL '7 days'
ORDER BY created_at DESC;
-- Export to CSV
COPY (
SELECT
data->>'email' as email,
data->>'name' as name,
data->>'company' as company,
ai_response->>'job_title' as enriched_title,
ai_response->>'seniority' as seniority,
ai_response->>'lead_score' as score
FROM workflow_logs
WHERE workflow_name = 'AI Contact Enrichment'
) TO '/tmp/enriched_contacts.csv' WITH CSV HEADER;
Automatically enrich new leads from forms:
Real-time enrichment as contacts enter CRM:
Enhance cold outreach campaigns:
Power ABM and segmentation:
Team notifications and collaboration:
sales-automation
, lead-enrichment
, ai-automation
, crm-integration
, data-enrichment
, contact-intelligence
, buyer-personas
, lead-scoring
, webhook
, supabase
, openai
, anthropic
, b2b-sales
This workflow template is provided as-is for use with n8n.
For questions or issues:
Input:
{
"email": "[email protected]",
"name": "Mike Johnson",
"company": "CloudTech Solutions",
"job_title": "Director of IT"
}
AI-Generated Enrichment:
{
"full_title": "Director of Information Technology",
"seniority": "Director",
"department": "Technology/IT",
"experience_years": "10-15",
"company_insights": {
"industry": "Cloud Computing",
"size": "Mid-Market (100-500)",
"revenue_estimate": "$10M-$50M"
},
"buyer_persona": {
"responsibilities": ["Infrastructure management", "Vendor selection", "Security oversight"],
"pain_points": ["Legacy system migration", "Cost optimization", "Security compliance"],
"priorities": ["Scalability", "Cost reduction", "Team efficiency"]
},
"engagement_strategy": {
"best_channels": ["Email", "LinkedIn"],
"timing": "Tuesday-Thursday, 9-11 AM",
"talking_points": ["ROI and cost savings", "Security features", "Ease of implementation"],
"personalization": "Reference cloud migration challenges"
},
"lead_score": 75
}