DEV Community

Cover image for How I Built a Scalable AI Outreach Engine with FastAPI and Cloud Run
KAILAS VS
KAILAS VS

Posted on

How I Built a Scalable AI Outreach Engine with FastAPI and Cloud Run

Most cold outreach platforms are either:

  • expensive,
  • heavily restricted,
  • or difficult to customize for real operational workflows.

So I started building an internal outreach automation system under Aurvyz β€” an engineering-focused company building intelligent systems, automation infrastructure, and scalable operational tools for businesses.

🌐 www.aurvyz.com

The goal wasn’t just β€œsend emails”.

The goal was building a scalable operational system capable of handling:

  • lead imports
  • AI-generated personalization
  • multi-step campaign flows
  • follow-up automation
  • reply classification
  • real-time tracking

πŸš€ Core Features

🧠 AI-Driven Personalization

The system uses the Google Gemini API to generate:

  • contextual intro lines
  • personalized outreach
  • follow-up variations
  • reply classifications

Instead of static templates, the engine dynamically generates messaging based on:

  • company information
  • industry
  • lead context
  • workflow relevance

πŸ“‚ Apollo CSV Import & Validation

The platform supports large Apollo lead imports with:

  • CSV validation
  • email verification workflows
  • deduplication
  • lead normalization

This allows campaigns to scale while keeping data quality clean.

⏰ Intelligent Scheduling & Send Windows

One of the biggest challenges in outreach automation is avoiding β€œrobotic” sending behavior.

The system includes:

  • custom send windows
  • weekday-only automation
  • randomized delays
  • sequence timing logic

Example:

send only between 9 AM – 5 PM
wait 3 business days before follow-up
randomize delivery timing between emails

This helps mimic natural human sending patterns.

πŸ“¦ Multi-Step Campaign Architecture

Instead of one-off email blasts, the platform is designed around conversational campaign flows.

Example sequence:

Intro β†’ Follow-up β†’ Value Add β†’ Re-engagement

Features include:

  • unlimited sequence steps
  • precision delay configuration
  • automated progression logic
  • reply-aware scheduling

πŸ›‘ Intelligent Stop-on-Reply Logic

One of the most important systems in the platform is the reply interruption engine.

Once a reply is detected:

all future sequence steps are halted automatically
the lead is marked for human takeover
campaign progression stops instantly

This prevents awkward double-outreach and duplicate follow-ups.

πŸ“¨ Multi-Infrastructure Email Engine

The delivery layer integrates multiple providers:

  • Resend
  • Postmark
  • Zoho SMTP
    The architecture supports:

  • provider fallback routing

  • delivery retries

  • bounce handling

  • provider failover

If one provider fails, the system can automatically reroute delivery traffic.

🏷️ AI Reply Classification

Incoming replies are processed using LLM classification logic.

Replies are automatically categorized into:

  • Interested
  • Later
  • Not a fit
  • Booked call

This makes campaign management significantly easier.

⚑ Architecture Highlights

The most interesting part of this project has been building the distributed processing architecture.

πŸš€** Async-First FastAPI Backend**

The API layer is built using FastAPI with async-first patterns for handling:

  • concurrent requests
  • webhook ingestion
  • scheduling orchestration
  • AI generation workflows

⛓️ Celery + Redis Distributed Workers

Heavy operations are fully decoupled from the API layer:

  • email sending
  • AI generation
  • scheduling
  • follow-up processing

This keeps the main application responsive while workers handle background tasks asynchronously.

πŸ—οΈ Horizontally Scalable Workers

Workers are deployed independently and can scale horizontally based on workload.

This allows the system to handle:

10 emails
or 10,000 emails

using the same architecture.

⚑ Real-Time Webhook Processing

Instead of polling inboxes repeatedly, the platform uses webhook-driven event processing for:

  • replies
  • opens
  • clicks
  • delivery events

This significantly reduces latency and unnecessary processing overhead.

πŸ› οΈ Tech Stack

  • Frontend
  • Next.js 15
  • TypeScript
  • Tailwind CSS
  • shadcn/ui
  • Backend
  • FastAPI
  • SQLAlchemy
  • PostgreSQL
  • Celery
  • Redis
  • Infrastructure
  • Docker
  • Jenkins CI/CD
  • Google Cloud Run
  • Cloud Scheduler

πŸ’‘ Engineering Challenges

Some of the more interesting problems included:

  • designing distributed campaign progression
  • building stop-on-reply orchestration
  • handling multi-provider email failover
  • scheduling around business-day logic
  • scaling AI generation workloads asynchronously

🀝 Collaboration & Exploration

Currently exploring and collaborating around:

  • AI systems & workflow automation
  • scalable backend architecture
  • distributed worker systems
  • product engineering
  • SaaS infrastructure
  • operational tooling

Always interested in connecting with:

  • developers
  • founders
  • product teams
  • early-stage startups
  • automation-focused businesses

Built under Aurvyz
Intelligence, Engineered.

🌐 www.aurvyz.com

AI #FastAPI #Python #NextJS #Redis #Celery #CloudRun #SoftwareEngineering #BuildInPublic

Top comments (0)