Inspiration

Sales teams waste hours every day on repetitive manual work — researching prospects, qualifying fit, writing personalized emails, before they ever get to have a real conversation. I wanted to see if a chain of specialized AI agents could handle the entire top-of-funnel workflow end-to-end, while keeping humans in the loop where it matters most: the final approval before outreach goes out.

What it does

DealFlow chains 4 AI agents through Airia to automate the full B2B sales pipeline:

  1. ProspectScout — Scrapes the web (via Firecrawl) to build a research dossier on any company: industry, size, pain points, tech stack, recent news
  2. FitAnalyzer — Scores prospect-product fit across 5 dimensions using RAG against a product catalog, generating talking points and matched case studies
  3. PitchCraft — Crafts a hyper-personalized outreach email (<150 words) with specific hooks tied to the prospect's situation
  4. OutreachPilot — Sends the approved email via Gmail

A real-time dashboard lets reps watch the pipeline run live, review AI-generated drafts, edit them, and approve or reject before anything gets sent.

How we built it

  • Backend: FastAPI orchestrates the 4 Airia pipelines sequentially, storing intermediate state in SQLite (async SQLAlchemy). Server-Sent Events push real-time updates to the frontend as each agent step completes.
  • Frontend: Next.js + TypeScript + Tailwind CSS + shadcn/ui. SWR handles data fetching with SSE-triggered cache invalidation for live updates.
  • Airia Platform: Each agent is its own pipeline with structured JSON output. FitAnalyzer uses a Data Store (RAG) loaded with product catalog PDFs. OutreachPilot uses the Gmail tool for email delivery.

Challenges we ran into

  • AI response parsing: Airia models often return preamble text and markdown code fences around JSON. I built a robust extraction layer that handles code blocks, bracket matching, and direct parsing fallbacks.
  • Real-time updates: SSE via EventSource exhausted the browser connection pool. I switched to a fetch-based singleton pattern with AbortController for proper cleanup.
  • State persistence: SQLAlchemy doesn't detect mutations to JSON columns — I had to create new dict objects on every update for changes to persist.
  • Human-in-the-loop flow: Pausing a pipeline mid-execution and resuming it after approval required careful state management across the orchestrator, database, and frontend.

What we learned

Multi-agent orchestration is powerful but the glue code matters. The hardest parts weren't the AI — they were the state management, error recovery, and making the real-time UX feel seamless. Airia's structured output and tool integration (Firecrawl, Gmail) made the individual agents straightforward; the challenge was chaining them reliably with human checkpoints in between.

What's next

  • Follow-up sequence automation (if no reply in X days, generate a follow-up)
  • Batch processing for prospect lists
  • Analytics dashboard tracking conversion rates across fit scores
  • CRM integration (Salesforce/HubSpot) for automatic deal stage syncing

Built With

Share this project:

Updates