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.
- 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
The assistant classifies user messages into:
- Greeting
- Product / Pricing Inquiry
- High Purchase Intent
- Lead Capture Flow
Examples
Hi thereWhat is your pricing?Which plan is best for YouTube creators?I want to try Pro plan
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.
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.
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:
- Full Name
- Email Address
- Creator Platform
Only after all fields are complete, the lead capture tool is triggered.
mock_lead_capture(name, email, platform)Includes:
- Total chats
- Total leads
- Conversion metrics
- Visual analytics charts
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.
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.
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.
- Python 3.11
- FastAPI
- SQLAlchemy
- LangChain
- LangGraph-style orchestration
- Next.js
- TypeScript
- Tailwind CSS
- Axios
- Recharts
backend/
app/
agent/
api/
kb/
rag/
models/
main.py
frontend/
app/
components/
cd backend
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
uvicorn app.main:app --reloadRuns on:
http://localhost:8000
cd frontend
npm install
npm run devRuns on:
http://localhost:3000
For internal monitoring and lead review, the backend exposes private admin endpoints:
GET /admin/stats→ total leads, chats, conversion rateGET /admin/leads→ latest captured leads
Local URLs:
http://localhost:8000/admin/stats
http://localhost:8000/admin/leads
Create .env inside backend/
GEMINI_API_KEY=your_key
GROQ_API_KEY=your_key
LLM_MODEL=models/gemini-2.0-flash-liteTo support WhatsApp in production:
- Use Meta WhatsApp Cloud API webhooks
- Receive messages in FastAPI webhook endpoint
- Map phone number to conversation state
- Process through same AI workflow
- Send reply using Meta Graph API
This allows AutoStream to convert WhatsApp inquiries into qualified leads automatically.
Unlike a basic assistant, this demonstrates:
- Intent reasoning
- Controlled workflows
- Persistent memory
- Tool execution gating
- Multi-provider AI resilience
Abhishek Bevinkatti
