Skip to content

About

Autonomous AI-powered customer support & ticketing backend built with Spring Boot, Spring AI, and MySQL. Features real LLM tool calling, persistent JDBC chat memory, and live SSE streaming.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Latest commit

Β 

History

7 Commits

Folders and files

NameName
Last commit message
Last commit date
Β 
Β 
Β 
Β 

Repository files navigation

🎧 Help Desk System

AI-Powered Customer Support & Ticketing Backend

An autonomous AI assistant that doesn't just chat β€” it actually creates, tracks, and updates support tickets in a real database.

Java Spring Boot Spring AI MySQL


πŸ’‘ What Is This?

Most AI chatbots just talk. This one acts.

Meet Liza β€” an AI help desk assistant built with Spring AI's Tool Calling feature. When a user reports an issue, Liza doesn't just respond with a canned message. She:

  1. πŸ” Checks the database for existing tickets using the user's email
  2. 🎫 Creates a real ticket in MySQL with auto-generated ID, priority, and status
  3. ✏️ Updates existing tickets when users provide additional details
  4. 🧠 Remembers the entire conversation across sessions (persistent JDBC memory)

The key difference? Every ticket ID Liza mentions is real β€” pulled from the database, not hallucinated.


πŸ— Architecture

flowchart LR
    Client["πŸ–₯️ Client"] -->|POST /api/v1/ai| API["AiController"]
    
    API --> ChatClient["ChatClient + Memory Advisor"]
    ChatClient <-->|Inference| LLM["☁️ Groq LLM"]
    
    LLM -->|"Tool Call"| Tools["πŸ”§ TicketDatabaseTool"]
    Tools --> DB[("πŸ—„οΈ MySQL")]
    
    ChatClient <-->|"Chat History"| DB
Loading

✨ Features

πŸ€– Autonomous Agent

Liza collects issue details step-by-step, asks clarifying questions, determines priority, and only creates a ticket when she has everything she needs.

πŸ› οΈ Real Tool Execution

The LLM doesn't fake it β€” it invokes actual Java methods annotated with @Tool that execute database queries via JPA.

🧠 Persistent Memory

Conversations survive server restarts. Backed by MySQL via JdbcChatMemoryRepository with a sliding window of 15 messages.

⚑ Streaming Responses

Real-time Server-Sent Events (SSE) for a live typing experience on the frontend via Flux<String>.

πŸ›‘οΈ Zero Hallucinated IDs

Ticket IDs come from MySQL's AUTO_INCREMENT, not the LLM's imagination. The system prompt strictly enforces tool usage.

🌐 Frontend-Ready

CORS enabled, POST-based API, optional ConversationId header with safe defaults β€” plug any frontend right in.


πŸ”§ Tools the LLM Can Call

Tool What It Does
createTicketTool Saves a new ticket (summary, description, category, priority, email) to MySQL
getTicketsByEmail Looks up all existing tickets for a user β€” prevents duplicates
updateTicket Appends notes, changes status/priority on an existing ticket
getCurrentTime Returns current system timestamp when the LLM needs it

Each tool accepts a lightweight Java record (not the raw JPA entity) to avoid deserialization crashes with dates and enums.


πŸš€ Quick Start

Prerequisites

  • JDK 25+
  • MySQL 8.0+ running on localhost:3306
  • A Groq API Key (free at console.groq.com)

1. Clone & Navigate

git clone https://github.com/Sagar-devx/help-desk-system.git
cd help-desk-system/help-desk-backend

2. Set Your API Key

# PowerShell
$env:OPENAI_API_KEY="gsk_your_groq_api_key_here"

# Bash / Zsh
export OPENAI_API_KEY="gsk_your_groq_api_key_here"

3. Run

# Windows
.\mvnw.cmd spring-boot:run

# macOS / Linux
./mvnw spring-boot:run

App starts on http://localhost:8081. MySQL database & tables are auto-created.


πŸ“‘ API Endpoints

Chat (Synchronous)

