LIVE DEMO: https://autostream-ai-agent-5yfpqwgetdjlaffptrajvp.streamlit.app
This is a Conversational AI Agent built for AutoStream, a fictional SaaS company. The agent is designed to qualify sales leads, answer pricing questions using RAG, and capture user details (Name, Email, Platform) into a structured format.
- Framework: LangGraph (Stateful Multi-Turn Conversations)
- LLM: Google Gemini 2.5 Flash
- Knowledge Base: JSON-based RAG
- Logic: Hybrid Approach (LLM Context Extraction + Persistent State)
- Clone the Repository
git clone [https://github.com/Ujjwal-Sharma-Data/AutoStream-AI-Agent.git](https://github.com/Ujjwal-Sharma-Data/AutoStream-AI-Agent.git) cd AutoStream-AI-Agent - Install Dependencies
pip install -r requirements.txt
- Configure API key
- Create a .env file in the root folder.
- Add your Google Gemini API key:
GOOGLE_API_KEY="your_actual_key_here"
- Run the Agent
python3 main.py
The system follows a cyclic State Machine architecture:
- Input: User message enters the graph and is appended to the persistent conversation history.
- Analysis (The Brain): The
agent_nodeconstructs a prompt containing the full transcript and the current known state. The LLM analyzes this to extract new entities (Name, Email, Platform) contextually. - State Merge: Extracted entities are merged into the persistent
lead_datadictionary. - Decision:
- Missing Data: The agent asks a follow-up question.
- Complete Data: The
tool_check_nodevalidates the state and executesmock_lead_capture.
- Output: The final response is returned to the user.
I selected LangGraph over AutoGen because this task requires a deterministic control flow. Unlike AutoGen (which is better for open-ended multi-agent debates), LangGraph allows us to define strict loops—ensuring the agent cannot proceed to the "Tool Trigger" step until specific data criteria (Name/Email/Platform) are met.
State Management:
We utilize a Hybrid Persistence model. Instead of relying solely on the LLM's short-term memory, we maintain a structured AgentState dictionary. Every turn, the LLM acts as an extractor, parsing the transcript to find new information which is permanently saved to the lead_data state. This ensures "perfect memory" even if the user provides details out of order or changes topics.
To deploy this agent on WhatsApp, I would integrate the WhatsApp Business API with a Python webhook:
- Webhook: A FastAPI endpoint receives incoming HTTP POST requests from Meta containing the user's message and
wa_id(phone number). - Session Handling: The
wa_idserves as the unique session key. We retrieve the user's persisted LangGraph state from a Redis database using this key. - Execution: The message passes through the graph, updates the state, and the agent's text response is sent back via the
messagesAPI endpoint.