Development Guide
The Instant Messaging (IM) service supports content moderation for IM messages.
- The IM service has a built-in sensitive word filtering mechanism. Note that this mechanism only serves as basic protection and is limited to text content (default maximum of 50 sensitive words).
- If you need to implement moderation yourself or integrate with third-party moderation services, you can use the Pre-messaging Callback service.
If a message is blocked due to being identified as violating content, the sender will not receive a notification by default. If your app wants to notify senders when their messages are blocked, you can submit a ticket to enable the Blocked Message Status Callback to Sender feature and set up client-side listeners (requires Android/iOS SDK version ≧ 5.1.4, Web ≧ 5.0.2). For details, see Message Block Notification Callback.
By default, for one-to-one chat messages that contain sensitive words or fail moderation, the message will still be stored in the sender's server-side message history. The user will also receive this message as compensation when logging in from other devices. If you don't want messages containing sensitive words or failing moderation to appear in the sender's message history or trigger message compensation, you can enable the Do Not Save Sensitive One-to-One Messages to Sender's History feature in the RongCloud Console under Chat > Chat settings > Security & Moderation.
Sensitive Word Filtering Mechanism
Note
- The client does not provide management interfaces for this feature, only callback interfaces to notify senders when messages are blocked. See Message Block Notification Callback for details.
The Sensitive Word Filtering Mechanism is a basic protection feature that only identifies and filters sensitive words in text message content. For messages containing sensitive words, you can choose to either block the message (preventing delivery to recipients) or replace the sensitive words according to specified rules before delivery.
Currently supported languages for sensitive word filtering include: Chinese, English, Japanese, German, Russian, Korean, and Arabic.
You can manage sensitive words in development or production environments under your App Key through the following methods:
| Function Description | Client API | RongCloud Server API | Console |
|---|---|---|---|
| Add sensitive words (with replacement content support) | Not available | Add Sensitive Word | Via Embedded Console |
| Remove sensitive words | Not available | Remove Sensitive Word | Via Embedded Console |
| Batch remove sensitive words | Not available | Batch Remove Sensitive Words | Via Embedded Console |
| Get sensitive word list (with replacement content) | Not available | Get Sensitive Word List | Via Embedded Console |
Default Behavior
- Maximum of 50 sensitive words by default
- Only applies to messages sent from client SDKs by default
- Only supports identifying sensitive words in official built-in text message types (message identifier
RC:TxtMsg) by default. Supported for one-to-one chat, group chat, chatroom, and ultra group conversations. Modified text messages in ultra groups also undergo sensitive word identification, blocking or filtering by default.
Configuration Adjustments
- To enable sensitive word filtering for messages sent via Server API, toggle on Filter server API messages in the RC Console under Chat > Chat settings > Security & Moderation.
- To enable the sensitive word mechanism for custom message types, use the Embedded Console to click Configure Custom Messages. Provide the custom message type's
ObjectNameand the corresponding key in the message content (Content) JSON structure to filter sensitive words in the specified value.
Pre-messaging Callback Service
If you want to integrate your own moderation system or third-party content moderation services, you can use the Pre-messaging Callback service.
The Pre-messaging Callback service (formerly Template Routing) provides a message filtering mechanism. You can synchronize specific messages to your designated server based on parameters like sender ID, recipient ID, message type, and conversation type. In ultra group business, message content modifications and message extension updates can also be synchronized to your designated server.
After messages are synchronized to your server, you can use your own moderation system or integrate third-party moderation systems. The RongCloud server will determine whether to deliver messages, replace message content, and how to perform replacements based on responses from your application server.
You can manage the Pre-messaging Callback service status and routing rules for development or production environments under your App Key through the Pre-messaging Callback page in the Console.
For instructions on creating routing rules and detailed callback parameters, refer to the Pre-messaging Callback documentation.