Configure callback notifications
Content Moderation sends the results of human moderation and subsequent reviews via asynchronous message notifications. To use or integrate this data, configure callback notifications. This topic describes how to configure callback notifications for human moderation and subsequent reviews.
Background information
There are two types of callback notifications for human moderation:
-
Human moderation callback notification: After the Content Moderation team completes a human moderation task, the server sends the results to your configured HTTP callback URL in a POST request.
-
Human review callback notification: After you confirm a review in the Content Moderation console, the server sends the review results to your configured HTTP callback URL in a POST request.
Key concepts
Before you configure callback notifications, understand the concepts in the following table.
|
Parameter |
Description |
|
callback URL |
A server address that you configure in the Content Moderation console. It is typically the public URL of your business server. The callback URL must meet the following requirements:
|
|
seed |
The seed value verifies that requests sent to your configured callback URL originate from the Content Moderation server. |
|
Retry attempts |
An HTTP status code of 200 from your server indicates successful receipt. Any other code indicates a failure. If a delivery fails, the Content Moderation server retries up to three times. |
|
Callback data |
The data returned by the Content Moderation server to your configured callback URL. For the data structure, see Callback notification form data. |
Table 1. Callback notification form data
|
Parameter |
Type |
Description |
|
checksum |
String |
A checksum generated by concatenating Note
To prevent tampering, recalculate the checksum when you receive the notification and compare it to the received checksum value. |
|
content |
String |
A stringified JSON object. You must parse this string to use it as a JSON object. For the structure of the content field after parsing, see Description of the content form field. Note
The structure of the content parameter differs between the content moderation API and OSS violation detection. |
Prerequisites
To use this service, you must request activation from after-sales support. If the Content Moderation service is not activated, the manual review section is not visible in the console.
To enable the service, contact after-sales support by joining the Alibaba Cloud Content Moderation Q&A group on DingTalk (Group ID: 35573806). When you request to join, provide your company name and role (for example, Developer, Product Manager, or Reviewer). For example: XXX Company + Developer.
Human moderation callback notifications
The human moderation API returns results asynchronously through callbacks. Human moderation includes machine and human review and human-only review. The callback configuration for each mode is different and described below.
Machine and human review
If you use both the Alibaba Cloud human moderation and machine auditing services, you must configure message notifications in the console to receive callbacks for human moderation. Follow these steps:
Log on to the Content Moderation console.
-
In the left-side navigation pane, choose .
-
On the Notification tab, click Create New Notification.
-
In the Create New Notification dialog box, enter a Title and Callback URL, select an Encryption algorithm, Notification type, and Audit Result, and then click Confirm.
After you save the configuration, the system automatically generates a seed. The seed value verifies that requests to your callback URL originate from Alibaba Cloud. Securely store the generated seed.
Important-
If you have already configured a callback notification service for machine auditing, you can reuse the existing configuration or create a new one.
-
By default, the system sends callbacks for all review results, but you can choose to receive them only for specific results.
-
For Notification Type, select Manual Review Results by AlibabaCloud.
-
Encryption algorithm options:
-
SHA256: Uses the HMAC-SHA256 encryption algorithm.
-
SM3: Uses the SM3 encryption algorithm and returns a hexadecimal string consisting of lowercase letters and digits.
For example, encrypting abc with SM3 returns 66c7f0f462eeedd9d1f2d46bdc10e4e24167c4875cf2f7a2297da02b8f4ba8e0.
-
-
-
On the Machine Moderation page, click BizType Manage.
-
On the BizType Manage tab, find the target business scene, and in the Operation column, click Choose Notification Plan to link the Callback notification scheme that you configured in Step4.
Human-only review
If you use the Alibaba Cloud human-only review service, you must include the callback (callback URL) and seed (verification string) parameters in your API request to enable callbacks.
-
Prepare an HTTP callback URL and a seed parameter to receive the scan results.
-
When you call an asynchronous content moderation API, include the callback and seed parameters in your request.
For parameter details, see Image human moderation, Video human moderation, Text human moderation, and Review human moderation results.
Content form field
After you enable callback notifications, Content Moderation sends API callbacks based on your configuration. These notifications contain the content form data. The following table describes the structure of the content field.
Table 2. Structure of the content form field
|
Parameter |
Type |
Required |
Description |
|
humanAuditResult |
JSONObject |
No |
Contains the result of Alibaba Cloud's human moderation. This field is included only if you have purchased the human moderation service. For details, see humanAuditResult. |
Table 3. humanAuditResult
|
Parameter |
Type |
Required |
Description |
|
suggestion |
String |
Yes |
The suggested action based on the human moderation result. Valid values:
|
|
customAuditFlag |
Boolean |
Yes |
Note
This flag distinguishes between results from the initial Alibaba Cloud human moderation and a subsequent review performed by you. |
|
taskId |
String |
Yes |
The ID of the moderation task. Use this ID to correlate the callback with the original moderation task. |
|
dataId |
String |
Yes |
The ID of the moderated content. |
|
labels |
StringArray |
No |
The violation labels assigned during human moderation. Note
This parameter is not returned by default. This feature incurs additional charges. For more information, contact the sales team. |
Example of content
{
"humanAuditResult": {
"suggestion": "pass",
"customAuditFlag": false,
"dataId": "yyyy",
"labels": [
"porn",
"vulgar"
],
"taskId": "xxxxxx"
}
}