This project implements a simple AI agent using LangGraph that analyzes basic business data (daily revenue, costs, customers) and generates automated insights and recommendations.
- Profit/Loss
- Customer Acquisition Cost (CAC)
- Revenue per Customer
- Day-over-day changes (revenue, cost, CAC)
- Reduce costs if profit is negative
- Alert if CAC increases by more than 20%
- Suggest marketing adjustments based on trends
- Identify shrinking customer base or falling revenue per customer
- Highlight low margins or high cost ratios
๐ง Built using LangGraph for agent-based flow and state management
- Create and activate virtual environment (recommended)
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate- Install dependencies
pip install -r requirements.txtRun the agent on sample input:
from agent_graph import graph
sample_input = {
"data": {
"today": {"revenue": 2000, "cost": 1200, "customers": 40},
"yesterday": {"revenue": 1500, "cost": 1100, "customers": 35}
}
}
result = graph.invoke(sample_input)
print(result["recommendations"])Output Format:
{
"recommendations": {
"status": "Profit",
"alerts": ["CAC increased by more than 20%."],
"advice": [
"Review marketing campaigns due to increased CAC.",
"Consider increasing advertising budget due to growing sales."
]
}
}Run tests to validate various business scenarios:
python test_agent.py- Profit and growth
- Loss and rising CAC
- Shrinking customer base
- Low margin alerts
- Falling revenue per customer
- Stable scenario