Webhook icon
ChatCompletion icon
Script icon
Docker icon
If icon
SlackIncomingWebhook icon
Log icon
Query icon
Return icon

AI Lead Firmographic Enrichment

Ingests inbound corporate leads, searches company firmographics via Perplexity AI, and routes high-value enterprise prospects to Slack.

Categories
AIBusiness

When prospective customers submit demo requests or trial signup forms, traditional enrichment providers (such as Clearbit or ZoomInfo) frequently have coverage gaps on high-growth startups, international organizations, or stealth companies. Furthermore, static database records quickly become outdated regarding recent venture rounds, acquisitions, and executive leadership shifts.

By orchestrating Perplexity AI's real-time web-grounded search models (sonar) within Kestra, marketing and sales teams can retrieve real-time firmographic intelligence for any inbound domain within seconds.

This blueprint listens for inbound lead form submissions via Webhook, prompts Perplexity to search the live web for verified company size, industry vertical, headquarters, and funding status, persists the enriched profile into PostgreSQL, and immediately routes high-value enterprise accounts to sales teams via Slack.

How it works

  1. Webhook Ingest: The inbound_lead_webhook trigger (io.kestra.plugin.core.trigger.Webhook) activates immediately upon form submission.
  2. Perplexity Web Search: The research_company_via_perplexity task (io.kestra.plugin.perplexity.ChatCompletion) queries the sonar model to conduct web research and return structured JSON.
  3. Python Field Parsing: The parse_firmographic_data task (io.kestra.plugin.scripts.python.Script) validates fields, evaluates enterprise qualification thresholds, and outputs lead_profile.json.
  4. Condition Branching: The evaluate_enterprise_tier flowable task (io.kestra.plugin.core.flow.If) branches based on whether the lead meets enterprise size criteria.
  5. Slack Alert Dispatch: If classified as enterprise, alert_enterprise_sales_lead (io.kestra.plugin.slack.notifications.SlackIncomingWebhook) delivers an actionable briefing card to the sales team.
  6. CRM Storage: The persist_lead_to_database task (io.kestra.plugin.jdbc.postgresql.Query) saves the enriched record to PostgreSQL with idempotent upsert logic.
  7. Lead Manifest: The export_lead_manifest task returns execution metadata for marketing analytics.

Architecture diagram

flowchart TD
    A[Trigger: Inbound Webhook] --> B[research_company_via_perplexity: Perplexity Sonar]
    B --> C[parse_firmographic_data: Python Classifier]
    C --> D{Enterprise Tier Lead?}
    D -- Yes --> E[alert_enterprise_sales_lead: Slack]
    D -- No --> F[log_standard_lead_tier: Log]
    E --> G[persist_lead_to_database: PostgreSQL]
    F --> G
    G --> H[export_lead_manifest: Return JSON]

Use cases

  • Speed-to-Lead Acceleration: Enrich inbound signups with live web data within seconds and alert enterprise sales reps.
  • Automated CRM Hygiene: Populate PostgreSQL customer databases with verified headcount, industry, and funding stage.
  • Dynamic Account-Based Routing: Filter out low-fit consumer signups while escalating high-ARR enterprise prospects.

What you get

  • Real-time web-grounded firmographic enrichment with zero stale database gaps.
  • Automated lead qualification routing enterprise accounts to account executives instantly.
  • Structured persistence into PostgreSQL CRM tables with upsert handling.
  • Formatted Slack alert cards containing company headcount, industry, and funding stage.

Who it is for

  • Revenue Operations (RevOps) engineers automating lead routing and qualification pipelines.
  • Growth Marketing teams optimizing inbound conversion rates and speed-to-lead SLAs.
  • Enterprise Sales Development Representatives (SDRs) prioritizing outreach.

Why orchestrate this with Kestra

Connecting web forms, generative search APIs, relational databases, and Slack typically requires brittle serverless functions. Kestra consolidates webhook ingestion, real-time AI inference, database upserts, and team notifications into a single observable workflow.

Inputs

Name Type Default Description
lead_email STRING alex.taylor@stripe.com Prospect contact email address.
company_name STRING Stripe Company name to investigate.
postgres_url STRING jdbc:postgresql://... JDBC URL for CRM storage.
postgres_username STRING crm_writer Database user for upsert queries.
slack_channel STRING #sales-leads Slack channel destination for alerts.

Expected outputs

  • {{ outputs.parse_firmographic_data.vars.is_enterprise }}: Boolean flag indicating if company headcount >= 500.
  • {{ outputs.parse_firmographic_data.vars.industry }}: Business vertical identified via web search.
  • {{ outputs.parse_firmographic_data.vars.employees }}: Estimated employee count.
  • {{ outputs.parse_firmographic_data.outputFiles['lead_profile.json'] }}: Complete JSON diagnostic report.

Prerequisites

  • Perplexity AI API account with active credits.
  • PostgreSQL CRM database with an inbound_leads table.
  • Slack Incoming Webhook configured for your sales notifications channel.

Secrets

  • PERPLEXITY_API_KEY: API key for Perplexity AI web search inference.
  • POSTGRES_PASSWORD: Password for the PostgreSQL database user.
  • SLACK_WEBHOOK_URL: Slack Incoming Webhook endpoint URL.

Quick start

  1. Configure PERPLEXITY_API_KEY, POSTGRES_PASSWORD, and SLACK_WEBHOOK_URL in your Kestra namespace secrets.
  2. Import this flow YAML into your Kestra instance.
  3. Click Execute in the UI with a sample corporate domain to test enrichment.
  4. Connect your web signup form to the generated Kestra Webhook URL.

Common pitfalls and troubleshooting

  • Consumer Email Domains: Free webmail domains (gmail.com, yahoo.com) lack corporate firmographics; filter consumer domains in front-end forms before webhook triggering.
  • API Token Credits: Ensure your Perplexity API account is configured with active usage credits for the sonar model.
  • Database Schema: Verify the target inbound_leads table exists in PostgreSQL with a unique constraint on the email column for upsert handling.

How to extend

  • Add io.kestra.plugin.hubspot.ContactCreate to automatically sync enriched leads into HubSpot CRM.
  • Generate personalized first-touch cold email copy using Claude or OpenAI based on the retrieved industry and funding data.
  • Score inbound leads using proprietary qualification algorithms in DuckDB before sales routing.

Links

See How

New to Kestra?

Use blueprints to kickstart your first workflows.