Skip to content

anshika476/ConversationalAI

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

7 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

AutoStream Conversational AI Agent 🤖

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).

Core Code

  • 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.json on 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.

Tech Stack

  • Python(3.9+)
  • LangGraph (State management and orchestration)
  • Google GenAI Python SDK (gemini-2.5-flash)
  • python-dotenv (Environment variable management)

Setup & Installation

1. Clone the repository.

git clone https://github.com/anshika476/ConversationalAI.git
cd ConversationalAI

2. Activate a virtual environment.

python -m venv .venv
# On Windows:
.venv\Scripts\activate
# On Mac/Linux:
source .venv/bin/activate

3. Install dependencies.

pip install -r requirements.txt

4. 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_here

Usage

Start the interactive terminal session by running:

python agent.py

Try it out!

Test the agent's intelligence by running through this conversation:

  1. "Hi! I am Anshika, an Instagram creator." (Agent will respond using the greeting flow)
  2. "What is your refund policy?" (Agent will respond using the RAG Q&A flow)
  3. "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!)

How State is Managed

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_step to "done"), which LangGraph automatically merges back into the global state.
  • Route: The StateGraph uses conditional edges to inspect the state (e.g., checking if lead_email is None) to decide whether to trigger the capture_tool or navigate back to the ask_field node.

Why LangGraph over Autogen?

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.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages