An open API service indexing awesome lists of open source software.

https://github.com/lucasboscatti/sales-ai-agent-langgraph

A Virtual Sales Agent that uses LangChain, LangGraph, and Gemini Flash to simulate customer interactions. Features include product inquiries, order management, and personalized recommendations through a user-friendly Streamlit interface.
https://github.com/lucasboscatti/sales-ai-agent-langgraph

Last synced: 3 months ago
JSON representation

A Virtual Sales Agent that uses LangChain, LangGraph, and Gemini Flash to simulate customer interactions. Features include product inquiries, order management, and personalized recommendations through a user-friendly Streamlit interface.

Awesome Lists containing this project

README

        

# Virtual Sales Agent powered by LangGraph, Streamlit & Gemini Flash

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](#interface-preview) section!

![Agent Workflow Diagram](./assets/agent_workflow.png)

---

## Table of Contents
1. [Key Features](#key-features)
2. [Built With](#built-with)
3. [Use Cases](#use-cases)
4. [Project Structure](#project-structure)
5. [Interface Preview](#interface-preview)
6. [Get Started](#get-started)
7. [Contributing](#contributing)
8. [Related Resources](#related-resources)
9. [Future Plans](#future-plans)
10. [License](#license)

---

## Key Features

This virtual sales agent can assist customers with:

1. **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?"

2. **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."

3. **Order Tracking:**
- Provide up-to-date status information for existing orders.
- **Example Question:** "What is the status of order #54321?"

4. **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."

---

## Use Cases

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.

---

## Built With

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

---

## Project Structure

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
```

---

## Interface Preview

1. **πŸŽ₯ 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.

![Demo GIF](./assets/demo.gif)

2. **LangGraph Workflow**

![Virtual Sales Agent Interaction Flow](./assets/graph.png "Virtual Sales Agent Interaction Flow")

---

## Get Started

Follow these steps to set up and run the Virtual Sales Agent:

### Prerequisites

- Ensure you have **Python 3.12 or later** installed on your machine.
- We recommend using a virtual environment for managing dependencies.

### Installation Steps

1. **Clone the Repository:**
```bash
git clone https://github.com/lucasboscatti/sales-ai-agent-langgraph.git
cd virtual-sales-agent
```

2. **Create a Virtual Environment:**
```bash
python3 -m venv venv
source venv/bin/activate # Linux/Mac
venv\Scripts\activate # Windows
```

3. **Install Dependencies:**
```bash
pip install -r requirements.txt
```

4. **Environment Configuration:**
- Rename the `.env-example` file to `.env`.
- Set up your API keys:
- **Google Gemini Flash:** Requires a `GOOGLE_API_KEY`, along with your `GOOGLE_APPLICATION_CREDENTIALS` (path to your credentials file), `GCP_PROJECT_ID` and `REGION`. Obtain these from your Google Cloud Platform (GCP) account at [Google AI Studio](https://aistudio.google.com/).
- **LangSmith:** Create a [LangSmith](https://smith.langchain.com/) account and get your `LANGCHAIN_API_KEY`. This is for monitoring and debugging agent interactions.
- Load environment variables:
```bash
source .env
```

5. **Initialize the Database:**
```bash
python3 setup_database.py
```

6. **Launch the Streamlit App:**
```bash
streamlit run main.py
```

This will open the application in your web browser, and you can start interacting with the Virtual Sales Agent.

---

## Contributing

We welcome contributions to improve this project! Here’s how you can help:
1. Fork the repository and create a feature branch.
2. Follow Python best practices (e.g., PEP 8).
3. Submit a pull request with a clear description of your changes.
4. For bug reports or feature requests, please open an issue.

---

## Related Resources

- [LangChain Documentation](https://python.langchain.com/docs/introduction/)
- [LangGraph Documentation](https://langchain-ai.github.io/langgraph/tutorials/introduction/)
- [Streamlit Documentation](https://docs.streamlit.io)
- [Google Gemini Flash](https://aistudio.google.com/)

---

## Future Plans

- Fuzzy logic for product names matching

---

## License

This project is licensed under the MIT License. See the [LICENSE](LICENSE) file for more details.

---