Skip to content

Repository files navigation

SENTIMENT & URGENCY DETECTOR

๐Ÿง  AI-Powered Customer Support Ticket Intelligence System

Sentiment & Urgency Detector is an AI-based system that analyzes customer support tickets to automatically detect Sentiment, Urgency, and Churn Risk using Large Language Models (OpenAI + Hugging Face) and triggers real-time alerts through Discord for critical issues.


๐Ÿ“Œ Submission Identity (Placement Drive)

Field Details
๐Ÿข Organization Infinity Computer Solutions
๐Ÿ“‚ Category Service Desk
๐Ÿ‘ฅ Team Number Team 8
๐Ÿ†” UC ID UC-4
๐Ÿš€ Project Title Sentiment & Urgency Detector
๐Ÿง  Domain AI / LLM-Based Automation System
๐Ÿ“… Type Placement Drive Submission

๐Ÿ‘จโ€๐Ÿ’ป Team Members

Name Role
Leela Project Lead & System Design
Mohan Backend Developer (FastAPI Integration)
Lalitha AI/ML Engineer (OpenAI + Hugging Face)
Sunitha Testing, Documentation & UI Support

๐ŸŒŸ Project Overview

Customer support teams receive thousands of tickets daily. Many critical messages containing anger, urgency, frustration, or cancellation intent are often missed due to manual handling.

This results in:

  • Delayed responses
  • Poor customer satisfaction
  • Increased customer churn
  • Revenue loss

๐Ÿ’ก Our Solution

The system automatically: โœ” Detects sentiment of customer messages โœ” Calculates urgency level โœ” Identifies churn-risk behavior โœ” Generates AI-based explanations โœ” Sends real-time alerts via Discord


โ— Problem Statement

Organizations face difficulty in identifying high-priority tickets among large volumes of incoming customer requests.

Manual handling leads to:

  • Slow response time
  • Missed urgent complaints
  • Inefficient escalation process

This project solves it using AI-driven automation and LLM intelligence.


๐Ÿš€ Live Application

๐ŸŒ https://sentiment-and-urgency-detector-dqg64ccmtf28dul7pead9m.streamlit.app/


๐ŸŽฅ Live Demo Video

๐Ÿ“ฝ๏ธ https://drive.google.com/file/d/1l609UCGY_uJ-B57SB1o6_vdm3HbB9MO6/view?usp=sharing


โœจ Key Features

๐Ÿค– AI Intelligence Features

  • ๐Ÿ˜Š Sentiment Detection (Positive / Neutral / Negative)
  • โšก Urgency Scoring System
  • ๐Ÿšจ Churn Risk Prediction
  • ๐Ÿง  Explainable AI Reasoning
  • ๐Ÿ“Š Confidence Score Generation

๐Ÿ”” Automation Features

  • Discord Webhook Alerts
  • Real-time Ticket Analysis
  • Automatic Escalation Trigger

๐Ÿ“ฆ System Features

  • REST API (FastAPI)
  • JSON Structured Output
  • Streamlit UI Support

๐Ÿ—๏ธ System Architecture

Customer Ticket Input
        โ”‚
        โ–ผ
LLM Processing Layer (OpenAI / Hugging Face)
        โ”‚
        โ”œโ”€โ”€ Sentiment Analysis
        โ”œโ”€โ”€ Urgency Detection
        โ”œโ”€โ”€ Churn Risk Analysis
        โ”‚
        โ–ผ
Risk Evaluation Engine
        โ”‚
   High Risk?
        โ”‚
     YES โ–ผ
Discord Webhook Alert System
        โ”‚
Support Team Notification

๐Ÿ› ๏ธ Tech Stack

  • ๐Ÿ Python
  • โšก FastAPI
  • ๐Ÿค– OpenAI API
  • ๐Ÿง  Hugging Face Models
  • ๐ŸŒ Streamlit
  • ๐Ÿ”— Discord Webhooks
  • ๐Ÿ“ฆ JSON Processing
  • ๐Ÿงฐ Git & GitHub

๐Ÿ“ Project Structure

Sentiment-and-Urgency-detector/
โ”‚โ”€โ”€ app.py
โ”‚โ”€โ”€ requirements.txt
โ”‚โ”€โ”€ .env
โ”‚โ”€โ”€ backend/
โ”‚โ”€โ”€ ai_model/
โ”‚โ”€โ”€ utils/
โ”‚โ”€โ”€ alerts/
โ””โ”€โ”€ README.md

โš™๏ธ Installation Steps

1๏ธโƒฃ Clone Repository

git clone https://github.com/konathalaleela2005-collab/Sentiment-and-Urgency-detector
cd Sentiment-and-Urgency-detector

2๏ธโƒฃ Create Virtual Environment

python -m venv venv

3๏ธโƒฃ Activate Environment

venv\Scripts\activate

4๏ธโƒฃ Install Dependencies

pip install -r requirements.txt

๐Ÿ” Environment Variables

OPENAI_API_KEY=your_api_key
DISCORD_WEBHOOK_URL=your_webhook_url
ALERT_THRESHOLD=0.75

โ–ถ๏ธ Run Project

python app.py

OR

streamlit run app.py

๐Ÿ“ฅ Sample Input

{
  "ticket": "I am extremely disappointed. If this issue is not fixed today, I will cancel my subscription."
}

๐Ÿ“ค Sample Output

