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
app.py
app.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
"""

from flask import Flask, render_template, request, jsonify, Response
from bot_logic import get_response, analyze_sentiment
from models import init_db, create_ticket, get_all_tickets, update_ticket_status, get_ticket_stats
import io
import csv

app = Flask(__name__)

# Initialize Database
init_db(app)

@app.route('/')
def index():
    return render_template('index.html')

@app.route('/admin')
def admin():
    """
    Admin Dashboard to view tickets and stats
    """
    tickets = get_all_tickets()
    stats = get_ticket_stats()
    return render_template('admin.html', tickets=tickets, stats=stats)

@app.route('/admin/export')
def export_tickets():
    """
    Export all tickets to CSV
    """
    tickets = get_all_tickets()
    
    # Create CSV in memory
    output = io.StringIO()
    writer = csv.writer(output)
    
    # Header
    writer.writerow(['ID', 'Issue', 'Contact', 'Priority', 'Status', 'Sentiment Score', 'Created At'])
    
    # Data
    for t in tickets:
        writer.writerow([t['id'], t['issue'], t['contact'], t['priority'], t['status'], t['sentiment_score'], t['created_at']])
        
    output.seek(0)
    
    return Response(
        output,
        mimetype="text/csv",
        headers={"Content-Disposition": "attachment;filename=tickets_export.csv"}
    )

@app.route('/api/chat', methods=['POST'])
def chat():
    user_message = request.json.get('message')
    response_data = get_response(user_message)
    return jsonify(response_data)

@app.route('/api/ticket', methods=['POST'])
def ticket():
    data = request.json
    issue = data.get('issue')
    contact = data.get('contact')
    
    # Analyze sentiment
    score, priority = analyze_sentiment(issue)
    
    ticket_id = create_ticket(issue, contact, priority, score)
    
    return jsonify({
        'status': 'success', 
        'ticket_id': ticket_id,
        'priority': priority
    })

@app.route('/api/ticket/<int:ticket_id>/close', methods=['POST'])
def close_ticket(ticket_id):
    update_ticket_status(ticket_id, 'Closed')
    return jsonify({'status': 'success'})

if __name__ == '__main__':
    app.run(debug=True, port=5000)
90 lines•2.3 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