curl -X POST http://localhost:8081/api/v1/ai \
  -H "Content-Type: text/plain" \
  -H "ConversationId: session-001" \
  -d "My laptop keeps crashing. Email: sagar@test.com"

Chat (Streaming / SSE)

curl -X POST http://localhost:8081/api/v1/ai/stream \
  -H "Content-Type: text/plain" \
  -H "Accept: text/event-stream" \
  -H "ConversationId: session-001" \
  -d "Do I have any open tickets? My email is sagar@test.com"
Endpoint Method Content-Type Description
/api/v1/ai POST text/plain Full response after tool execution
/api/v1/ai/stream POST text/event-stream Token-by-token live streaming

ConversationId header is optional β€” defaults to "default".


πŸ—„ Database

Two tables, both auto-managed:

help_desk_tickets β€” User support tickets

Column Type Notes
id BIGINT Auto-increment PK
summary LONGTEXT AI-generated issue title
description TEXT Detailed issue + appended updates
category VARCHAR Hardware / Software / Technical / Account
email VARCHAR User's contact email
priority ENUM LOW Β· MEDIUM Β· HIGH Β· URGENT
status ENUM OPEN Β· CLOSED Β· RESOLVED
created_on DATETIME Set automatically on insert
updated_on DATETIME Set automatically on update

spring_ai_chat_memory β€” Persistent conversation history (auto-created by Spring AI)


πŸ“‚ Project Structure

help-desk-system/
β”œβ”€β”€ README.md
└── help-desk-backend/
    β”œβ”€β”€ pom.xml
    └── src/main/
        β”œβ”€β”€ java/com/helpdesk/
        β”‚   β”œβ”€β”€ config/         β†’ AiConfig (ChatClient + Memory)
        β”‚   β”œβ”€β”€ controller/     β†’ AiController (REST + SSE)
        β”‚   β”œβ”€β”€ entity/         β†’ Ticket, Priority, Status
        β”‚   β”œβ”€β”€ repository/     β†’ TicketRepository (JPA)
        β”‚   β”œβ”€β”€ service/        β†’ AiService, TicketService
        β”‚   └── tools/          β†’ TicketDatabaseTool (@Tool + Records)
        └── resources/
            β”œβ”€β”€ application.yaml
            └── helpdesk-system.st  β†’ AI persona & behavior rules

πŸ”„ How It Works (End to End)

User: "My Wi-Fi keeps dropping. Email: john@test.com"
                    β”‚
                    β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚   System Prompt       β”‚  ← helpdesk-system.st
        β”‚   (Liza's persona)    β”‚
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚
                   β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚  LLM decides to call  β”‚
        β”‚  getTicketsByEmail()  β”‚  ← Checks for existing tickets
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚ No open tickets found
                   β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚  LLM calls            β”‚
        β”‚  createTicketTool()   β”‚  ← Saves to MySQL
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”¬β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜
                   β”‚ Returns: { id: 42, status: OPEN, ... }
                   β–Ό
        β”Œβ”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”
        β”‚  Liza responds with   β”‚
        β”‚  real Ticket ID: 42   β”‚  ← No hallucination
        β””β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”€β”˜

πŸ’» Tech Stack

Technology Version Role
β˜• Java 25 Language
πŸƒ Spring Boot 4.1.2 Application Framework
πŸ€– Spring AI 2.0.1 ChatClient, Tool Calling, Memory
πŸ—„οΈ MySQL 8.0+ Tickets + Chat History
☁️ Groq β€” LLM Inference (Qwen)
⚑ Project Reactor β€” Reactive Streaming (Flux)
πŸ”§ Lombok β€” Boilerplate Reduction

πŸ‘€ Author

Sagar Β· @Sagar-devx

Built with β˜• Java, πŸƒ Spring, and a lot of curiosity.

About

Autonomous AI-powered customer support & ticketing backend built with Spring Boot, Spring AI, and MySQL. Features real LLM tool calling, persistent JDBC chat memory, and live SSE streaming.

Topics

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages