An intelligent, stateful AI sales agent built for AutoStream ( SaaS product that provides automated video editing tools for content creators.) using LangGraph and Google Gemini (2.5 Flash).
- Agent logic: Utilizes an orchestrating flowchart (LangGraph) that manages short-term memory, decides conversational routing, and transitions seamlessly between standard chat and aggressive lead-capture flows without dropping context.
- RAG pipeline: Ingests the company's
knowledege_base.jsonon startup and intelligently answers questions regarding pricing plans, features, and cancellation policies without hallucinating. - Intent detection: Dynamically analyzes every single user input to classify the hidden intent (greeting, inquiry, or lead), ensuring the agent always acts according to the user's actual goal.
- Tool execution: Automatically executes mock backend tools (like
mock_lead_capture) when specific criteria are met, simulating the process of writing finalized leads to a real-world CRM database.
- Python(3.9+)
- LangGraph (State management and orchestration)
- Google GenAI Python SDK (
gemini-2.5-flash) - python-dotenv (Environment variable management)
1. Clone the repository.
git clone https://github.com/anshika476/ConversationalAI.git
cd ConversationalAI2. Activate a virtual environment.
python -m venv .venv
# On Windows:
.venv\Scripts\activate
# On Mac/Linux:
source .venv/bin/activate3. Install dependencies.
pip install -r requirements.txt4. Set up your environment variables.
Create a .env file in the root directory and add your Google Gemini API key:
GEMINI_API_KEY=your_actual_gemini_api_key_hereStart the interactive terminal session by running:
python agent.pyTest the agent's intelligence by running through this conversation:
"Hi! I am Anshika, an Instagram creator."(Agent will respond using the greeting flow)"What is your refund policy?"(Agent will respond using the RAG Q&A flow)"I'd like to sign up for the Pro plan!"(Agent detects high intent and switches to the Lead Generation flow. It will automatically remember your name and platform from Step 1, and only ask you for your email address!)
State is maintained via a centralized AgentState TypedDict. This object acts as the agent's "short-term memory," holding structured data (like lead_name and intent) and unstructured data (the messages transcript).
The system follows a strict "Read-Update-Route" cycle:
- Read: Each node receives the current state as its primary input, ensuring a single source of truth for the entire conversation.
- Update: Nodes return only the changes (e.g., updating
lead_stepto"done"), which LangGraph automatically merges back into the global state. - Route: The
StateGraphuses conditional edges to inspect the state (e.g., checking iflead_emailisNone) to decide whether to trigger thecapture_toolor navigate back to theask_fieldnode.
This agent is built using LangGraph to handle complex, non-linear conversation flows. Unlike simple chatbots, AutoStream uses a state machine architecture to ensure reliability and context-retention. I chose LangGraph over linear chains because it allows for cyclical logic. If a user provides an invalid email address, the agent doesn't crash or move forward with bad data; it simply loops back to the extraction and collection nodes until the business requirements are met.