AutoStream is an AI-powered SaaS platform that provides automated video editing tools for content creators on YouTube, Instagram, TikTok, and other platforms.
This project implements a Social-to-Lead Agentic Workflow that:
- Understands user intent (greeting, product inquiry, high-intent lead)
- Answers questions using RAG (Retrieval-Augmented Generation)
- Identifies high-intent users
- Captures leads with contact information
We chose LangChain because:
- Built-in Memory Management: LangChain's
ConversationBufferWindowMemoryautomatically manages conversation history for 5-6 turns - Modular Design: Separates concerns (prompts, chains, memory) making the code maintainable
- RAG Integration: Native support for vector stores and retrieval chains
- Production-Ready: Industry standard for building LLM applications
State is managed through:
- ConversationBufferWindowMemory: Stores last 5 conversation turns automatically
- Stateful Agent Class: Maintains conversation context across multiple interactions
- Session State: Tracks lead capture progress (name, email, platform collection)
User Input
β
Intent Detection (LangChain + LLM)
β
RAG Retrieval (ChromaDB Vector Store)
β
Response Generation (LangChain Chain)
β
High Intent? β Lead Capture Tool
β
Save to CSV & Call mock_lead_capture()
- Python 3.9+
- HuggingFace API Token (free tier)
git clone https://github.com/yourusername/autostream-ai-agent.git
cd autostream-ai-agentpython -m venv venv
# On Windows
venv\Scripts\activate
# On Mac/Linux
source venv/bin/activatepip install -r requirements.txt# Copy example env file
cp .env.example .env
# Edit .env and add your HuggingFace token
# Get token from: https://huggingface.co/settings/tokensYour .env file should look like:
HF_TOKEN=hf_your_token_here
python main.pyautostream-ai-agent/
βββ README.md # Project documentation
βββ requirements.txt # Python dependencies
βββ .env.example # Environment variables template
βββ .gitignore # Git ignore rules
βββ config/
β βββ knowledge_base.json # AutoStream product documentation
βββ src/
β βββ __init__.py
β βββ agent.py # Main agent logic with LangChain
β βββ rag_system.py # RAG implementation with ChromaDB
β βββ intent_detector.py # Intent classification
β βββ lead_capture.py # Lead capture tool and logic
β βββ utils.py # Helper functions
βββ data/
β βββ leads.csv # Captured leads (auto-generated)
βββ main.py # Entry point
Classifies user intent into:
- greeting: Casual greetings
- product_inquiry: Questions about features, pricing, plans
- high_intent: Ready to sign up or try the product
- Uses ChromaDB vector store for document retrieval
- Embedding model:
sentence-transformers/all-MiniLM-L6-v2 - Retrieves top-2 most relevant documents per query
When high-intent is detected:
- Collects: Name, Email, Creator Platform
- Validates all inputs
- Calls
mock_lead_capture(name, email, platform) - Saves to
data/leads.csv
- Maintains last 5 conversation turns using LangChain's memory
- Context-aware responses based on conversation history
You: Hi, tell me about your pricing.
[Intent: product_inquiry]
Agent: AutoStream offers two pricing plans. Our Basic Plan is $29/month
with 10 videos per month at 720p resolution. Our Pro Plan is
$79/month with unlimited videos, 4K resolution, and AI-powered
captions with 24/7 support.
You: That sounds good, I want to try the Pro plan for my YouTube channel.
[Intent: high_intent]
Agent: That's fantastic! I'd love to help you get started with AutoStream Pro.
Let me collect a few details to set up your account.
Your name: John Doe
Your email: john@example.com
Creator Platform: YouTube
β
Lead captured successfully!
Name: John Doe
Email: john@example.com
Platform: YouTube
1. Setup Webhook Server
- Deploy this agent on a cloud server (AWS, GCP, Azure, or Heroku)
- Create a REST API endpoint (e.g., using Flask/FastAPI) that receives POST requests
2. Register Webhook with WhatsApp Business API
# Example webhook endpoint
@app.post("/webhook")
def whatsapp_webhook(request):
user_message = request.json['message']
user_phone = request.json['phone']
# Process with AutoStream Agent
response = agent.process_message(user_message)
# Send back to WhatsApp
send_whatsapp_message(user_phone, response)3. Message Flow
User sends WhatsApp message
β
WhatsApp β Your Webhook (POST /webhook)
β
Your Agent processes message
β
Your Webhook β WhatsApp API (send response)
β
User receives response on WhatsApp
4. State Management for WhatsApp
- Store conversation state per phone number in Redis/Database
- Load conversation history when webhook receives message
- Update state after each interaction
5. Lead Capture on WhatsApp
- Collect information in multi-turn conversation
- Store leads in database instead of CSV
- Send confirmation message after successful capture
Tools Needed:
- WhatsApp Business API account
- Twilio/MessageBird for WhatsApp API access
- Cloud hosting (for webhook endpoint)
- Redis/PostgreSQL (for session management)
- Greeting: "Hi", "Hello", "Hey there"
- Product Questions: "What features do you have?", "Tell me about pricing"
- High Intent: "I want to sign up", "Let me try Pro plan"
During conversation, type:
leads
clear
- β Intent Identification: 3 intents (greeting, product_inquiry, high_intent)
- β RAG-Powered Knowledge: ChromaDB with AutoStream documentation
- β
Tool Execution:
mock_lead_capture(name, email, platform) - β State Management: LangChain memory for 5-6 turns
- β Framework: LangChain implementation
- β LLM: HuggingFace API (Llama 3.3 70B Instruct)
- β Proper Tool Calling: Collects all 3 fields before calling API
Basic Plan - $29/month
- 10 videos/month
- 720p resolution
Pro Plan - $79/month
- Unlimited videos
- 4K resolution
- AI captions
- 24/7 support
- No refunds after 7 days
- 24/7 support only on Pro plan
- 14-day free trial available
- LangChain: Agent framework and memory management
- HuggingFace: LLM API (Llama 3.3 70B)
- ChromaDB: Vector database for RAG
- Sentence Transformers: Text embeddings
- Python 3.9+: Core language
This project is created as part of the ServiceHive ML Intern Assignment.
[Namit kumar]
- GitHub: @yourusername
- Email: er.kumarnamit00@gmail.com
- ServiceHive for the assignment opportunity
- Anthropic, HuggingFace, and LangChain for the tools