Chat Room Tags

Update time: 2022/06/28 10:57:42

Feature overview

The IM service help you build an in-app chat room that is widely used in social entertainment and education live streaming. By default, all online users in a chat room can receive messages. Starting from V8.4.0, we provide the chat room tag, meeting the needs of delivering messages to specific users. Receiving specific types of messages is supported also.

Scenarios

When a teacher gives lectures online, students are organized in small sizes to involve in teachings. The model can lower the teaching cost and make students more involved.

The above shows the scenario of a breakout class:

  • All class members are in the same chat room.
  • Teachers can send online messages to all classes, and also can receive messages from all classes.
  • Students can only receive messages and send messages in their respective classes.
  • Users can set teaching assistants as required, who can manage one or more online classes.

Large live streaming chat room

In a large live streaming chat room, in consideration of barrage refreshing and debate, users may be grouped by tags to yield the following effect:

  • In the live streaming of multiple stars or entertainers, internal interaction is supported among the fans of any of the stars or entertainers, but there is no interaction among the fans of different stars.
  • In sports competitions, e-sports or other competitions, audiences may choose a preferred team, and interact with fans
  • Prepare an appropriate tag strategy based on users' characteristics. The users in the same chat room, having the same hobbies and at the same age may interact with each other.

Feature description

Chat room tags are used to set tag-related fields at login to send and receive messages in a customized manner. The main process is detailed as follows:

1. Login

At login, two parameters are required:

  • The first parameter tags is used to identify which tags the persistent connection of the login belongs to. It is a json array, and at most 10 tags may be set for a long connection. Each tag consists of 32 characters at most, such as ["abc", "def"].
  • The second parameter notifyTargetTags is a tag expression that indicates the tag users to whom in and out notifications generated by the login and the subsequent logout operation should be broadcast. If missing, the server will automatically generate a tag expression based on tags based on the rule by which all tags are combined by the keyword "and", which means that the users in all tags may receive in and out notifications.

2. Send messages

Send messages using the SDK

When calling corresponding methods to send a message, you can set the parameter notifyTargetTags, a tag expression, to specify to whom the message will be sent. If it is not set, the parameter notifyTargetTags configured at login will take effect instead.

Send messages by calling server APIs

When calling corresponding server APIs to send a message, you can set the parameter notifyTargetTags, a tag expression, to specify to whom the message will be sent. If it is not set, the message will be sent to all end users of the chat room.

Tag expression

Tag expression is used to set the target to which chat room notifications/messages are delivered, and supports the setting of intersection and union, as well as regex match. Brackets may be used to set the priority in the expression (similar as the brackets in addition, subtraction, multiplication, and division). Each tag expression consists of up to 128 characters.

Examples of some tag expressions:

1) Match tag abc

{"tag": "abc"}

2) Match tag abc or def

{"tag": "abc"} or {"tag": "def"}

3) Match tag abc and def

{"tag": "abc"} and {"tag": "def"}

4) Use regex match tag abc

{"tag": "abc.*", "matchType": "regex"}

5) Match tag abc or def, and regex match tag 123 or 456

({"tag": "abc"} or {"tag": "def"}) and ({"tag": ".*123", "matchType": "regex"} or {"tag": "456.*", "matchType": "regex"})
Was this page helpful?
Yes
No
  • Feature overview
  • Scenarios
  • Large live streaming chat room
  • Feature description
  • 1. Login
  • 2. Send messages
  • Send messages using the SDK
  • Send messages by calling server APIs
  • Tag expression