An automated B2B lead intelligence system that enriches sales leads through AI-powered research, CRM integration, and personalized outreach—all visualized in real-time.
Automates the entire lead enrichment process:
- Company Research - Deep AI search for funding, tech stack, and news (via Exa)
- Decision Makers - Finds key executives and LinkedIn profiles (via Exa)
- CRM Integration - Creates enriched contacts in Attio with duplicate detection
- Analytics Logging - Tracks all enrichment data in Airtable
- Email Generation - AI-powered personalized outreach emails
- Automated Sending - Sends emails via Gmail
- Intelligence Reports - Creates detailed reports in Notion
- Vercel Workflows - Durable workflow orchestration
- Pica - Unified API for 5+ integrations (Exa, Attio, Airtable, Gmail, Notion)
- Next.js 15 - React framework with App Router
- React Flow - Visual workflow canvas
- Tailwind CSS + shadcn/ui - Modern UI components
npm installCreate a .env file in the project root:
# Pica API Configuration
PICA_SECRET=your_pica_secret_key
# Integration Connection Keys (from Pica dashboard)
PICA_EXA_CONNECTION_KEY=live::exa::default::your_exa_key
PICA_ATTIO_CONNECTION_KEY=live::attio::default::your_attio_key
PICA_AIRTABLE_CONNECTION_KEY=live::airtable::default::your_airtable_key
PICA_GMAIL_CONNECTION_KEY=live::gmail::default::your_gmail_key
PICA_NOTION_CONNECTION_KEY=live::notion::default::your_notion_key
# Airtable Configuration
AIRTABLE_BASE_ID=appXXXXXXXXXXXXXX
AIRTABLE_TABLE_ID=tblXXXXXXXXXXXXXX
# Notion Configuration
NOTION_PARENT_PAGE_ID=xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx- Sign up at pica.com
- Connect your integrations (Exa, Attio, Airtable, Gmail, Notion)
- Copy connection keys from the Pica dashboard
- Set your
PICA_SECRETfrom account settings
npm run dev// workflows/lead-enrichment.ts
export async function enrichLeadWorkflow(leadData: LeadData) {
"use workflow"; // Vercel Workflow directive
// Each step calls real Pica APIs
const companyData = await researchCompany(); // Step 1
const decisionMakers = await findDecisionMakers(); // Step 2
const attioResult = await createAttioContact(); // Step 3
// ... etc
return { success: true, /* all results */ };
}- Workflow pushes step results to
/api/step-updateusingfetchfrom "workflow" - Frontend polls every 2 seconds
- React Flow visualizes progress with 8 stable nodes
- No disappearing nodes - memoized
nodeTypesandedgeTypes
✅ Combo Uniqueness - Searches Attio for email+name+company before creating duplicates
✅ Error Handling - Failed steps show red badge with error details
✅ Real-Time Visualization - See each step complete with 2-second pauses
✅ Durable Execution - Survives server restarts, auto-retries on failures
✅ Production Ready - Bulletproof state management, no flickering nodes
├── app/
│ ├── api/
│ │ ├── leads/ # Trigger workflow endpoint
│ │ ├── workflow/ # Query workflow status
│ │ └── step-update/ # Real-time step data store
│ ├── workflow/[runId]/ # Workflow visualization page
│ └── page.tsx # Landing page with form
├── workflows/
│ └── lead-enrichment.ts # Main workflow definition
├── lib/
│ └── pica-client.ts # Pica API wrapper functions
└── components/
└── lead-form.tsx # Lead submission form
Submits a new lead and triggers the workflow.
Request:
{
"name": "Sarah Chen",
"email": "sarah@startup.com",
"company": "Tech Startup"
}Response:
{
"success": true,
"runId": "wrun_01K8K...",
"lead": { /* lead data */ }
}Fetches workflow status and final results.
Fetches real-time step results.
Deploy to Vercel with one click:
vercel deployMake sure to add all environment variables in the Vercel dashboard.
MIT
For issues or questions, open a GitHub issue or contact support@pica.com