Overview
The Twigz chat system provides real-time messaging between customers, stores, and admin support. This guide covers the complete implementation from basic messaging to advanced features like conversation transfers and typing indicators.Architecture
The chat system consists of three main components:Customer Support
Direct messaging between customers and stores
Admin Support
Admin intervention and conversation management
Transfer System
Seamless conversation transfers between support levels
Core Concepts
Conversation Types
Customer to Store
Customer to Store
Purpose: Direct communication between customers and store ownersRequirements:
- Customer must have at least one non-cancelled order with the store
- Direct messaging must be enabled globally and for the specific store
- Store must have direct messaging enabled in their settings
- Order-related questions
- Product inquiries
- Delivery issues
- General store communication
Customer to Admin
Customer to Admin
Purpose: Customer support through platform administratorsRequirements:
- Admin support must be enabled in platform settings
- Available as fallback when direct store messaging is not possible
- Platform-related issues
- Escalated store problems
- General support requests
- Technical difficulties
Message Types
Text Messages
Text Messages
Standard text communication with full UTF-8 support
Image Messages
Image Messages
Images with automatic validation and compression (max 5MB)
System Messages
System Messages
Automated notifications and status updates
Transfer Notices
Transfer Notices
Messages indicating conversation transfers between support levels
Implementation Guide
1. Basic Chat Setup
2. Real-time Message Display
3. Message Input with Typing Indicators
4. Image Message Support
5. Admin Chat Management
Advanced Features
Conversation Transfers
The system supports seamless conversation transfers between different support levels:Customer to Store Transfer
Customer to Store Transfer
When: Customer wants to communicate directly with store
Requirements: Customer must have orders with the store
Process: Creates new store conversation, archives admin conversation
Store to Admin Transfer
Store to Admin Transfer
When: Store needs admin intervention
Requirements: Store owner or admin can initiate
Process: Creates new admin conversation, archives store conversation
Message History Transfer
Message History Transfer
Option: Include or exclude message history
Default: Admin transfers include history, store transfers exclude
Benefit: Maintains context while allowing fresh start
Chat Settings Management
Best Practices
Performance
- Debounce typing indicators to avoid excessive updates
- Use pagination for message loading
- Implement proper cleanup for real-time subscriptions
User Experience
- Show typing indicators for better engagement
- Provide immediate feedback for message status
- Handle offline scenarios gracefully
Security
- Validate all message content
- Implement proper authorization checks
- Sanitize user input before display
Scalability
- Use efficient database queries with indexes
- Implement proper caching strategies
- Monitor chat system performance
Error Handling
Network Issues
Network Issues
Problem: Connection lost during message send
Solution: Implement retry logic with exponential backoff
User Feedback: Show message as “pending” until confirmed
Permission Errors
Permission Errors
Problem: User tries to access unauthorized conversation
Solution: Check permissions before allowing access
User Feedback: Show clear error message with guidance
Image Upload Failures
Image Upload Failures
Problem: Image too large or invalid format
Solution: Validate before upload and provide clear limits
User Feedback: Show specific error message with requirements
The chat system is designed to handle high-volume messaging with real-time updates. Always test thoroughly with multiple concurrent users to ensure performance.
