help@rskworld.in +91 93305 39277
RSK World
  • Home
  • Development
    • Web Development
    • Mobile Apps
    • Software
    • Games
    • Project
  • Technologies
    • Data Science
    • AI Development
    • Cloud Development
    • Blockchain
    • Cyber Security
    • Dev Tools
    • Testing Tools
  • About
  • Contact

Theme Settings

Color Scheme
Display Options
Font Size
100%
Back to Project
RSK World
nlp-text-analysis-bot
RSK World
nlp-text-analysis-bot
NLP Text Analysis Bot - Python + NLP + Flask + Machine Learning + Text Analysis + AI
nlp-text-analysis-bot
  • __pycache__
  • static
  • templates
  • .gitignore90 B
  • LICENSE1.1 KB
  • README.md1.1 KB
  • RELEASE_NOTES.md1.1 KB
  • app.py2.3 KB
  • bot_logic.py4.6 KB
  • models.py2.7 KB
  • requirements.txt194 B
models.py
models.py
Raw Download
Find: Go to:
"""
Project: Customer Service Bot
Author: RSK World
Website: https://rskworld.in
Contact: info@rskworld.com, support@rskworld.com
Phone: +91 93305 39277
Year: 2026
"""

import sqlite3

# Updated to v2 to ensure new schema is used without manual migration
DB_NAME = 'customer_service_v2.db'

def init_db(app):
    """
    Initialize the database
    Project: Customer Service Bot
    Author: RSK World
    Year: 2026
    """
    conn = sqlite3.connect(DB_NAME)
    c = conn.cursor()
    # Added priority and sentiment columns
    c.execute('''
        CREATE TABLE IF NOT EXISTS tickets (
            id INTEGER PRIMARY KEY AUTOINCREMENT,
            issue TEXT NOT NULL,
            contact TEXT NOT NULL,
            status TEXT DEFAULT 'Open',
            priority TEXT DEFAULT 'Normal',
            sentiment_score REAL DEFAULT 0.0,
            created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP
        )
    ''')
    conn.commit()
    conn.close()

def create_ticket(issue, contact, priority='Normal', sentiment_score=0.0):
    """
    Create a new support ticket with advanced metadata
    Project: Customer Service Bot
    Author: RSK World
    Year: 2026
    """
    conn = sqlite3.connect(DB_NAME)
    conn.row_factory = sqlite3.Row
    c = conn.cursor()
    c.execute('''
        INSERT INTO tickets (issue, contact, priority, sentiment_score) 
        VALUES (?, ?, ?, ?)
    ''', (issue, contact, priority, sentiment_score))
    ticket_id = c.lastrowid
    conn.commit()
    conn.close()
    return ticket_id

def get_all_tickets():
    """
    Retrieve all tickets for the admin dashboard
    """
    conn = sqlite3.connect(DB_NAME)
    conn.row_factory = sqlite3.Row
    c = conn.cursor()
    c.execute('SELECT * FROM tickets ORDER BY created_at DESC')
    tickets = [dict(row) for row in c.fetchall()]
    conn.close()
    return tickets

def update_ticket_status(ticket_id, status):
    """
    Update ticket status
    """
    conn = sqlite3.connect(DB_NAME)
    c = conn.cursor()
    c.execute('UPDATE tickets SET status = ? WHERE id = ?', (status, ticket_id))
    conn.commit()
    conn.close()

def get_ticket_stats():
    """
    Get simple stats for dashboard
    """
    conn = sqlite3.connect(DB_NAME)
    c = conn.cursor()
    c.execute('SELECT COUNT(*) FROM tickets')
    total = c.fetchone()[0]
    
    c.execute("SELECT COUNT(*) FROM tickets WHERE status='Open'")
    open_count = c.fetchone()[0]
    
    c.execute("SELECT COUNT(*) FROM tickets WHERE priority='High'")
    high_priority = c.fetchone()[0]
    
    conn.close()
    return {
        'total': total,
        'open': open_count,
        'high_priority': high_priority
    }
101 lines•2.7 KB
python

About RSK World

Founded by Molla Samser, with Designer & Tester Rima Khatun, RSK World is your one-stop destination for free programming resources, source code, and development tools.

Founder: Molla Samser
Designer & Tester: Rima Khatun

Development

  • Game Development
  • Web Development
  • Mobile Development
  • AI Development
  • Development Tools

Legal

  • Terms & Conditions
  • Privacy Policy
  • Disclaimer

Contact Info

Nutanhat, Mongolkote
Purba Burdwan, West Bengal
India, 713147

+91 93305 39277

hello@rskworld.in
support@rskworld.in

© 2026 RSK World. All rights reserved.

Content used for educational purposes only. View Disclaimer