Skip to main content
Quick Reference

Overview

AI Moderation in the CometChat SDK helps ensure that your chat application remains safe and compliant by automatically reviewing messages for inappropriate content. This feature leverages AI to moderate messages in real-time, reducing manual intervention and improving user experience.
For a broader understanding of moderation features, configuring rules, and managing flagged messages, see the Moderation Overview.

Prerequisites

Before using AI Moderation, ensure the following:
  1. Moderation is enabled for your app in the CometChat Dashboard
  2. Moderation rules are configured under Moderation > Rules
  3. You’re using a CometChat SDK version that supports moderation

How It Works

Supported Message Types

Moderation is triggered only for the following message types:

Moderation Status

The getModerationStatus() method returns one of the following values:

Implementation

Step 1: Send a Message and Check Initial Status

When you send a text, image, or video message, check the initial moderation status:

Step 2: Listen for Moderation Results

Register a message listener to receive moderation results in real-time:
Always remove message listeners when the component unmounts to prevent memory leaks.

Step 3: Handle Disapproved Messages

When a message is disapproved, handle it appropriately in your UI:
  • Always check getModerationStatus() after sending a message to show appropriate UI indicators (e.g., a pending badge)
  • Register the onMessageModerated listener early in your app lifecycle so you don’t miss moderation results
  • Provide clear feedback to users when their message is disapproved — avoid silently hiding content without explanation
  • Custom and Action messages are not moderated — if you need moderation on custom message types, implement your own server-side checks
  • Consider caching moderation status locally to avoid re-checking on message list re-renders
  • Moderation status always PENDING: Ensure moderation rules are configured in the CometChat Dashboard under Moderation > Rules.
  • onMessageModerated not firing: Verify you registered a MessageListener with the correct listener ID and that moderation is enabled for your app.
  • Custom messages not being moderated: This is expected — AI Moderation only applies to text, image, and video messages.
  • Disapproved messages still visible: Make sure your onMessageModerated handler updates the UI when a message status changes to DISAPPROVED.

Next Steps

Flag Message

Allow users to report inappropriate messages

AI Agents

Add intelligent AI agent interactions