AI Agent Lead Enrichment

Click to zoom
AI Agent Lead Enrichment
Score and enrich leads with AI, then automatically sync them to HubSpot CRM. Submit a lead form, let OpenAI evaluate the contact quality, and push enriched data in one workflow.
AI Agent Lead Enrichment is a full-stack automation that combines AI-powered lead scoring with HubSpot CRM integration to qualify and store leads with minimal effort.
What it does
- Lead intake : Accepts lead details (email, name, company, phone) via an interactive frontend form
- AI lead scoring : Uses OpenAI to analyse the email domain and company name and assign a quality score between 0 and 100
- CRM sync : Creates or updates the contact in HubSpot with the enriched score via the
enrich-leadhabit
Environment variables (.env / keyring on apps)
| Variable | Purpose |
|---|---|
HABITS_OPENAI_API_KEY | OpenAI API key for AI-powered lead scoring |
HABITS_HUBSPOT_ACCESS_TOKEN | HubSpot Private App access token for CRM sync |
How to set up
- Copy
.env.exampleto.envand fill in your credentials. - Create a HubSpot Private App with the required CRM scopes and paste the token as
HABITS_HUBSPOT_ACCESS_TOKEN. - On desktop/mobile apps, the same keys are stored securely in the system keyring.
- Run the
enrich-leadhabit, fill in the lead form, and the contact will be scored and synced to HubSpot automatically.
Tech stack
- habits framework for workflow orchestration
- OpenAI (
@ha-bits/bit-openai) for natural-language lead scoring - HubSpot (
@ha-bits/bit-hubspot) for CRM contact creation and updates - Frontend habit for interactive lead submission UI
Run Your .habit File
Run on Mobile
- [ ] Download the Cortex App from store or the downloads page
- [ ] Open the Cortex App on your device
- [ ] Tap "Open Habit" or "+" button
- [ ] Select your
.habitfile from your device storage - [ ] The habit will be loaded and ready to run
Run on Desktop
- [ ] Download the Cortex App for your platform from the downloads page
- [ ] Install and open the Cortex App
- [ ] Click "Open Habit" or drag & drop your
.habitfile - [ ] The habit will be loaded and ready to run
- [ ] Optional: Place a
.envfile in the same directory as your.habitfile to override environment variables
Run on Server
Run your .habit file as a server using the Cortex CLI:
bash
# Install and run in one command
npx @ha-bits/cortex --config ./your-app.habit- [ ] Make sure Node.js 20+ is installed
- [ ] Run the command above with your
.habitfile path - [ ] Server will start on the specified port (default: 3000)
- [ ] Access the app at
http://localhost:3000 - [ ] Optional: Place a
.envfile next to your.habitfile - it will automatically override any embedded environment variables
Run Serverless
For serverless or containerized deployments, we recommend using Docker:
bash
# Using Docker (recommended for serverless)
docker run -p 3000:3000 -v $(pwd)/your-app.habit:/app/habit.habit \
node:20-alpine npx @ha-bits/cortex --config /app/habit.habit --host 0.0.0.0Or create a Dockerfile:
dockerfile
FROM node:20-alpine
WORKDIR /app
COPY your-app.habit ./
COPY .env ./ # Optional: include environment variables
RUN npm install -g @ha-bits/cortex
EXPOSE 3000
CMD ["cortex", "--config", "./your-app.habit", "--host", "0.0.0.0"]- [ ] Create a Dockerfile or use the Docker run command above
- [ ] Deploy to your preferred cloud provider (AWS, GCP, Azure, etc.)
- [ ] Configure environment variables via your cloud provider's secrets management
- [ ] Set up health checks at
/habits/base/apiendpoint
Workflow Visualization
Requirements
- OPENAI_API_KEY (OpenAI API key)
- HUBSPOT_ACCESS_TOKEN (HubSpot Private App access token)
Quick Start
Run using the Habits CLI wrapper, recommended if you develop local Habits
# First, download the example files
npx habits@latest cortex --config ./ai-agent-lead-enrichment/stack.yamlGet in touch
Want this habit running in your environment?
This habit is a starting point. Tell us about your stack and we'll help you get it working exactly the way your team needs.
