FollowUpAI

πŸ¦… FollowUpAI: Autonomous Sales Recovery Agent

Python Next.js FastAPI License

β€œTurn dead leads into revenue with autonomous, multi-channel engagement.”

FollowUpAI is an enterprise-grade autonomous agent system designed to automate the most painful part of sales: The Follow-Up. It intelligently orchestrates communication across Email and WhatsApp, using state-of-the-art LLMs (Llama-3 via Groq) to personalize content, detect intent, and recover stalled pipelines without human intervention.


πŸ“– Table of Contents


πŸš€ The Problem & Solution

The Pain πŸ“‰

Sales teams lose 48% of leads simply because they don’t follow up enough. Manual follow-ups are tedious, unpersonalized, and hard to scale. Leads go β€œcold” and revenue is left on the table.

The Solution πŸ“ˆ

FollowUpAI acts as a tireless SDR (Sales Development Representative).

  1. Ingests Leads: Takes in leads from CSVs or CRM integrations.
  2. Analyzes Context: Uses AI to research the prospect (via Tavily) and understand their potential needs.
  3. Autonomous Outreach: Sends personalized emails (Resend) and WhatsApp messages (Twilio) based on a strategic cadence.
  4. Handling Replies: If a lead replies, the AI analyzes the sentiment (Interested, Not Interested, OOO) and updates the pipeline status automatically.

πŸ—οΈ System Architecture

The application follows a Micro-Service Ready architecture, separating the API layer from the background worker layer to ensure scalability and fault tolerance.

graph TD
    subgraph "Frontend Layer (Vercel)"
        Web[Next.js 14 Dashboard]
        Components[Shadcn UI + Tailwind]
    end

    subgraph "API Layer (Render / Cloud Run)"
        API[FastAPI Server]
        Auth[OAuth2 + JWT Service]
    end

    subgraph "Worker Layer (Async)"
        Broker[Redis Message Broker]
        Worker[Taskiq Worker Process]
        LangGraph[LangGraph State Machine]
    end

    subgraph "Data Persistence"
        DB[(PostgreSQL)]
    end

    subgraph "External Providers"
        Groq[Groq Llama-3 API]
        Tavily[Tavily Search API]
        Resend[Resend Email API]
        Twilio[Twilio WhatsApp API]
    end

    Web -->|HTTPS/JSON| API
    API -->|Write/Read| DB
    API -->|Enqueue Task| Broker
    Broker -->|Consume| Worker
    Worker -->|Execute Agent| LangGraph
    LangGraph -->|Inference| Groq
    LangGraph -->|Research| Tavily
    LangGraph -->|Send| Resend
    LangGraph -->|Send| Twilio
    Worker -->|Update Status| DB

πŸ› οΈ Tech Stack & Decisions

We chose β€œBoring Technology” for infrastructure and β€œBleeding Edge” for AI.

Component Technology Why We Chose It
Backend FastAPI Python offers the best AI ecosystem. FastAPI provides async concurrency and auto-generated docs.
Frontend Next.js 14 React Server Components for performance; standard for modern web apps.
Database PostgreSQL Relational data integrity is critical for CRM data. (Neon Tech for Serverless).
Queue Redis + Taskiq Decouples heavy AI processing from the specialized user-facing API.
AI Model Llama-3 (Groq) Near-instant inference speed (~800 t/s) is crucial for real-time agent loops.
Orchestration LangGraph Provides cyclic graph capability (Loops) which standard RAG chains lack.

⚑ Key Features


πŸ”§ Getting Started (Local)

Prerequisites

1. Clone & Configure

git clone https://github.com/Aisenh037/FollowUpAI.git
cd FollowUpAI

2. Backend Setup

cd backend
python -m venv venv
# Windows
.\venv\Scripts\activate
# Mac/Linux
source venv/bin/activate

pip install -r requirements.txt
cp .env.example .env
# Edit .env with your API Keys (Groq, Resend, etc.)

3. Frontend Setup

cd frontend
npm install
cp .env.example .env.local
npm run dev

Visit http://localhost:3000 to see the app!


☁️ Deployment (Cloud)

This project is optimized for β€œServerless” Deployment.

See RENDER_VERCEL_DEPLOY.md for the step-by-step guide.


🧠 AI Logic (The Brain)

The core logic resides in backend/agents. We use a State Graph:

  1. State: LeadStatus (New, Researching, Contacted, Waiting, Replied).
  2. Nodes: Python functions that perform work (e.g., research_lead, draft_email).
  3. Edges: Conditional logic (e.g., if reply_received -> stop_sequence).

This determinism ensures the AI never goes β€œrogue” and always follows business rules.


πŸ“‚ Project Structure

FollowUpAI/
β”œβ”€β”€ backend/
β”‚   β”œβ”€β”€ agents/           # LangGraph Agent Logic
β”‚   β”œβ”€β”€ routes/           # FastAPI Endpoints
β”‚   β”œβ”€β”€ services/         # Business Logic (Email, DB)
β”‚   β”œβ”€β”€ models/           # SQLAlchemy Database Models
β”‚   β”œβ”€β”€ main.py           # App Entrypoint
β”‚   └── worker.py         # Taskiq Worker Entrypoint
β”œβ”€β”€ frontend/
β”‚   β”œβ”€β”€ app/              # Next.js App Router Pages
β”‚   β”œβ”€β”€ components/       # Reusable UI Components
β”‚   β”œβ”€β”€ lib/              # API Clients & Utilities
β”‚   └── types/            # TypeScript Interfaces
└── docker-compose.yml    # Local Dev Orchestration

πŸ›£οΈ Roadmap


πŸ‘¨β€πŸ’» Author

Built with ❀️ by Karan as a demonstration of advanced AI Engineering.