How It Works
- When a user sends a message, CometChat retrieves the webhook URL from the configured List.
- The message, along with previous conversation messages (if a context window is set in settings), is sent to the webhook.
- The webhook (your external API) processes the data using your custom moderation logic.
- The webhook responds with a structured decision containing details about the moderation outcome.
- CometChat processes the response and applies the moderation decision in real-time.
Integration
Step 1: Configure Custom API Settings
-
Login to the CometChat Dashboard
- Navigate to CometChat Dashboard and select your app.
-
Navigate to Moderation Settings
- Go to Moderation → Settings in the left-hand menu.
-
Open Custom API Settings Tab
- Click on the Custom API tab within the Moderation Settings.
-
Fill in the Custom API Configuration
-
Set Action on API Error
- Define how the system should respond if the Custom API is unavailable (e.g., “Allow message” or “Block message”).
-
Set Context Window
- Specify the number of previous messages in a conversation that will be used for context.
-
Set Action on API Error
- Click Save Settings
Step 2: Enable Custom API Moderation
- Navigate to Moderation → Rules.
- Click “Create New Rule”.
- Select Custom API as the moderation type.
- The rule you create should be of type “Text Contains” or “Image Contains”.
- Save the rule.
Payload Sent to Webhook
When a message is sent, CometChat invokes your webhook with a payload that includes:- he latest message (the one just sent) — provided in full detail (entire message object)
- The previous messages — provided as plain text only, for context (based on the context window setting)