{
  "sentiment": "Negative",
  "sentiment_score": 0.94,
  "urgency_score": 0.91,
  "churn_risk_score": 0.88,
  "overall_risk": "High",
  "flagged": true
}

๐Ÿšจ Discord Alert Example

๐Ÿšจ HIGH PRIORITY TICKET

Risk Level: HIGH Sentiment Score: 0.94 Urgency Score: 0.91 Churn Risk Score: 0.88

Reason:

  • Negative emotional tone
  • Immediate action required
  • Customer may churn

๐Ÿ“Š Business Impact

โœ” Faster response to critical tickets โœ” Reduced customer churn โœ” Improved support efficiency โœ” Automated escalation system โœ” Better customer satisfaction


โš ๏ธ Challenges Faced

  • Handling ambiguous customer tone
  • Prompt optimization for LLM accuracy
  • Reducing false positives
  • Real-time webhook integration

๐Ÿ”ฎ Future Enhancements

  • ๐ŸŒ Multi-language support
  • ๐Ÿ“Š Analytics dashboard
  • ๐Ÿ“ฉ Email/SMS alerts
  • ๐Ÿค– Fine-tuned domain model
  • ๐Ÿ“ˆ Sentiment trend tracking

๐Ÿ“ธ Screenshots

<title>Sentiment & Urgency Detector</title> <style> * { box-sizing: border-box; margin: 0; padding: 0; }
    body {
        font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, Helvetica, Arial, sans-serif;
        background-color: #f8f9fa;
        color: #212529;
        display: flex;
        justify-content: center;
        align-items: center;
        min-height: 100vh;
        padding: 20px;
    }

    .container {
        width: 100%;
        max-width: 700px;
        background: #ffffff;
        padding: 40px;
        border-radius: 12px;
        box-shadow: 0 4px 6px rgba(0, 0, 0, 0.05);
    }

    h1 {
        font-size: 2rem;
        font-weight: 700;
        color: #1a1e21;
        margin-bottom: 24px;
    }

    .form-group {
        margin-bottom: 20px;
    }

    label {
        display: block;
        font-size: 0.85rem;
        color: #6c757d;
        margin-bottom: 8px;
        font-weight: 500;
    }

    textarea {
        width: 100%;
        height: 120px;
        padding: 16px;
        border: 1px solid #dee2e6;
        border-radius: 8px;
        background-color: #e9ecef; /* Matching the muted blue-gray tone from the image */
        font-family: inherit;
        font-size: 1rem;
        color: #495057;
        resize: vertical;
        outline: none;
        transition: border-color 0.2s ease, background-color 0.2s ease;
    }

    textarea:focus {
        background-color: #f1f3f5;
        border-color: #ced4da;
    }

    button {
        background-color: #f1f3f5;
        color: #495057;
        border: 1px solid #ced4da;
        padding: 10px 24px;
        font-size: 0.95rem;
        border-radius: 20px; /* Rounded pill style matching the image */
        cursor: pointer;
        font-weight: 500;
        transition: all 0.2s ease;
        margin-bottom: 32px;
    }

    button:hover {
        background-color: #e2e6ea;
        border-color: #adb5bd;
    }

    .result-section {
        border-top: 1px solid #e9ecef;
        padding-top: 24px;
    }

    h2 {
        font-size: 1.5rem;
        font-weight: 600;
        color: #212529;
        margin-bottom: 16px;
    }

    .result-item {
        font-size: 1rem;
        margin-bottom: 12px;
        color: #495057;
    }

    .result-value {
        font-weight: 500;
        color: #212529;
    }
</style>

Sentiment & Urgency Detector

<div class="form-group">
    <label for="complaintInput">Enter Customer Complaint</label>
    <textarea id="complaintInput" placeholder="Type customer complaint here...">I am frustrated and nobody helped me</textarea>
</div>

<button onclick="analyzeSentiment()">Analyze</button>

<div class="result-section">
    <h2>Result</h2>
    <div class="result-item">
        Sentiment: <span id="sentimentResult" class="result-value">Angry / Negative</span>
    </div>
    <div class="result-item">
        Urgency: <span id="urgencyResult" class="result-value">High</span>
    </div>
</div>
<script> function analyzeSentiment() { const text = document.getElementById('complaintInput').value.toLowerCase().trim(); const sentimentEl = document.getElementById('sentimentResult'); const urgencyEl = document.getElementById('urgencyResult'); if (text === "") { sentimentEl.textContent = "N/A"; urgencyEl.textContent = "N/A"; return; } // Mock basic client-side analysis logic for interactivity if (text.includes('frustrated') || text.includes('angry') || text.includes('nobody helped')) { sentimentEl.textContent = "Angry / Negative"; urgencyEl.textContent = "High"; } else if (text.includes('broken') || text.includes('urgent') || text.includes('help')) { sentimentEl.textContent = "Negative"; urgencyEl.textContent = "High"; } else if (text.includes('thanks') || text.includes('good') || text.includes('happy')) { sentimentEl.textContent = "Positive"; urgencyEl.textContent = "Low"; } else { sentimentEl.textContent = "Neutral"; urgencyEl.textContent = "Medium"; } } </script>

๐Ÿ Conclusion

The Sentiment & Urgency Detector demonstrates how Artificial Intelligence can transform customer support systems by automatically prioritizing critical tickets and enabling faster decision-making through LLM-based automation.


๐Ÿ’ผ Built for Infinity Computer Solutions Placement Drive

๐Ÿš€ AI-Powered Customer Support Intelligence System