# Incident-Centric Chat System A comprehensive real-time collaboration platform for incident response teams, integrated with the ETB (Enterprise Incident Management) API. ## ๐Ÿš€ Features ### Core Chat Functionality - **Real-time Messaging**: WebSocket-based chat with instant message delivery - **Incident-Centric Rooms**: Every incident automatically gets its own chat room - **Cross-linking**: Direct links between incident timeline and chat logs - **Pinned Messages**: Pin important updates for easy reference - **Threaded Conversations**: Reply to messages for focused discussions - **Reactions**: Emoji reactions (๐Ÿ‘, ๐Ÿšจ, โœ…) for lightweight feedback ### Advanced Collaboration - **@mentions**: Mention users with notifications - **File Sharing**: Upload logs, screenshots, evidence files - **ChatOps Commands**: Execute automation commands via chat - **AI Assistant**: Intelligent bot for incident guidance and knowledge queries ### Security & Compliance - **Encryption**: Chat logs encrypted at rest and in transit - **RBAC**: Role-based access control for sensitive incidents - **Audit Trail**: Immutable audit trail for compliance - **Data Classification**: Automatic file classification and retention ### Integrations - **Incident Intelligence**: Auto-creates chat rooms, links to timeline - **SLA & On-Call**: SLA threshold notifications, escalation alerts - **Automation Orchestration**: Execute runbooks via chat commands - **Compliance Governance**: File classification, audit trails - **Knowledge Learning**: AI assistant with knowledge base integration ## ๐Ÿ“‹ Quick Start ### 1. Setup ```bash # Activate virtual environment source venv/bin/activate.fish # Run migrations python manage.py migrate # Create default bots and war rooms python manage.py setup_chat_system --create-bots --create-war-rooms ``` ### 2. WebSocket Connection ```javascript // Connect to chat room const ws = new WebSocket('ws://localhost:8000/ws/chat/{room_id}/'); // Send message ws.send(JSON.stringify({ type: 'chat_message', content: 'Hello team!', message_type: 'TEXT' })); // Add reaction ws.send(JSON.stringify({ type: 'reaction', message_id: 'message-uuid', emoji: '๐Ÿ‘', action: 'add' })); ``` ### 3. ChatOps Commands ``` /status # Get incident status /run playbook # Execute runbook /escalate [reason] # Trigger escalation /assign # Assign incident /update status # Update incident status ``` ## ๐Ÿ—๏ธ Architecture ### Models - **WarRoom**: Chat rooms for incidents - **WarRoomMessage**: Chat messages with reactions, attachments - **MessageReaction**: Emoji reactions to messages - **ChatFile**: File attachments with compliance integration - **ChatCommand**: ChatOps command execution - **ChatBot**: AI assistant bots ### Services - **SLANotificationService**: SLA threshold and escalation notifications - **AutomationCommandService**: ChatOps command execution - **ComplianceIntegrationService**: File classification and audit trails - **AIAssistantService**: AI-powered assistance and suggestions ### WebSocket Consumer - **ChatConsumer**: Real-time chat functionality - Message broadcasting - Reaction handling - Command execution - Typing indicators ## ๐Ÿ”ง API Endpoints ### War Rooms ```http GET /api/collaboration_war_rooms/api/war-rooms/ POST /api/collaboration_war_rooms/api/war-rooms/{id}/create_chat_room/ GET /api/collaboration_war_rooms/api/war-rooms/{id}/messages/ GET /api/collaboration_war_rooms/api/war-rooms/{id}/pinned_messages/ ``` ### Messages ```http POST /api/collaboration_war_rooms/api/war-room-messages/ POST /api/collaboration_war_rooms/api/war-room-messages/{id}/pin_message/ POST /api/collaboration_war_rooms/api/war-room-messages/{id}/add_reaction/ POST /api/collaboration_war_rooms/api/war-room-messages/{id}/execute_command/ ``` ### Files ```http POST /api/collaboration_war_rooms/api/chat-files/ POST /api/collaboration_war_rooms/api/chat-files/{id}/log_access/ ``` ### AI Assistant ```http GET /api/collaboration_war_rooms/api/chat-bots/ POST /api/collaboration_war_rooms/api/chat-bots/{id}/generate_response/ ``` ## ๐Ÿ” Security Features ### Access Control - Users must have appropriate clearance level for sensitive incidents - War room access controlled by incident permissions - File access logged and audited ### Encryption - Messages can be encrypted for sensitive incidents - Files encrypted based on classification level - WebSocket connections use WSS in production ### Audit Trail - All chat messages logged with timestamps - File access tracked with user and timestamp - Command executions logged with results ## ๐Ÿ“Š Monitoring & Analytics ### Metrics Tracked - Message volume per incident - Response times for commands - File upload/download statistics - User engagement metrics - Error rates and types ### Alerts - High message volume incidents - Failed command executions - Security policy violations - System performance issues ## ๐Ÿš€ Deployment ### Production Setup 1. Configure WebSocket routing in your ASGI application 2. Set up Redis for WebSocket channel layers 3. Configure file storage for attachments 4. Set up SSL certificates for WSS connections 5. Configure monitoring and alerting ### Environment Variables ```bash # WebSocket configuration CHANNEL_LAYERS_REDIS_URL=redis://localhost:6379/1 # File storage DEFAULT_FILE_STORAGE=django.core.files.storage.FileSystemStorage MEDIA_ROOT=/var/www/media/ # Security CHAT_ENCRYPTION_KEY=your-encryption-key CHAT_AUDIT_LOG_LEVEL=INFO ``` ## ๐Ÿงช Testing ### Unit Tests ```bash python manage.py test collaboration_war_rooms ``` ### WebSocket Testing ```javascript // Test WebSocket connection const ws = new WebSocket('ws://localhost:8000/ws/chat/test-room/'); ws.onopen = () => console.log('Connected'); ws.onmessage = (event) => console.log('Message:', event.data); ``` ## ๐Ÿ“š Documentation - [API Documentation](Documentations/INCIDENT_CENTRIC_CHAT_API.md) - [WebSocket API Reference](Documentations/INCIDENT_CENTRIC_CHAT_API.md#websocket-api) - [ChatOps Commands](Documentations/INCIDENT_CENTRIC_CHAT_API.md#chatops-commands) - [Security Guidelines](Documentations/INCIDENT_CENTRIC_CHAT_API.md#security-considerations) ## ๐Ÿค Contributing 1. Fork the repository 2. Create a feature branch 3. Make your changes 4. Add tests 5. Submit a pull request ## ๐Ÿ“„ License This project is part of the ETB (Enterprise Incident Management) API system. ## ๐Ÿ†˜ Support For support and questions: - Check the documentation - Review the API reference - Contact the development team ## ๐Ÿ”ฎ Roadmap ### Planned Features - Voice messages and video calls - Advanced AI assistant capabilities - Integration with external chat platforms - Mobile app support - Advanced analytics dashboard ### Integration Roadmap - Slack/Teams integration - PagerDuty integration - Jira integration - Custom webhook support