AI Integration Quick Reference
AI Integration Quick Reference
Overview
Flagging messages allows users to report inappropriate content to moderators or administrators. When a message is flagged, it appears in the CometChat Dashboard under Moderation > Flagged Messages for review.For a complete understanding of how flagged messages are reviewed and managed, see the Flagged Messages documentation.
Prerequisites
Before using the flag message feature:- Moderation must be enabled for your app in the CometChat Dashboard
- Flag reasons should be configured under Moderation > Advanced Settings
How It Works
Get Flag Reasons
Before flagging a message, retrieve the list of available flag reasons configured in your Dashboard:- Dart
Response
The response is a list ofFlagReason objects containing:
| Property | Type | Description |
|---|---|---|
id | String | Unique identifier for the reason |
name | String | Display name for the reason |
description | String? | Optional description of the reason |
createdAt | DateTime? | Timestamp when the reason was created |
updatedAt | DateTime? | Timestamp when the reason was last updated |
Error
Error
| Parameter | Type | Description | Sample Value |
|---|---|---|---|
code | String | Error code identifier | "ERR_CHAT_API_FAILURE" |
message | String | Human-readable error message | "Failed to fetch flag reasons." |
details | String | Additional technical details | "An unexpected error occurred while processing the request." |
Flag a Message
To flag a message, use theflagMessage() method with the message ID and a FlagDetail object:
- Dart
Parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
messageId | int | Yes | The ID of the message to flag |
flagDetail | FlagDetail | Yes | Contains flagging details |
flagDetail.reasonId | String | Yes | ID of the flag reason (from getFlagReasons()) |
flagDetail.remark | String? | No | Additional context or explanation from the user |
Response
Response
On Success — A
String message confirming the message has been flagged:| Parameter | Type | Description | Sample Value |
|---|---|---|---|
message | String | Success confirmation message | "Message 123 has been flagged successfully." |
Error
Error
| Parameter | Type | Description | Sample Value |
|---|---|---|---|
code | String | Error code identifier | "ERR_CHAT_API_FAILURE" |
message | String | Human-readable error message | "Failed to flag the message." |
details | String | Additional technical details | "An unexpected error occurred while processing the request." |
Complete Example
Here’s a complete implementation showing how to build a report message flow:- Dart
Next Steps
Receive Messages
Handle incoming messages and real-time events
Delete Message
Remove messages from conversations
AI Moderation
Automate content moderation with AI
Delivery & Read Receipts
Track message delivery and read status