This project implements a Virtual Sales Agent that simulates customer interactions, providing information and support through a Streamlit interface. Using the power of LangChain, LangGraph, and a SQLite database, this agent can answer product questions, create orders, check order statuses, and offer personalized recommendations. These tools are divided into safe and sensitive categories. For sensitive tools, such as creating orders, a human-in-the-loop mechanism is implemented, requiring approval or denial before proceeding.
👉 Check out a quick demo of the Virtual Sales Agent in action in the Interface Preview section!
- Key Features
- Built With
- Use Cases
- Project Structure
- Interface Preview
- Get Started
- Contributing
- Related Resources
- Future Plans
- License
This virtual sales agent can assist customers with:
-
Product Inquiries:
- Answer questions about product availability, pricing, and stock levels.
- Example Questions:
- "What products do you have in stock?"
- "How much does product X cost?"
- "Is product Y available?"
-
Order Placement:
- Allow customers to create new orders, referencing data from the database.
- Example Request: "I would like to order 2 units of product Z."
-
Order Tracking:
- Provide up-to-date status information for existing orders.
- Example Question: "What is the status of order #54321?"
-
Personalized Recommendations:
- Suggest relevant products based on a customer's past purchase history.
- Example Recommendation: "Based on your previous order, you might also like product A."
This Virtual Sales Agent is ideal for:
- E-commerce websites to streamline customer service and increase sales.
- Customer support teams looking to automate routine tasks while maintaining user control.
- Sales teams to recommend personalized products based on purchase history.
- LangChain: Provides the framework for developing AI-powered conversational applications.
- LangGraph: Enables the creation of sophisticated, stateful agent workflows.
- SQLite: A lightweight database for managing product data and orders.
- Streamlit: Facilitates the development of interactive web applications for the agent interface.
- Gemini Flash 2.0: A fast and efficient large language model from Google for natural language understanding.
Here's a breakdown of the project's directory structure:
.
├── assets/
│ ├── agent_workflow.png # Diagram
│ ├── demo.gif # Demo gif
│ ├── graph.png # Agent workflow diagram
│ └── style.css # Streamlit custom styling
├── database/
│ ├── db/
│ │ ├── products.json # Bot product data (initial)
│ │ └── schemas.sql # SQL schema definitions
│ ├── db_manager.py # Handles database interactions
│ └── config.py # Database connection configuration
├── virtual_sales_agent/
│ ├── graph.py # LangGraph agent state machine and logic
│ ├── tools.py # Custom tools used by the agent
│ └── utils_functions.py # Utility functions for the agent
├── env-example # Environment variables template
├── main.py # Main Streamlit app
├── README.md # This file!
├── requirements.txt # Project dependencies
└── setup_database.py # Script to initialize the database
-
🎥 Demo GIF Here's a quick demonstration of the Virtual Sales Agent in action:
- Main Interface: A clean and intuitive chatbot interface that interacts with customers to answer queries and perform tasks.
- Human-in-the-Loop Approval System: A mechanism where sensitive actions, like order creation, require user approval. Users can review the action details and provide feedback for continuous improvement.
-
LangGraph Workflow
Follow these steps to set up and run the Virtual Sales Agent:
- Ensure you have Python 3.12 or later installed on your machine.
- We recommend using a virtual environment for managing dependencies.
-
Clone the Repository:
git clone https://github.com/lucasboscatti/sales-ai-agent-langgraph.git cd virtual-sales-agent
-
Create a Virtual Environment:
python3 -m venv venv source venv/bin/activate # Linux/Mac venv\Scripts\activate # Windows
-
Install Dependencies:
pip install -r requirements.txt
-
Environment Configuration:
- Rename the
.env-example
file to.env
. - Set up your API keys:
- Google Gemini Flash: Requires a
GOOGLE_API_KEY
, along with yourGOOGLE_APPLICATION_CREDENTIALS
(path to your credentials file),GCP_PROJECT_ID
andREGION
. Obtain these from your Google Cloud Platform (GCP) account at Google AI Studio. - LangSmith: Create a LangSmith account and get your
LANGCHAIN_API_KEY
. This is for monitoring and debugging agent interactions.
- Google Gemini Flash: Requires a
- Load environment variables:
source .env
- Rename the
-
Initialize the Database:
python3 setup_database.py
-
Launch the Streamlit App:
streamlit run main.py
This will open the application in your web browser, and you can start interacting with the Virtual Sales Agent.
We welcome contributions to improve this project! Here’s how you can help:
- Fork the repository and create a feature branch.
- Follow Python best practices (e.g., PEP 8).
- Submit a pull request with a clear description of your changes.
- For bug reports or feature requests, please open an issue.
- Fuzzy logic for product names matching
This project is licensed under the MIT License. See the LICENSE file for more details.