Skip to main content

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

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
Use Cases:
  • Order-related questions
  • Product inquiries
  • Delivery issues
  • General store communication
Purpose: Customer support through platform administratorsRequirements:
  • Admin support must be enabled in platform settings
  • Available as fallback when direct store messaging is not possible
Use Cases:
  • Platform-related issues
  • Escalated store problems
  • General support requests
  • Technical difficulties

Message Types

Standard text communication with full UTF-8 support
Images with automatic validation and compression (max 5MB)
Automated notifications and status updates
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:
When: Customer wants to communicate directly with store Requirements: Customer must have orders with the store Process: Creates new store conversation, archives admin conversation
When: Store needs admin intervention Requirements: Store owner or admin can initiate Process: Creates new admin conversation, archives store conversation
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

Problem: Connection lost during message send Solution: Implement retry logic with exponential backoff User Feedback: Show message as “pending” until confirmed
Problem: User tries to access unauthorized conversation Solution: Check permissions before allowing access User Feedback: Show clear error message with guidance
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.
Consider implementing message queuing for offline scenarios and message status indicators (sent, delivered, read) for better user experience.