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
conversational-ai-bot
/
templates
RSK World
conversational-ai-bot
Conversational AI Bot - Python + NLP + Flask + Machine Learning + Chatbot + AI
templates
  • index.html10.6 KB
index.html
templates/index.html
Raw Download
Find: Go to:
<!DOCTYPE html>
<html lang="en">
<head>
    <!--
    Project: Conversational AI Bot
    Developer: RSK World
    Website: https://rskworld.in
    Email: help@rskworld.in
    Phone: +91 93305 39277
    Year: 2026
    -->
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>Conversational AI Bot - RSK World</title>
    <style>
        * {
            margin: 0;
            padding: 0;
            box-sizing: border-box;
        }
        
        body {
            font-family: 'Segoe UI', Tahoma, Geneva, Verdana, sans-serif;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            height: 100vh;
            display: flex;
            justify-content: center;
            align-items: center;
        }
        
        .chat-container {
            width: 90%;
            max-width: 800px;
            height: 90vh;
            background: white;
            border-radius: 20px;
            box-shadow: 0 20px 60px rgba(0,0,0,0.3);
            display: flex;
            flex-direction: column;
            overflow: hidden;
        }
        
        .chat-header {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            padding: 20px;
            text-align: center;
        }
        
        .chat-header h1 {
            font-size: 24px;
            margin-bottom: 5px;
        }
        
        .chat-header p {
            font-size: 12px;
            opacity: 0.9;
        }
        
        .chat-messages {
            flex: 1;
            overflow-y: auto;
            padding: 20px;
            background: #f5f5f5;
        }
        
        .message {
            margin-bottom: 15px;
            display: flex;
            align-items: flex-start;
        }
        
        .message.user {
            justify-content: flex-end;
        }
        
        .message-content {
            max-width: 70%;
            padding: 12px 16px;
            border-radius: 18px;
            word-wrap: break-word;
        }
        
        .message.user .message-content {
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
        }
        
        .message.bot .message-content {
            background: white;
            color: #333;
            box-shadow: 0 2px 5px rgba(0,0,0,0.1);
        }
        
        .message-time {
            font-size: 10px;
            opacity: 0.7;
            margin-top: 5px;
        }
        
        .chat-input-container {
            padding: 20px;
            background: white;
            border-top: 1px solid #e0e0e0;
            display: flex;
            gap: 10px;
        }
        
        .chat-input {
            flex: 1;
            padding: 12px 16px;
            border: 2px solid #e0e0e0;
            border-radius: 25px;
            font-size: 14px;
            outline: none;
            transition: border-color 0.3s;
        }
        
        .chat-input:focus {
            border-color: #667eea;
        }
        
        .send-button {
            padding: 12px 24px;
            background: linear-gradient(135deg, #667eea 0%, #764ba2 100%);
            color: white;
            border: none;
            border-radius: 25px;
            cursor: pointer;
            font-size: 14px;
            font-weight: bold;
            transition: transform 0.2s;
        }
        
        .send-button:hover {
            transform: scale(1.05);
        }
        
        .send-button:active {
            transform: scale(0.95);
        }
        
        .loading {
            display: none;
            text-align: center;
            padding: 10px;
            color: #667eea;
        }
        
        .controls {
            display: flex;
            gap: 10px;
            padding: 10px 20px;
            background: #f9f9f9;
            border-top: 1px solid #e0e0e0;
        }
        
        .control-button {
            padding: 8px 16px;
            background: white;
            border: 1px solid #e0e0e0;
            border-radius: 20px;
            cursor: pointer;
            font-size: 12px;
            transition: all 0.3s;
        }
        
        .control-button:hover {
            background: #f0f0f0;
            border-color: #667eea;
        }
        
        .footer {
            text-align: center;
            padding: 10px;
            font-size: 11px;
            color: #666;
            background: #f9f9f9;
        }
        
        .footer a {
            color: #667eea;
            text-decoration: none;
        }
    </style>
</head>
<body>
    <div class="chat-container">
        <div class="chat-header">
            <h1>🤖 Conversational AI Bot</h1>
            <p>Advanced AI Chatbot with Context Management</p>
        </div>
        
        <div class="chat-messages" id="chatMessages">
            <div class="message bot">
                <div class="message-content">
                    Hello! I'm a conversational AI bot. How can I assist you today?
                    <div class="message-time">Just now</div>
                </div>
            </div>
        </div>
        
        <div class="loading" id="loading">Bot is thinking...</div>
        
        <div class="controls">
            <button class="control-button" onclick="clearChat()">Clear Chat</button>
            <button class="control-button" onclick="showAnalytics()">Analytics</button>
            <button class="control-button" onclick="showHistory()">History</button>
        </div>
        
        <div class="chat-input-container">
            <input type="text" class="chat-input" id="chatInput" placeholder="Type your message..." onkeypress="handleKeyPress(event)">
            <button class="send-button" onclick="sendMessage()">Send</button>
        </div>
        
        <div class="footer">
            Developed by <a href="https://rskworld.in" target="_blank">RSK World</a> | 
            Email: help@rskworld.in | Phone: +91 93305 39277 | Year: 2026
        </div>
    </div>
    
    <script>
        function addMessage(text, isUser = false) {
            const messagesDiv = document.getElementById('chatMessages');
            const messageDiv = document.createElement('div');
            messageDiv.className = `message ${isUser ? 'user' : 'bot'}`;
            
            const now = new Date();
            const timeStr = now.toLocaleTimeString();
            
            messageDiv.innerHTML = `
                <div class="message-content">
                    ${text}
                    <div class="message-time">${timeStr}</div>
                </div>
            `;
            
            messagesDiv.appendChild(messageDiv);
            messagesDiv.scrollTop = messagesDiv.scrollHeight;
        }
        
        async function sendMessage() {
            const input = document.getElementById('chatInput');
            const message = input.value.trim();
            
            if (!message) return;
            
            addMessage(message, true);
            input.value = '';
            
            document.getElementById('loading').style.display = 'block';
            
            try {
                const response = await fetch('/api/chat', {
                    method: 'POST',
                    headers: {
                        'Content-Type': 'application/json'
                    },
                    body: JSON.stringify({ message: message })
                });
                
                const data = await response.json();
                
                if (data.success) {
                    let botResponse = data.response;
                    if (data.sentiment) {
                        botResponse += `\n\n[Sentiment: ${data.sentiment} (${data.sentiment_score})]`;
                    }
                    addMessage(botResponse, false);
                } else {
                    addMessage('Sorry, I encountered an error. Please try again.', false);
                }
            } catch (error) {
                addMessage('Sorry, I encountered an error. Please try again.', false);
            } finally {
                document.getElementById('loading').style.display = 'none';
            }
        }
        
        function handleKeyPress(event) {
            if (event.key === 'Enter') {
                sendMessage();
            }
        }
        
        async function clearChat() {
            if (confirm('Are you sure you want to clear the chat?')) {
                try {
                    await fetch('/api/clear', { method: 'POST' });
                    document.getElementById('chatMessages').innerHTML = `
                        <div class="message bot">
                            <div class="message-content">
                                Hello! I'm a conversational AI bot. How can I assist you today?
                                <div class="message-time">Just now</div>
                            </div>
                        </div>
                    `;
                } catch (error) {
                    alert('Error clearing chat');
                }
            }
        }
        
        async function showAnalytics() {
            try {
                const response = await fetch('/api/analytics');
                const data = await response.json();
                
                if (data.success) {
                    alert(data.summary);
                }
            } catch (error) {
                alert('Error fetching analytics');
            }
        }
        
        async function showHistory() {
            try {
                const response = await fetch('/api/history?limit=10');
                const data = await response.json();
                
                if (data.success && data.history.length > 0) {
                    let historyText = 'Recent Conversation History:\n\n';
                    data.history.slice(-5).forEach((entry, index) => {
                        historyText += `${index + 1}. You: ${entry.user_message}\n`;
                        historyText += `   Bot: ${entry.bot_response}\n\n`;
                    });
                    alert(historyText);
                } else {
                    alert('No conversation history available');
                }
            } catch (error) {
                alert('Error fetching history');
            }
        }
    </script>
</body>
</html>

340 lines•10.6 KB
markup

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