Instant Messaging
Android
Getting Started
Introduction
Overview
Features
Limits
Features
Account Integration and Login
Group Chat
Chat Room
Chat Room Tags
Multi-device Login
Statistics Monitoring
Integration
Interface Overview
Integrate and Initialize SDK
Login
Message Sending
Message Receiving
Recent Chats
Server Sessions
User Profile
User Relationship
Online Status Subscription
System Notification
Push and Message Alert
Team
Superteam
Chat Room
Moderation
Chat Extension
Miscellaneous Features
Best Practice
Traffic Control in Chat Rooms
API Reference
Android API Reference
Android Status Codes

Content Moderation

Update time: 2022/06/28 17:31:34

CommsEase supports four types of content moderation features, such as basic content moderation, client content moderation, GuardEase content moderation and user-defined content moderation.

Basic content moderation is the default content moderation feature for IM. The configuration of the basic content moderation is not required. For more information, see product introduction.

Content moderation on the client

You can activate the content moderation feature by consulting our sales manager. The feature supports content moderation for text messages in one-to-one chat, team chat, and chat rooms. content moderation rules support keywords and regular expression.

The content moderation trigger words is managed and configured by the developer in the background of CommsEase, and SDK is responsible for download and management of the trigger words. Three applicable replacement rules for spam words:

  • Client-side replacement: Replace the words which hit the content moderation rules with specified texts, and send the replacements to the server.
  • Client-side interception After the hit, developers should not send the message.
  • Server processing: Developers configure corresponding attributes of the message as determined server interception library and then send the message to the server (The sender can see that the message is sent, but CommsEase server will not transmit the message and the recipient cannot receive the message). See the following text for the configuration method.

Retrieving term list

The SDK automatically gets the term list containing the user-defined undesired words from the CommsEase server upon login.

You need to configure the term list on the CommsEase console and apply it to the SDK first.

Detecting sensitive words

  • API prototype
/**
 * Verify local content moderation library
 * @param content - Text that must be checked
 * @param replacement - Designate replaced text in content after being filtered in content moderation library
 * @return LocalAntiSpamResult - Verification results
 */
public LocalAntiSpamResult checkLocalAntiSpam(String content, String replacement);
  • LocalAntiSpamResult parameter
Parameter Description
operator Operation on spam words:
0: missed, 1: replaced on clients, 2: intercepted on clients, and 3: intercepted on the server.
content The text used to replace spam words.
  • Example
String content = "USA"
String replacement = "Filter"

LocalAntiSpamResult result = NIMClient.getService(MsgService.class).checkLocalAntiSpam(content,replacement);

int operator = result.getOperator();
if (operator == 0){
    // Non-filtered
}else if(operator == 1){
    // Replaced at client
    content = result.getContent();
}else if(operator == 2){
    // Intercepted at client
    // Do not send any message.
}else if(operator == 3){
    // Deliver to server
    // Set hit attribute in message
    message.setClientAntiSpam(true);
}

Content moderation using GuardEase

You can enable GuardEase in the console and implement content moderation. GuardEase supports content moderation for messaging in one-to-one chat, team chat, and chat room, user profile picture, and user profile.

If you need to use GuardEase for content moderation, you must apply for the feature. After enabling, the types which enable GuardEase content moderation may be set on the console, such as IM one-to-one chat, team chat, text messages, and image messages.

The user-defined message is special. If the developer defines to filter message using GuardEase content moderation feature, the developer must describe the content of the user-defined message being text, image, or video through configuring antiSpamOption of NIMMessage when sending a message to implement content moderation processing by related type using GuideEase.

CommsEase content moderation includes general content moderation and GuardEase content moderation. If GuardEase content moderation app is enabled, messages will be filtered using GuardEase content moderation in priority. If a special configuration is required for the current message, Android needs to call setNIMAntiSpamOption method of IMMessage for a message to be sent, pass parameter is NIMAntiSpamOption object and the developer needs to create this NIMAntiSpamOption object. Supported configuration items include:

  • Parameters

NIMAntiSpamOption parameter

NIMAntiSpamOption parameter Description
enable Boolean, to be filtered using GuardEase content moderation. If GuardEase content moderation is not enabled in App, then the setting is invalid. If it is set as "false", the message is filtered using general content moderation only.
content String, user-defined content moderation field, valid for user-defined message only.
antiSpamConfigId String, optional, configuration ID of GuardEase content moderation. You can specify to filter the message using a certain configuration of GuardEase content moderation.

The value of the content parameter must be in JSON format. The size cannot exceed 5,000 bytes.

{
    "type": 1, //1: Text, 2: Image, and 3: Video
    "data": "" // URL of a text, image, or video.
}
  • Example
// This is an example account. You must sign up first for your account.
String account = "testAccount";
// The one-to-one chat type is used as an example.
SessionTypeEnum sessionType = SessionTypeEnum.peer-to-peer;
String text = "This message must be filtered by universal content moderation, instead of YiDun";
// Create a text message.
IMMessage textMessage = MessageBuilder.createTextMessage(account, sessionType, text);

// Create content moderation object.
NIMAntiSpamOption antiSpamOption = new NIMAntiSpamOption();
antiSpamOption.enable = false;
textMessage.setNIMAntiSpamOption(antiSpamOption);

// Send a message to a peer.
NIMClient.getService(MsgService.class).sendMessage(textMessage, false);

Content moderation using user-defined callbacks

CommsEase also supports user-defined content moderation using third-party callbacks.

Was this topic helpful?
Yes
No
  • Content moderation on the client
  • Retrieving term list
  • Detecting sensitive words
  • Content moderation using GuardEase
  • Content moderation using user-defined callbacks