Build Real-Time Chat with Azure Communication Services
Java skill for real-time chat with Azure Communication Services - threads, messages, participants, and read receipts.
Why it matters
Integrate real-time chat functionality into your Java applications using Azure Communication Services. This asset provides the building blocks for creating dynamic chat experiences with features like thread management, messaging, participant handling, and read receipts.
Outcomes
What it gets done
Create and manage chat threads
Send and retrieve text and HTML messages
Manage chat participants (add/remove)
Implement read receipts and typing notifications
Install
Add it to your toolbox
Run in your project directory:
curl -fsSL https://spark.entire.vc/get/ag-azure-communication-chat-java | bash Overview
Azure Communication Chat (Java)
Java skill for the Azure Communication Chat SDK, covering thread creation, text/HTML messaging with pagination, participant add/remove with history-sharing control, read receipts, typing notifications, and thread lifecycle management. Use when building real-time chat features - threads, messaging, participants, read receipts - in a Java application on Azure Communication Services.
What it does
This skill builds real-time chat applications with the Azure Communication Chat SDK for Java (com.azure:azure-communication-chat, version 1.6.0), covering thread management, messaging, participants, and read receipts. A ChatClient (or async ChatAsyncClient) is built from an endpoint and a CommunicationTokenCredential wrapping a user access token - distinct classes handle distinct responsibilities: ChatClient creates/deletes chat threads and vends ChatThreadClients, while ChatThreadClient handles everything within a single thread (messages, participants, receipts). Creating a thread takes a topic and a list of ChatParticipants (each a CommunicationUserIdentifier plus display name), returning a thread ID used to get a ChatThreadClient for further operations. Messaging supports both TEXT and HTML content types via sendMessage, listing all messages (listMessages, paginated with a configurable maxPageSize, showing edited/deleted timestamps when applicable), fetching a single message, updating a message's content, and deleting a message. Participant management covers listing current participants, adding new ones with an optional shareHistoryTime to control how much prior message history a newly added participant can see, and removing a participant by identifier. Read receipts are sent per message (sendReadReceipt) and listed per thread (listReadReceipts, showing who read what and when), and typing notifications can be sent to signal active composition. Thread-level operations cover getting thread properties (topic, creation time), updating the topic, deleting the thread entirely, and listing all threads for the current user (with topic and last-message timestamp). Errors surface as HttpResponseException with specific handling suggested for 401 (check token), 403 (user not in thread), and 404 (thread not found). System message types (TOPIC_UPDATED, PARTICIPANT_ADDED, PARTICIPANT_REMOVED) are distinguished from TEXT/HTML user messages so they can be filtered out of a normal message view.
When to use - and when NOT to
Use this skill when building real-time chat functionality in a Java application - group or one-to-one messaging, presence/typing indicators, read receipts, or thread-based conversations - on Azure Communication Services. It is not for building the token issuance/refresh service itself in depth (though the skill flags that user tokens expire and refresh logic via CommunicationTokenRefreshOptions is needed), and read receipts should only be sent when a message is genuinely viewed by the user, not automatically on receipt.
Inputs and outputs
Input is thread topics, participant identifiers and display names, message content (text or HTML), and message/participant IDs for targeted operations. Output is created threads and messages with IDs and timestamps, paginated message/participant/receipt listings, and read-receipt and typing-notification confirmations.
Integrations
Built on the Azure Communication Chat Java SDK (ChatClient, ChatThreadClient), authenticated via CommunicationTokenCredential backed by a user access token issued through Azure Communication Services.
<dependency>
<groupId>com.azure</groupId>
<artifactId>azure-communication-chat</artifactId>
<version>1.6.0</version>
</dependency>
Who it's for
Java developers building real-time chat features - threaded messaging, participant management, read receipts, typing indicators - on Azure Communication Services rather than a custom WebSocket-based chat backend.
FAQ
Common questions
Discussion
Questions & comments · 0
Sign In Sign in to leave a comment.