How It Works
- User sends a message in your chat application
- CometChat intercepts the message and POSTs it to your webhook URL along with optional conversation context (previous messages as plain text)
- Your webhook processes the message using your custom moderation logic
- Your webhook responds with a JSON decision containing
isMatchingCondition,confidence, and optionalreason - CometChat compares the returned confidence against your configured threshold and applies the appropriate action (block, flag for review, etc.)
Getting Started
Build Your Moderation Endpoint
Create a webhook that accepts POST requests with message data. Your endpoint must return JSON with:
isMatchingCondition(boolean) – whether the content violates rulesconfidence(number 0.0-1.0) – confidence score of the decisionreason(string, optional) – explanation for flagging
Create a Custom API List
In the CometChat Dashboard, go to Moderation → Settings → List and create a new list with:
- Category: Custom API
- URL: Your webhook endpoint
- Basic Auth (optional): Username and password for secure authentication
Configure Advanced Settings
Under Moderation → Settings → Advanced Settings, configure:
- Context messages (0-10): Number of previous messages to include for context-aware moderation
- Error handling: Choose to approve or block messages when your API is unavailable
Create a Moderation Rule
Go to Moderation → Rules and create a rule that:
- Selects your Custom API list
- Sets a confidence threshold (e.g., “greater than 80%”)
- Defines actions when content is flagged
Custom API Configuration
Step-by-step guide to configure your custom moderation API
Handle Moderation Events (Optional)
Set up webhooks to receive notifications when messages are approved or blocked by your moderation logic.
Moderation Events
Learn about moderation webhook events
Key Features
- Contextual Moderation – Include up to 10 previous messages from the conversation for context-aware analysis
- Secure Authentication – Optional Basic Auth support for webhook security
- Confidence-Based Decisions – Set confidence thresholds to fine-tune when actions are triggered
- Configurable Error Handling – Choose to approve or block messages when your API is unavailable or returns an error
- Full Message Details – Receive complete message objects including sender/receiver info, timestamps, and metadata
- Real-time Processing – Moderation decisions are applied before message delivery