Skip to content

bevinkatti/lead-agentic-workflow

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Social-to-Lead Agentic Workflow

Assignment Submission for ServiceHive – Inflx

An AI-powered conversational lead generation system built for AutoStream, a fictional SaaS platform for creators.

This project converts inbound creator conversations into qualified leads using intelligent intent detection, local knowledge retrieval, session memory, lead qualification workflows, and automated tool execution.


Demo Preview

Demo


Why This Project

  • Real-time intent detection
  • Local RAG knowledge retrieval
  • Multi-turn conversational memory
  • Structured lead qualification flow
  • Automated lead capture tool execution
  • Full-stack analytics dashboard
  • Multi-model fallback architecture
  • Production-oriented backend + frontend design

Core Features

1. Intent Detection

The assistant classifies user messages into:

  • Greeting
  • Product / Pricing Inquiry
  • High Purchase Intent
  • Lead Capture Flow

Examples

  • Hi there
  • What is your pricing?
  • Which plan is best for YouTube creators?
  • I want to try Pro plan

2. Local RAG Knowledge Base

Responses are grounded using a local JSON knowledge base containing:

  • Pricing plans
  • Feature comparisons
  • Refund policy
  • Support availability
  • Plan recommendations

This reduces hallucinations and improves consistency.


3. Multi-turn Memory

The system stores per-session context and remembers prior user inputs.

Example

User: I upload videos daily on YouTube
Later: Which plan should I choose?

The assistant remembers creator context and recommends the Pro plan.


4. Lead Qualification Workflow

Captured leads are persisted to the database and can be reviewed through a private admin API endpoint.
When purchase intent is detected, the system collects:

  1. Full Name
  2. Email Address
  3. Creator Platform

Only after all fields are complete, the lead capture tool is triggered.

mock_lead_capture(name, email, platform)

5. Admin Dashboard

Includes:

  • Total chats
  • Total leads
  • Conversion metrics
  • Visual analytics charts

Architecture

This project uses a LangGraph-style agentic workflow where each stage has a clear responsibility.

Detect Intent
→ Retrieve Knowledge
→ Generate Smart Response
→ Qualify Lead
→ Collect Missing Fields
→ Execute Tool

This structure is more reliable than a single-prompt chatbot.


State Management

Conversation state is stored in backend session memory.

Each session tracks:

name
email
platform
lead_step
chat history

This enables realistic multi-turn interactions across 5–6 messages.


Reliability / Failover Design

To improve uptime, multiple LLM providers are supported:

1. Groq (Primary)
2. Gemini (Secondary)
3. Gemma (Tertiary)
4. Safe fallback response

This mirrors production resilience patterns.


Tech Stack

Backend

  • Python 3.11
  • FastAPI
  • SQLAlchemy
  • LangChain
  • LangGraph-style orchestration

Frontend

  • Next.js
  • TypeScript
  • Tailwind CSS
  • Axios
  • Recharts

Project Structure

backend/
  app/
    agent/
    api/
    kb/
    rag/
    models/
    main.py

frontend/
  app/
  components/

Run Locally

Backend

cd backend
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
uvicorn app.main:app --reload

Runs on:

http://localhost:8000

Frontend

cd frontend
npm install
npm run dev

Runs on:

http://localhost:3000

Admin Monitoring API

For internal monitoring and lead review, the backend exposes private admin endpoints:

  • GET /admin/stats → total leads, chats, conversion rate
  • GET /admin/leads → latest captured leads

Local URLs:

http://localhost:8000/admin/stats  

http://localhost:8000/admin/leads  

Environment Variables

Create .env inside backend/

GEMINI_API_KEY=your_key
GROQ_API_KEY=your_key
LLM_MODEL=models/gemini-2.0-flash-lite

WhatsApp Deployment Approach 📲

To support WhatsApp in production:

  1. Use Meta WhatsApp Cloud API webhooks
  2. Receive messages in FastAPI webhook endpoint
  3. Map phone number to conversation state
  4. Process through same AI workflow
  5. Send reply using Meta Graph API

This allows AutoStream to convert WhatsApp inquiries into qualified leads automatically.


Why This Is More Than a Chatbot

Unlike a basic assistant, this demonstrates:

  • Intent reasoning
  • Controlled workflows
  • Persistent memory
  • Tool execution gating
  • Multi-provider AI resilience

Author

Abhishek Bevinkatti

About

AI-powered Social-to-Lead Agentic Workflow for AutoStream | converts creator conversations into qualified leads using intent detection, RAG, memory, and automated lead capture.

Topics

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors