241 lines
6.8 KiB
Markdown
241 lines
6.8 KiB
Markdown
# 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 <name> # Execute runbook
|
|
/escalate [reason] # Trigger escalation
|
|
/assign <username> # Assign incident
|
|
/update status <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
|