New to Claude Skills? Learn how to install them →

sickn33 on GitHub

Azure Communication Chat

Free

Build real-time chat applications with ease.

Get this skill

Free · Opens the source repo

What Azure Communication Chat does

The Azure Communication Chat skill allows developers to create robust real-time chat applications using Java. With features such as thread management, messaging, participant management, and read receipts, this skill provides a comprehensive framework for integrating chat functionalities into applications. The skill utilizes the Azure Communication Services, ensuring that developers can leverage a scalable and secure environment for their chat applications.

To get started, developers can easily include the Azure Communication Chat dependency in their project. The skill provides a straightforward API that allows for the creation of chat clients and threads, enabling seamless interaction among participants. Developers can send messages in various formats, manage participants, and track message statuses, including read receipts, which enhances user experience and engagement.

The skill is designed for developers looking to implement chat features without the overhead of building a messaging system from scratch. It is suitable for applications that require real-time communication capabilities, such as team collaboration tools, customer support platforms, and social networking apps. The integration with Azure ensures that developers can focus on building their applications while relying on a robust backend infrastructure.

Overall, Azure Communication Chat provides a solid foundation for real-time chat functionalities, making it an essential tool for developers aiming to enhance their applications with interactive communication features.

When to use it

Use this skill when you need to implement chat features in your Java applications, especially for scenarios requiring thread management and participant interactions.

When not to use it

This skill may not be suitable for applications that do not require real-time communication or for those needing extensive customization beyond the provided API.

What you can build with it

Team Collaboration Tool

Integrate chat features into a team collaboration application to facilitate real-time communication among team members.

Customer Support Platform

Use the skill to build a chat interface for customer support, allowing users to interact with support agents in real-time.

Social Networking App

Implement chat functionalities in a social networking application to enhance user engagement through direct messaging.

How to install Azure Communication Chat

View source

1. Install with the skills CLI

npx skills add sickn33/agentic-awesome-skills/azure-communication-chat-java --agent claude-code

2. Or install it manually

Download the skill folder and drop it into ~/.claude/skills/ for all projects, or .claude/skills/ to scope it to one repo. Restart Claude Code so it picks up the new skill.

Anthropic's agentic coding CLI, and the reference implementation of Agent Skills. Drop a skill folder into ~/.claude/skills and Claude Code loads it automatically whenever a task matches the skill's description. Claude Code docs

Inside SKILL.md

Written by sickn33

Azure Communication Chat (Java)

Build real-time chat applications with thread management, messaging, participants, and read receipts.

Installation

<dependency>
    <groupId>com.azure</groupId>
    <artifactId>azure-communication-chat</artifactId>
    <version>1.6.0</version>
</dependency>

Client Creation

import com.azure.communication.chat.ChatClient;
import com.azure.communication.chat.ChatClientBuilder;
import com.azure.communication.chat.ChatThreadClient;
import com.azure.communication.common.CommunicationTokenCredential;

// ChatClient requires a CommunicationTokenCredential (user access token)
String endpoint = "https://<resource>.communication.azure.com";
String userAccessToken = "<user-access-token>";

CommunicationTokenCredential credential = new CommunicationTokenCredential(userAccessToken);

ChatClient chatClient = new ChatClientBuilder()
    .endpoint(endpoint)
    .credential(credential)
    .buildClient();

// Async client
ChatAsyncClient chatAsyncClient = new ChatClientBuilder()
    .endpoint(endpoint)
    .credential(credential)
    .buildAsyncClient();

Key Concepts

ClassPurpose
ChatClientCreate/delete chat threads, get thread clients
ChatThreadClientOperations within a thread (messages, participants, receipts)
ChatParticipantUser in a chat thread with display name
ChatMessageMessage content, type, sender info, timestamps
ChatMessageReadReceiptRead receipt tracking per participant

Create Chat Thread

import com.azure.communication.chat.models.*;
import com.azure.communication.common.CommunicationUserIdentifier;
import java.util.ArrayList;
import java.util.List;

// Define participants
List<ChatParticipant> participants = new ArrayList<>();

ChatParticipant participant1 = new ChatParticipant()
    .setCommunicationIdentifier(new CommunicationUserIdentifier("<user-id-1>"))
    .setDisplayName("Alice");

ChatParticipant participant2 = new ChatParticipant()
    .setCommunicationIdentifier(new CommunicationUserIdentifier("<user-id-2>"))
    .setDisplayName("Bob");

participants.add(participant1);
participants.add(participant2);

// Create thread
CreateChatThreadOptions options = new CreateChatThreadOptions("Project Discussion")
    .setParticipants(participants);

CreateChatThreadResult result = chatClient.createChatThread(options);
String threadId = result.getChatThread().getId();

// Get thread client for operations
ChatThreadClient threadClient = chatClient.getChatThreadClient(threadId);

Send Messages

// Send text message
SendChatMessageOptions messageOptions = new SendChatMessageOptions()
    .setContent("Hello, team!")
    .setSenderDisplayName("Alice")
    .setType(ChatMessageType.TEXT);

SendChatMessageResult sendResult = threadClient.sendMessage(messageOptions);
String messageId = sendResult.getId();

// Send HTML message
SendChatMessageOptions htmlOptions = new SendChatMessageOptions()
    .setContent("<strong>Important:</strong> Meeting at 3pm")
    .setType(ChatMessageType.HTML);

threadClient.sendMessage(htmlOptions);

Get Messages

import com.azure.core.util.paging.PagedIterable;

// List all messages
PagedIterable<ChatMessage> messages = threadClient.listMessages();

