ws_chat_flutter 1.0.0
ws_chat_flutter: ^1.0.0 copied to clipboard
AI-Powered Customer Service Chat Widget for Flutter with real-time messaging, AI assistance, and seamless CS handover built with Socket.IO
π¬ WS Chat Flutter #
A comprehensive real-time chat widget package for Flutter with AI assistance and seamless customer service handover, built with Socket.IO.
β¨ Features #
π― Customer Chat Screen #
- π€ AI-Powered Responses - Instant automated replies using AI
- π€ Human CS Handover - Seamless transfer to human agents
- π± Responsive Design - Works on phones, tablets, and web
- π¬ Real-time Messaging - Instant message delivery
- β Read Receipts - Know when messages are read
- π Chat History - Persistent conversation history
- π¨ Customizable Theme - Adjust colors to match your brand
- π Full Screen Experience - Native screen implementation
π¨βπΌ CS Dashboard Screen #
- π Multi-Chat Management - Handle multiple conversations
- π Real-time Updates - Instant message and status updates
- π€ AI Summary - View AI conversation summaries
- π Notifications - In-app notifications for new messages
- β Message Read Tracking - See when customers read messages
- π― Smart Sorting - Auto-sorted by latest activity
- π± Responsive Layout - Desktop and mobile optimized
π¦ Installation #
Add this to your package's pubspec.yaml file:
dependencies:
ws_chat_flutter: ^1.0.0
Then run:
flutter pub get
π Quick Start #
Customer Chat Screen #
import 'package:ws_chat_flutter/ws_chat_flutter.dart';
// Navigate to chat screen
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ChatScreen(
serverUrl: 'https://your-server.com',
customerId: 'customer_123',
customerName: 'John Doe',
title: 'Customer Support',
primaryColor: Color(0xFF4F46E5),
),
),
);
CS Dashboard Screen #
import 'package:ws_chat_flutter/ws_chat_flutter.dart';
// Navigate to CS dashboard
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => CSDashboardScreen(
serverUrl: 'https://your-server.com',
csUserId: 'cs_001',
csName: 'Agent Sarah',
primaryColor: Color(0xFF10B981),
),
),
);
π± Usage Examples #
Example 1: In-App Support Button #
import 'package:flutter/material.dart';
import 'package:ws_chat_flutter/ws_chat_flutter.dart';
class MyHomePage extends StatelessWidget {
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text('My App'),
actions: [
IconButton(
icon: Icon(Icons.support_agent),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) => ChatScreen(
serverUrl: 'https://your-server.com',
customerId: 'user_${userId}',
customerName: userName,
),
),
);
},
),
],
),
body: Center(
child: Text('Welcome to My App'),
),
);
}
}
Example 2: Embedded in Navigation #
import 'package:flutter/material.dart';
import 'package:ws_chat_flutter/ws_chat_flutter.dart';
class MainScreen extends StatefulWidget {
@override
_MainScreenState createState() => _MainScreenState();
}
class _MainScreenState extends State<MainScreen> {
int _currentIndex = 0;
final List<Widget> _screens = [
HomeScreen(),
ChatScreen(
serverUrl: 'https://your-server.com',
customerId: 'customer_123',
customerName: 'John Doe',
showBackButton: false,
),
ProfileScreen(),
];
@override
Widget build(BuildContext context) {
return Scaffold(
body: _screens[_currentIndex],
bottomNavigationBar: BottomNavigationBar(
currentIndex: _currentIndex,
onTap: (index) => setState(() => _currentIndex = index),
items: [
BottomNavigationBarItem(icon: Icon(Icons.home), label: 'Home'),
BottomNavigationBarItem(icon: Icon(Icons.chat), label: 'Support'),
BottomNavigationBarItem(icon: Icon(Icons.person), label: 'Profile'),
],
),
);
}
}
Example 3: CS Agent Login Flow #
import 'package:flutter/material.dart';
import 'package:ws_chat_flutter/ws_chat_flutter.dart';
class CSLoginPage extends StatelessWidget {
final String agentId;
final String agentName;
const CSLoginPage({
required this.agentId,
required this.agentName,
});
@override
Widget build(BuildContext context) {
return Scaffold(
body: Center(
child: ElevatedButton(
onPressed: () {
// Navigate to CS Dashboard
Navigator.pushReplacement(
context,
MaterialPageRoute(
builder: (context) => CSDashboardScreen(
serverUrl: 'https://your-server.com',
csUserId: agentId,
csName: agentName,
primaryColor: Colors.green,
),
),
);
},
child: Text('Start CS Dashboard'),
),
),
);
}
}
π¨ Customization #
Custom Colors #
ChatScreen(
serverUrl: 'https://your-server.com',
customerId: 'customer_123',
customerName: 'John Doe',
primaryColor: Color(0xFFFF6B6B), // Custom brand color
)
Custom Title #
ChatScreen(
serverUrl: 'https://your-server.com',
customerId: 'customer_123',
customerName: 'John Doe',
title: 'Talk to Us', // Custom title
)
Hide Back Button #
ChatScreen(
serverUrl: 'https://your-server.com',
customerId: 'customer_123',
customerName: 'John Doe',
showBackButton: false, // Useful for embedded screens
)
π§ Backend Requirements #
This package requires a Socket.IO server with the following events:
Customer Events (Emit) #
start_chat- Initialize chat sessioncustomer_message- Send customer messageget_customer_chat_history- Request chat historymark_message_read- Mark message as read
CS Events (Emit) #
cs_login- CS agent logincs_logout- CS agent logoutcs_select_room- Select chat roomcs_send_message- Send CS messagecs_get_all_rooms- Get all chat roomscs_mark_messages_read- Mark messages as read
Server Response Events (Listen) #
chat_started- Chat session createdreceive_message- New message receivedai_typing- AI is typing indicatorcs_assigned- CS agent assignedmessages_read_by_cs- Messages read by CScustomer_chat_history- Chat history datacs_chat_rooms- Available chat roomscs_chat_history- Room chat historycustomer_message_to_cs- Customer message notificationnew_customer_chat- New chat notificationcs_message_sent- Message sent confirmationmessage_read_by_customer- Read receipt
π± Platform Support #
| Platform | Supported |
|---|---|
| Android | β Yes |
| iOS | β Yes |
| Web | β Yes |
| macOS | β Yes |
| Windows | β Yes |
| Linux | β Yes |
π Security Notes #
- Always use HTTPS in production
- Implement proper authentication for CS dashboard
- Validate all user inputs on the server
- Use environment variables for sensitive data
- Implement rate limiting on the server
π Troubleshooting #
Connection Issues #
// Check if server URL is correct
// Ensure Socket.IO server is running
// Verify CORS settings on server
Messages Not Appearing #
// Verify customerId/csUserId are unique
// Check event names match server implementation
// Enable debug logging: print() statements in SocketService
π API Reference #
ChatScreen Properties #
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
serverUrl |
String | β | - | WebSocket server URL |
customerId |
String | β | - | Unique customer identifier |
customerName |
String | β | - | Customer display name |
title |
String | β | Status text | Screen title |
primaryColor |
Color | β | #4F46E5 | Primary theme color |
showBackButton |
bool | β | true | Show/hide back button |
CSDashboardScreen Properties #
| Property | Type | Required | Default | Description |
|---|---|---|---|---|
serverUrl |
String | β | - | WebSocket server URL |
csUserId |
String | β | - | Unique CS agent identifier |
csName |
String | β | - | CS agent display name |
primaryColor |
Color | β | #10B981 | Primary theme color |
π€ Contributing #
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
π License #
This project is licensed under the MIT License - see the LICENSE file for details.
π¨βπ» Author #
Your Name
- Email: your.email@example.com
- GitHub: @yourusername
π Acknowledgments #
- Built with Socket.IO Client
- Inspired by modern chat interfaces
- Thanks to the Flutter community
π Support #
For issues and questions:
- π Report bugs
- π¬ Discussions
- π§ Email: support@example.com
πΊοΈ Roadmap #
- β File upload support
- β Voice message support
- β Video call integration
- β Chat analytics
- β Multi-language support
- β Emoji picker
- β Message reactions
- β Typing indicators enhancement
- β Push notifications
Made with β€οΈ using Flutter
Version: 1.0.0
Last Updated: November 2024