Skip to main content

Message moderation mechanism

During message moderation, the content moderation service reviews the specifically designated fields within the message bodies. Different message types have different field names and content structures. Ensure these fields contain only the content to be moderated, as other content may affect moderation accuracy. This guide describes the message content fields within the bodies for each message type.

Following is a sample message structure:


_21
{
_21
"msg_id": "5I02W-XX-8278a",
_21
"timestamp": 1403099033211,
_21
"direction": "outgoing",
_21
"to": "XXXX",
_21
"from": "XXXX",
_21
"chat_type": "chat",
_21
"payload": {
_21
"bodies": [
_21
{
_21
// message body details
_21
}
_21
],
_21
"ext": {
_21
"key1": "value1"
_21
// more key-value pairs
_21
},
_21
"from": "XXXX",
_21
"to": "XXXX"
_21
}
_21
}

Text messages

For text messages, the content moderation service only reviews the content in the msg field within the message bodies.

ParameterTypeDescription
msgStringMessage content.

Example:


_8
{
_8
"bodies": [
_8
{
_8
"msg": "welcome to Agora Chat!",
_8
"type": "txt"
_8
}
_8
]
_8
}

Image messages

For image messages, the content moderation service downloads files from their URLs for review. The service focuses on the url field within the bodies of these messages.

ParameterTypeDescription
urlStringURL address of the image message.

Image message bodies example:


_15
{
_15
"bodies": [
_15
{
_15
"file_length": 128827,
_15
"filename": "test1.jpg",
_15
"secret": "DRGM8OZrEeO1vaXXXXXXXXHBeKlIhDp0GCnFu54xOF3M6KLr",
_15
"size": {
_15
"height": 1325,
_15
"width": 746
_15
},
_15
"type": "img",
_15
"url": "https://XXXX/XXXX/chatdemoui/chatfiles/65e54a4a-XXXX-XXXX-b821-ebde7b50cc4b"
_15
}
_15
]
_15
}

Custom messages

info

To use custom message moderation, Enable the moderation feature in Agora Console, then contact technical support to enable custom message moderation.

For custom messages submitted for moderation, the customExts parameter must include a moderation node, as shown in the following example:


_13
{
_13
"customExts": {
_13
"moderation": {
_13
"enable": true,
_13
"contents": [
_13
{
_13
"type": "text",
_13
"data": "Hello World"
_13
}
_13
]
_13
}
_13
}
_13
}

The parameters in the moderation node are described in the following table:

ParameterTypeDescription
enableBooleanWhether to enable moderation.
- Set to true to enable moderation.
- Set to false to disable moderation.
contentsArrayMessage content.
typeStringMessage type. Currently, the moderation service supports only text and image messages, so this field can only be set to text or img.
dataStringContent to be moderated.
- For text messages: the actual message content.
- For image messages: the image URL.