To maintain a safe, respectful, and engaging environment for your users, our platform offers a powerful Moderation Integration system. This system allows you to automatically review, filter, and take action on user-generated messages, images, and videos before they are delivered.With Moderation Integration, you can define flexible rules, receive real-time updates, and ensure your app meets community guidelines, legal standards, and brand values without manual intervention.
Zero code required — Moderation is built into CometChat UI Kits. Simply configure rules in the Dashboard and the UI Kit handles everything automatically.
SDK Integration
Full control — Use the CometChat SDK to handle moderation programmatically in your custom UI implementation.
CometChat provides a set of default moderation rules designed to cover common use cases such as offensive language, spam, and inappropriate content. You can enable these rules to start moderating messages immediately, without any additional setup.
If you have specific requirements, you can create custom moderation rules tailored to your app’s needs:
Using the CometChat Dashboard — A simple, no-code interface for visually creating and managing moderation rules.
Using the CometChat API — Programmatically create and manage moderation rules for advanced or automated workflows. See the Rules Management documentation.
To automate your moderation flow and receive updates in real time, configure a moderation webhook. This allows your system to react instantly when a message or media is moderated.
Webhooks are optional if you’re using the SDK’s onMessageModerated listener for real-time updates.
Once your moderation rules are configured in the Dashboard, integrate moderation into your application using the CometChat SDK. The SDK automatically handles moderation for all messages sent through CometChat.
Using UI Kit? Skip this section - the UI Kit handles everything automatically!
When you send a message, it’s automatically checked against your moderation rules. The message object contains a moderationStatus property:
JavaScript
Android (Kotlin)
iOS (Swift)
React Native
Flutter
Report incorrect code
Copy
Ask AI
const textMessage = new CometChat.TextMessage( receiverUID, "Hello, how are you?", CometChat.RECEIVER_TYPE.USER);CometChat.sendMessage(textMessage).then( (message) => { const status = message.getModerationStatus(); switch (status) { case CometChat.ModerationStatus.PENDING: console.log("Message is under moderation review"); break; case CometChat.ModerationStatus.APPROVED: console.log("Message approved and delivered"); break; case CometChat.ModerationStatus.DISAPPROVED: console.log("Message blocked by moderation"); break; } }, (error) => { console.log("Message sending failed:", error); });
Report incorrect code
Copy
Ask AI
val textMessage = TextMessage( receiverUID, "Hello, how are you?", CometChatConstants.RECEIVER_TYPE_USER)CometChat.sendMessage(textMessage, object : CometChat.CallbackListener<TextMessage>() { override fun onSuccess(message: TextMessage) { when (message.moderationStatus) { ModerationStatus.PENDING -> Log.d(TAG, "Message under review") ModerationStatus.APPROVED -> Log.d(TAG, "Message approved") ModerationStatus.DISAPPROVED -> Log.d(TAG, "Message blocked") } } override fun onError(e: CometChatException) { Log.e(TAG, "Message sending failed: ${e.message}") }})
Report incorrect code
Copy
Ask AI
let textMessage = TextMessage( receiverUid: receiverUID, text: "Hello, how are you?", receiverType: .user)CometChat.sendTextMessage(message: textMessage) { sentMessage in if let message = sentMessage as? TextMessage { switch message.getModerationStatus() { case "pending": print("Message under review") case "approved": print("Message approved") case "disapproved": print("Message blocked") default: break } }} onError: { error in print("Message sending failed: \(error?.errorDescription ?? "")")}
Report incorrect code
Copy
Ask AI
const textMessage = new CometChat.TextMessage( receiverUID, "Hello, how are you?", CometChat.RECEIVER_TYPE.USER);CometChat.sendMessage(textMessage).then( (message) => { const status = message.getModerationStatus(); if (status === CometChat.ModerationStatus.PENDING) { console.log("Message under review"); } else if (status === CometChat.ModerationStatus.DISAPPROVED) { console.log("Message blocked"); } }, (error) => console.log("Failed:", error));
Report incorrect code
Copy
Ask AI
TextMessage textMessage = TextMessage( text: "Hello, how are you?", receiverUid: receiverUID, receiverType: ReceiverTypeConstants.user,);CometChat.sendMessage( textMessage, onSuccess: (TextMessage message) { switch (message.moderationStatus?.value) { case ModerationStatusEnum.PENDING: print("Message under review"); break; case ModerationStatusEnum.APPROVED: print("Message approved"); break; case ModerationStatusEnum.DISAPPROVED: print("Message blocked"); break; } }, onError: (CometChatException e) { print("Message sending failed: ${e.message}"); },);
When a message is blocked (disapproved), handle it appropriately in your UI:
JavaScript
Android (Kotlin)
iOS (Swift)
Report incorrect code
Copy
Ask AI
function handleBlockedMessage(message) { const messageId = message.getId(); const senderUid = message.getSender().getUid(); // Option 1: Hide the message completely removeMessageFromUI(messageId); // Option 2: Show a placeholder showPlaceholder(messageId, "This message was blocked by moderation"); // Option 3: Notify the sender if (senderUid === currentUserUID) { showToast("Your message was blocked due to policy violation"); }}
Report incorrect code
Copy
Ask AI
fun handleBlockedMessage(message: BaseMessage) { val messageId = message.id val senderUid = message.sender.uid // Option 1: Hide the message completely removeMessageFromUI(messageId) // Option 2: Show a placeholder showPlaceholder(messageId, "This message was blocked by moderation") // Option 3: Notify the sender if (senderUid == currentUserUID) { Toast.makeText(context, "Your message was blocked", Toast.LENGTH_SHORT).show() }}
Report incorrect code
Copy
Ask AI
func handleBlockedMessage(_ message: BaseMessage) { let messageId = message.id let senderUid = message.sender?.uid // Option 1: Hide the message completely removeMessageFromUI(messageId) // Option 2: Show a placeholder showPlaceholder(messageId, text: "This message was blocked by moderation") // Option 3: Notify the sender if senderUid == currentUserUID { showAlert("Your message was blocked due to policy violation") }}