Skip to content

Navigation Menu

Sign in
Sign up

Repository files navigation

🎫 Ticket Agent

An intelligent multi-role support ticket agent powered by LangGraph and Snowflake Cortex and Streamlit. This system automates the lifecycle of a support ticketβ€”from initial AI-driven triage and priority classification to human-in-the-loop administrative resolution.

✨ Features

  • Smart New-Ticket Evaluation – Evaluates new issues (priority + metadata) before ticket creation and response generation
  • Snowflake Cortex Search – Retrieves relevant past tickets and knowledge base context to inform responses
  • AI + Human Support Loop – Combines AI-generated replies with admin human-in-the-loop intervention in the same chat threads
  • Lifecycle Tracking & Resolution – Stores all agent messages and runs resolution checks to keep ticket status up to date

πŸ‘₯ Dual-Role Interface

The system features a unified routing architecture in frontend/app.py that allows seamless switching between two distinct user experiences, managed via a global sidebar toggle.

πŸ‘€ User Experience

  • Support Desk Landing: A dedicated home page to raise new problems or check the status of existing ones.
  • Live Status Tracking: Real-time ticket lookups with direct "Open Chat" links to resume active conversations.
  • Ticket History: A searchable, tabular overview of all personal past tickets for easy reference.
  • AI-Driven Chat: Direct interaction with the Mistral-powered agent for immediate troubleshooting and automated triage.

πŸ”‘ Administrator Dashboard

  • Queue Management: A comprehensive view of all system tickets with visual color indicators for priority (URGENT to LOW) and status.
  • Advanced Triage: Built-in tools to filter the queue by status (OPEN/CLOSED) and sort by urgency, subject, or update recency.
  • Human-in-the-Loop Override: Admins can enter any active chat thread to provide manual assistance alongside the AI agent.
  • One-Click Resolution: Streamlined controls to close resolved tickets directly from the dashboard or within the chat view.

πŸ’¬ Hybrid Chat System

  • Shared Interface: Both roles utilize the same user_chat.py component, ensuring a consistent history of both AI and human responses.
  • Visual Role Cues: The chat interface identifies messages from "Users," "AI Agents," and "Human Agents" (Admins) using distinct avatars and alignments to maintain clarity.

πŸ—οΈ Architecture

The agent uses a LangGraph state machine with the following workflow:

stateDiagram-v2
 [*] --> load_history
 load_history --> retrieve
 retrieve --> evaluate_ticket: new_ticket
 evaluate_ticket --> create_ticket
 create_ticket --> generate
 retrieve --> update_ticket: existing_ticket
 update_ticket --> generate
 generate --> store_agent_message
 store_agent_message --> check_for_resolution
 check_for_resolution --> [*]
Loading

Nodes

Node Description
load_history Loads past ticket messages
evaluate_ticket Evaluates ticket priority and metadata for new tickets
retrieve Fetches relevant context from Snowflake Cortex Search
generate Generates a support response based on priority and context
create_ticket Creates a new ticket in the database
update_ticket Adds a message to an existing ticket
store_agent_message Persists the agent's response
check_for_resolution Checks if the issue is resolved and updates ticket status

πŸ“ Project Structure

ticket_agent/
β”œβ”€β”€ backend/
β”‚ β”œβ”€β”€ agent.py # Main agent entry point
β”‚ β”œβ”€β”€ db/
β”‚ β”‚ β”œβ”€β”€ snowflake_utils.py # Snowflake session management utils
β”‚ β”‚ β”œβ”€β”€ sql_utils.py # SQL execution helpers
β”‚ β”‚ β”œβ”€β”€ zen_repo.py # Ticket repository operations
β”‚ β”‚ β”œβ”€β”€ csv/ # CSV files for sample data
β”‚ β”‚ β”œβ”€β”€ tables/ # SQL table definitions
β”‚ β”‚ β”œβ”€β”€ views/ # SQL view definitions
β”‚ β”‚ └── cortex_search_services/ # SQL cortex definitions
β”‚ β”œβ”€β”€ graph/
β”‚ β”‚ β”œβ”€β”€ graph.py # LangGraph workflow definition
β”‚ β”‚ β”œβ”€β”€ router.py # Conditional routing logic
β”‚ β”‚ β”œβ”€β”€ state.py # State schema definition
β”‚ β”‚ └── nodes/ # Individual graph nodes
β”‚ └── llm/
β”‚ └── model.py # LLM configuration
β”œβ”€β”€ scripts/
β”‚ β”œβ”€β”€ setup_db.py # Database setup script
β”‚ └── chat_with_agent.py # CLI chat interface
β”œβ”€β”€ frontend/
β”‚ β”œβ”€β”€ app.py # Streamlit app entry point
β”‚ └── views/ # Streamlit app pages
β”œβ”€β”€ requirements.txt
β”œβ”€β”€ Makefile
└── .env.example

πŸš€ Getting Started

Prerequisites

  • Python 3.10+
  • Snowflake account with Cortex enabled
  • Mistral API key (used in backend/llm/model.py, you can change the code to use another LLM)
  • Environment: Ensure your .env contains your Snowflake credentials and MISTRAL_API_KEY

Installation

  1. Clone the repository

    git clone <repository-url>
    cd ticket_agent
  2. Create and activate a virtual environment

    make venv
    source venv/bin/activate
  3. Configure environment variables

    Copy the example file and fill in your credentials:

    cp .env.example .env

    Required variables:

    Variable Description
    SNOWFLAKE_ACCOUNT Your Snowflake account identifier
    SNOWFLAKE_USER Snowflake username
    SNOWFLAKE_TOKEN Snowflake password/token
    MISTRAL_API_KEY API key
    SNOWFLAKE_WAREHOUSE Compute warehouse name
    SNOWFLAKE_DATABASE Database containing your data
    SNOWFLAKE_SCHEMA Schema name
    SNOWFLAKE_CORTEX_SEARCH_SERVICE Cortex Search service name

Running the Agent

To test the agent through command line, run:

make run_agent
# or
PYTHONPATH=.:backend python scripts/chat_with_agent.py

Running the Frontend

Start the ticketing system UI:

make app
# or
streamlit run frontend/app.py

πŸ› οΈ Technologies

About

IT Support ticketing agentic system

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages

AltStyle γ«γ‚ˆγ£γ¦ε€‰ζ›γ•γ‚ŒγŸγƒšγƒΌγ‚Έ (->γ‚ͺγƒͺγ‚ΈγƒŠγƒ«) /