Skip to content

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.

License

Notifications You must be signed in to change notification settings

lucasboscatti/sales-ai-agent-langgraph

Repository files navigation

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 section!

Agent Workflow Diagram


Table of Contents

  1. Key Features
  2. Built With
  3. Use Cases
  4. Project Structure
  5. Interface Preview
  6. Get Started
  7. Contributing
  8. Related Resources
  9. Future Plans
  10. 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

  2. LangGraph Workflow

    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:

    git clone https://github.com/lucasboscatti/sales-ai-agent-langgraph.git
    cd virtual-sales-agent
  2. Create a Virtual Environment:

    python3 -m venv venv
    source venv/bin/activate    # Linux/Mac
    venv\Scripts\activate       # Windows
  3. Install Dependencies:

    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.
      • LangSmith: Create a LangSmith account and get your LANGCHAIN_API_KEY. This is for monitoring and debugging agent interactions.
    • Load environment variables:
      source .env
  5. Initialize the Database:

    python3 setup_database.py
  6. 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.


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


Future Plans

  • Fuzzy logic for product names matching

License

This project is licensed under the MIT License. See the LICENSE file for more details.


About

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.

Topics

Resources

License

Stars

Watchers

Forks