Skip to main content

Concept Explanation

What is a Channel?

A Channel is the carrier for message transmission in WuKongIM, defining the target and scope of message delivery. Each channel has a unique identifier and type, used to organize and manage different communication scenarios.

Why are Channels Important?

  • Message Routing: Channels determine where messages are sent, forming the foundation of message transmission
  • Permission Control: Different channel types have different permissions and management rules
  • Scenario Differentiation: Channel types distinguish between different scenarios like one-on-one chat and group chat

Relationship with Other Concepts

  • Message: All messages must specify a target channel to be sent
  • User: Users communicate through channels, can be channel creators or participants
  • Conversation: Each conversation corresponds to a channel; the conversation list is actually the list of channels a user participates in

Core Structure

Channels are the carriers of message transmission, containing the following core attributes:
AttributeTypeDescription
channel_idstringChannel unique identifier
channel_typeintegerChannel type (1=personal, 2=group)
largeintegerLarge channel identifier (0=no, 1=yes)
banintegerDisabled status (0=no, 1=yes)
disbandintegerDisbanded status (0=no, 1=yes)

Channel Types

  • Personal Channel (1): One-on-one private chat
  • Group Channel (2): Multi-user group chat
  • Customer Service Channel (3): Customer service channel, no permission checks
  • Community Channel (4): Community channel, similar to Discord channels
  • Community Topic Channel (5): Community topic channel, similar to Discord sub-channels
  • News Channel (6): News channel (with temporary subscriber concept, join temporary subscription when viewing news, exit when leaving)
  • Live Channel (9): Live channel (live channels don’t save recent conversation data)
  • Visitor Channel (10): Visitor channel (channel ID is visitor ID, supports only one visitor subscriber and multiple customer service subscribers, can replace customer service channels for customer service scenarios)
  • Personal Agent Channel (11): Personal Agent channel (AI Agent channel, channel ID structure is UID@AgentID, similar to personal chat channel, optimized for AI Agent scenarios)
  • Group Agent Channel (12): Group Agent channel (AI Agent group chat channel, similar to group chat channel, optimized for multi-Agent collaboration scenarios)

Channel Example

{
  "channel_id": "group123",
  "channel_type": 2,
  "large": 1,
  "ban": 0,
  "disband": 0
}
EndpointMethodDescription
/channelPOSTCreate channel
/channel/infoPOSTGet channel information
/channel/deleteDELETEDelete channel
/channel/subscriber_addPOSTAdd subscribers
/channel/subscriber_removePOSTRemove subscribers
/channel/messagesyncPOSTSync channel messages

EasySDK Code Examples

Send Messages to Different Channel Types

import { WKIM, WKIMChannelType } from 'easyjssdk';

const im = WKIM.init("ws://your-server.com:5200", {
  uid: "your_user_id",
  token: "your_token"
});

// Send to personal channel (one-on-one chat)
const personalPayload = {
  type: 1,
  content: "Hello!"
};
await im.send("user123", WKIMChannelType.Person, personalPayload);

// Send to group channel (group chat)
const groupPayload = {
  type: 1,
  content: "Hello everyone!"
};
await im.send("group123", WKIMChannelType.Group, groupPayload);

Channel Type Description

Personal Channel (person):
  • channelId is the other user’s ID
  • Used for one-on-one private chat
  • Example: To send to user “user123”, channelId is “user123”
Group Channel (group):
  • channelId is the group’s ID
  • Used for multi-user group chat
  • Example: To send to group “group123”, channelId is “group123”
Channels are uniquely identified by the combination of channel_id and channel_type, serving as the fundamental carrier for message transmission.