*** id: 306e6105-6f11-4f4a-9c2d-ad046077e8c2 title: Chat sidebar-title: Overview position: 0 keywords: 'SignalWire, Realtime SDK, Node.js, chat API, real-time chat' slug: /node/reference/chat description: >- Access the Chat API for building real-time chat applications. Subscribe to channels, send messages, and track member presence in chat rooms. max-toc-depth: 3 ---------------- [chat-client-1]: /docs/server-sdk/v4/node/reference/chat/client/listen [chat-client-2]: /docs/server-sdk/v4/node/reference/chat/client [chat-client]: /docs/server-sdk/v4/node/reference/chat/client#events Access the Chat API Consumer. You can instantiate a [Chat.Client][chat-client-2] to subscribe to Chat events. For a full list of events that a [Chat.Client][chat-client-2] can subscribe to, refer to [Chat Events][chat-client]. #### Example The following example shows how to instantiate a [Chat.Client][chat-client-2] and [listen][chat-client-1] to the `onMemberJoined` event on the `channel1` channel. When a member joins the channel, the bot will send a message to the channel with the number of members in the channel and the list of members. ```javascript import { SignalWire } from "@signalwire/realtime-api"; const client = await SignalWire({ project: "ProjectID Here", token: "Token Here" }) const chatClient = client.chat; await chatClient.listen({ channels: ["channel1"], onMemberJoined: async (member) => { let members = await chatClient.getMembers({ channel: member.channel }); let chatMessage = `Hello ${member.id}! There are ${members.members.length} members in this channel. The members are: ${members.members.map(m => m.id).join(", ")}` await chatClient.publish({ channel: member.channel, content: chatMessage }) } }); ``` *** ## **Classes** The main Chat client for sending messages, managing members, and subscribing to chat events. Represents a member in a chat channel with properties for identity and state. Represents a chat message with content, sender information, and metadata.