A modern React-based demonstration application for Azure Communication Services Chat SDK with real-time notifications, comprehensive chat operations, and an intuitive testing interface.
- Node.js (version 14 or later)
- npm or yarn
- Azure Communication Services resource
git clone https://github.com/LuChen-Microsoft/Chat-Signaling-Sample.git
cd Chat-Signaling-Sample
npm install
src/config.js
:
export const ConnectionString = "endpoint=https://your-acs-resource.communication.azure.com/;accesskey=your-access-key";
How to get your connection string:
- Go to Azure Portal
- Navigate to your Azure Communication Services resource
- Go to "Keys" in the left navigation
- Copy the "Connection string" from the Primary key section
npm start
The app will open at http://localhost:3000
- Real-time chat box with message history
- Interactive message input with Enter key support
- Live participant management with add/remove functionality
- System message detection with special styling
- Message metadata display (ID, type, timestamp)
- Live events panel showing all ACS notifications in real-time
- JSON-formatted event details for debugging
- Connection status monitoring
- Event history (keeps last 50 events)
- Thread Management: Create, update topic/metadata/retention policy, delete
- Message Operations: Send, update, delete messages
- Participant Management: Add/remove participants with diverse names
- Real-time Features: Typing notifications, read receipts
- System Messages: Automatic display of thread operation notifications
- 26 diverse participant names: Alice, Bob, Charlie, Diana, Emma, Frank, Grace, Henry, Isabella, Jack, Kate, Liam, Maya, Nathan, Olivia, Peter, Quinn, Rachel, Sam, Tina, Uma, Victor, Wendy, Xavier, Yara, Zoe
- Automatic name cycling: Names rotate through the pool automatically
- Visual participant list with remove buttons for recent additions
src/Chat.js
- Main React component with all chat functionalitysrc/ChatUI.css
- Modern styling with Microsoft design languagesrc/config.js
- Azure Communication Services configurationsrc/App.js
- Application entry point
The application manages several key state objects:
- Chat Client State:
chatClient
,threadId
,threadClient
,messageId
- UI State:
messages[]
,participants[]
,events[]
,messageInput
- Connection State:
isConnected
,lastUser
- Participant Management:
participantNames[]
,usedNameIndex
- User performs action β ACS SDK operation
- ACS sends real-time notification β Event handler processes
- UI state updates β Components re-render
- Visual feedback displayed β JSON event details shown
- Initialize: Click "Initialize Chat Client" to start
- Create Thread: Click "Create Chat Thread" to begin a conversation
- Send Messages: Type and send messages in the chat box
- Add Participants: Click "Add Participant" to simulate multi-user scenarios
- Monitor Events: Watch the real-time events panel for all notifications
- Thread Operations: Test topic updates, metadata changes, retention policies
- Message Management: Update or delete specific messages
- Real-time Features: Send typing notifications and read receipts
- Participant Management: Add multiple participants and remove specific ones
- System Messages: Appear in yellow with "System" sender for thread operations
- User Messages: Standard chat messages with sender names and timestamps
- Real-time Events: JSON-formatted events in the sidebar panel
- Connection Status: Monitor real-time notification connection health
src/
βββ Chat.js # Main chat component (class-based React)
βββ ChatUI.css # Styling and layout
βββ config.js # ACS connection configuration
βββ App.js # Application wrapper
βββ App.css # Application-level styles
βββ index.js # React app entry point
- @azure/communication-chat: Core chat functionality
- @azure/communication-identity: User and token management
- @azure/communication-common: Shared utilities and credentials
- @azure/logger: Logging and debugging support
npm run build # Creates optimized production build in /build
npm test # Runs test suite
Connection String Error
- Ensure your connection string is correctly formatted
- Verify your Azure Communication Services resource is active
- Check that the access key hasn't expired
Real-time Notifications Not Working
- Verify the connection status shows "Connected"
- Check browser console for WebSocket connection errors
- Ensure firewall/proxy settings allow WebSocket connections
Messages Not Appearing
- Check that a thread has been created first
- Verify the message was sent successfully (check console logs)
- Try refreshing the message list manually
The application includes verbose logging. Check your browser's developer console for detailed ACS SDK operations and debugging information.
This project is licensed under the MIT License - see the LICENSE file for details.
Contributions are welcome! Please feel free to submit a Pull Request.
Built with β€οΈ for Azure Communication Services developers