for (ChatMessage message : messages) {
    System.out.println("ID: " + message.getId());
    System.out.println("Type: " + message.getType());
    System.out.println("Content: " + message.getContent().getMessage());
    System.out.println("Sender: " + message.getSenderDisplayName());
    System.out.println("Created: " + message.getCreatedOn());
    
    // Check if edited or deleted
    if (message.getEditedOn() != null) {
        System.out.println("Edited: " + message.getEditedOn());
    }
    if (message.getDeletedOn() != null) {
        System.out.println("Deleted: " + message.getDeletedOn());
    }
}

// Get specific message
ChatMessage message = threadClient.getMessage(messageId);

Update and Delete Messages

// Update message
UpdateChatMessageOptions updateOptions = new UpdateChatMessageOptions()
    .setContent("Updated message content");

threadClient.updateMessage(messageId, updateOptions);

// Delete message
threadClient.deleteMessage(messageId);

Manage Participants

// List participants
PagedIterable<ChatParticipant> participants = threadClient.listParticipants();

for (ChatParticipant participant : participants) {
    CommunicationUserIdentifier user = 
        (CommunicationUserIdentifier) participant.getCommunicationIdentifier();
    System.out.println("User: " + user.getId());
    System.out.println("Display Name: " + participant.getDisplayName());
}

// Add participants
List<ChatParticipant> newParticipants = new ArrayList<>();
newParticipants.add(new ChatParticipant()
    .setCommunicationIdentifier(new CommunicationUserIdentifier("<new-user-id>"))
    .setDisplayName("Charlie")
    .setShareHistoryTime(OffsetDateTime.now().minusDays(7))); // Share last 7 days

threadClient.addParticipants(newParticipants);

// Remove participant
CommunicationUserIdentifier userToRemove = new CommunicationUserIdentifier("<user-id>");
threadClient.removeParticipant(userToRemove);

Read Receipts

// Send read receipt
threadClient.sendReadReceipt(messageId);

// Get read receipts
PagedIterable<ChatMessageReadReceipt> receipts = threadClient.listReadReceipts();

for (ChatMessageReadReceipt receipt : receipts) {
    System.out.println("Message ID: " + receipt.getChatMessageId());
    System.out.println("Read by: " + receipt.getSenderCommunicationIdentifier());
    System.out.println("Read at: " + receipt.getReadOn());
}

Typing Notifications

import com.azure.communication.chat.models.TypingNotificationOptions;

// Send typing notification
TypingNotificationOptions typingOptions = new TypingNotificationOptions()
    .setSenderDisplayName("Alice");

threadClient.sendTypingNotificationWithResponse(typingOptions, Context.NONE);

// Simple typing notification
threadClient.sendTypingNotification();

Thread Operations

// Get thread properties
ChatThreadProperties properties = threadClient.getProperties();
System.out.println("Topic: " + properties.getTopic());
System.out.println("Created: " + properties.getCreatedOn());

// Update topic
threadClient.updateTopic("New Project Discussion Topic");

// Delete thread
chatClient.deleteChatThread(threadId);

List Threads

// List all chat threads for the user
PagedIterable<ChatThreadItem> threads = chatClient.listChatThreads();

for (ChatThreadItem thread : threads) {
    System.out.println("Thread ID: " + thread.getId());
    System.out.println("Topic: " + thread.getTopic());
    System.out.println("Last message: " + thread.getLastMessageReceivedOn());
}

Pagination

import com.azure.core.http.rest.PagedResponse;

// Paginate through messages
int maxPageSize = 10;
ListChatMessagesOptions listOptions = new ListChatMessagesOptions()
    .setMaxPageSize(maxPageSize);

PagedIterable<ChatMessage> pagedMessages = threadClient.listMessages(listOptions);

pagedMessages.iterableByPage().forEach(page -> {
    System.out.println("Page status code: " + page.getStatusCode());
    page.getElements().forEach(msg -> 
        System.out.println("Message: " + msg.getContent().getMessage()));
});

Error Handling

import com.azure.core.exception.HttpResponseException;

try {
    threadClient.sendMessage(messageOptions);
} catch (HttpResponseException e) {
    switch (e.getResponse().getStatusCode()) {
        case 401:
            System.out.println("Unauthorized - check token");
            break;
        case 403:
            System.out.println("Forbidden - user not in thread");
            break;
        case 404:
            System.out.println("Thread not found");
            break;
        default:
            System.out.println("Error: " + e.getMessage());
    }
}

Message Types

TypeDescription
TEXTRegular chat message
HTMLHTML-formatted message
TOPIC_UPDATEDSystem message - topic changed
PARTICIPANT_ADDEDSystem message - participant joined
PARTICIPANT_REMOVEDSystem message - participant left

Environment Variables

AZURE_COMMUNICATION_ENDPOINT=https://<resource>.communication.azure.com
AZURE_COMMUNICATION_USER_TOKEN=<user-access-token>

Best Practices

  1. Token Management - User tokens expire; implement refresh logic with CommunicationTokenRefreshOptions
  2. Pagination - Use listMessages(options) with maxPageSize for large threads
  3. Share History - Set shareHistoryTime when adding participants to control message visibility
  4. Message Types - Filter system messages (PARTICIPANT_ADDED, etc.) from user messages
  5. Read Receipts - Send receipts only when messages are actually viewed by user

Trigger Phrases

  • "chat application Java", "real-time messaging Java"
  • "chat thread", "chat participants", "chat messages"
  • "read receipts", "typing notifications"
  • "Azure Communication Services chat"

When to Use

This skill is applicable to execute the workflow or actions described in the overview.

Limitations

  • Use this skill only when the task clearly matches the scope described above.
  • Do not treat the output as a substitute for environment-specific validation, testing, or expert review.
  • Stop and ask for clarification if required inputs, permissions, safety boundaries, or success criteria are missing.

Frequently asked questions about Azure Communication Chat

Similar skills