GitHub Leads (Multi-Company)

Monitor GitHub activity across multiple organizations and use AI to qualify leads. Each company gets its own custom prompt, dashboard, and email digest.

Multi-company dashboard

What this does

  1. Monitor GitHub events for multiple organizations from one val
  2. AI qualifies each lead using a custom prompt per company
  3. Each company has its own dashboard and email digest
  4. Export any company's data for migration to a standalone val

Getting started

  1. Add OPENAI_API_KEY and GITHUB_TOKEN to Environment Variables
  2. Visit the dashboard at the val's HTTP endpoint
  3. Click AdminAdd Company
  4. Configure:
    • Display Name: Human-readable name (e.g., "Acme Corp")
    • Slug: URL-safe identifier (e.g., "acme-corp")
    • GitHub Org: The GitHub org to monitor
    • Recipients: Comma-separated emails for daily digest
    • Prompt: Customize the AI qualification criteria

URL structure

PathDescription
/Home - lists all companies
/c/{slug}Company dashboard
/c/{slug}/lead/{id}Lead detail page
/c/{slug}/exportExport company data as JSON
/adminManage companies
/admin/newAdd a company
/admin/{id}Edit a company
/webhook/{slug}POST endpoint for external lead sources

How it works

Cron Job (github.cron.ts)

  • Runs on schedule and processes all active companies
  • Fetches recent GitHub events for each org
  • Groups events by actor and sends to AI

AI Agent (agent.ts)

  • Uses each company's custom prompt
  • Web searches to research the lead
  • Returns {name, match, score, leadTypes, reasoning}

Storage (db.ts)

  • github_leads_companies_v1 - company configurations
  • github_leads_v4 - leads with company_id foreign key

Dashboard (dashboard.tsx)

  • Home page lists all companies with stats
  • Per-company views show qualified vs non-matched leads

Digest (digest.ts)

  • Runs daily and sends separate emails per company
  • Only sends to companies with configured recipients

Splitting off a company

When you want to give a company their own standalone val:

  1. Go to /c/{slug}/export to download the JSON
  2. Create a new val from the single-company template
  3. Import the JSON into their SQLite table
  4. Delete from this multi-company val via Admin

Environment Variables

VariableDescription
OPENAI_API_KEYRequired for AI lead qualification
GITHUB_TOKENRequired for GitHub API access

Files

FileDescription
main.tsHTTP entry point, routes
db.tsCompanies + leads SQLite operations
agent.tsAI lead qualification
github.cron.tsScheduled GitHub monitoring
digest.tsDaily email digest per company
dashboard.tsxMulti-company dashboard UI
admin.tsxCompany management UI