ActiveFence Video Content Moderation

Updated

Integrate and use the ActiveFence content moderation extension in your app.

ActiveFence provides trust and safety solutions to protect online platforms and their users from malicious behavior and content. By integrating ActiveFence capabilities in your app, you can design the exact content moderation solution you need. Content moderation is powered by AI-driven automated detection for text, audio, image, and video content, enabling you to moderate, enforce policies, manage user flags, and send notifications across multiple abuse areas and languages.

The following figure shows the ActiveFence workflow to moderate content sent by a specific user to a channel:

This page shows you how to integrate and use the ActiveFence content detection and moderation extension in your app.

Prerequisites

The development environment requirements are as follows:

  • Android Studio 4.1 or later.
  • A physical device (not an emulator) running Android 5.0 or later.
  • Implemented the SDK quickstart.
  • If you use RTC SDK tokens, ensure that you are using AccessToken2 to enable ActiveFence video content moderation.

Project setup

In order to configure ActiveFence:

  1. Set up your ActiveFence account.

    • In Agora Extensions Marketplace, select ActiveFence, then click Activate Your Account; or contact extensions.marketplace@agora.io to activate the extension.
    • Follow the activation email instructions to activate your ActiveFence account.
  2. Configure your ActiveFence API key.

    • In ActiveFence, open Account Settings.
    • Click Data Management > ActiveFence API Keys and create a key.
    • Save the key securely and share the key information with Agora so the services can be connected.
  3. Connect your app to your ActiveFence account.

    • Email support@agora.io and provide your company name, company email, Agora App ID, and ActiveFence API key.
  4. Customize your callback fields.

    • In ActiveFence, open Account Settings > Moderation Capabilities > Custom Fields.
    • Add editable fields for cname, requestId, sid, source, timestamp, and uid.
    Title & KeyTypeMeaning
    cnameTextRTC channel name
    requestIdTextRequest ID of the screenshot
    sidTextSession ID
    sourceTextSource of screenshot (agora)
    timestampNumberTimestamp, for example 20230614050206430
    uidNumberUser ID (unique in a channel)

The editable fields are:

Title and keyTypeMeaning
cnameTextRTC channel name
requestIdTextRequest ID of the screenshot
sidTextSession ID
sourceTextSource of the screenshot, for example agora
timestampNumberTimestamp, for example 20230614050206430
uidNumberUser ID, unique in a channel
  1. Configure action webhooks and workflows in ActiveFence.
  2. Invite users and start moderating content in ActiveFence.

Integrate the extension

Now that ActiveFence is activated, set up your webhook receiver and then enable content inspection in your SDK project.

Set up your webhook

To react to content moderation callbacks, create a server that receives and interprets the webhook data. For example:

  1. Open agora-activefence-kicker and deploy the server with its one-click flow.
  2. Add the deployment link plus /kick/ to the webhook URL for the desired event in ActiveFence.

Initialize ContentInspectConfig

Set up the inspect config inside ContentInspectModule. If you use a string UID to join the channel and want to receive it in the webhook callback, pass the string UID to extraInfo inside ContentInspectConfig.

val contentInspectModule = ContentInspectModule()
contentInspectModule.type = ContentInspectConfig.CONTENT_INSPECT_TYPE_IMAGE_MODERATION
contentInspectModule.interval = 5
val contentInspectConfig = ContentInspectConfig()
contentInspectConfig.modules[0] = contentInspectModule
contentInspectConfig.moduleCount = 1
contentInspectConfig.extraInfo = "YourExtraInfo"

Apply ContentInspectConfig

Enable content inspection after joining a channel and after the local video is published and played. If you need support for taking screenshots for multiple video streams and uploading them, use enableContentInspectEx.

val returnVal = agoraEngine?.enableContentInspect(true, contentInspectConfig)
val returnValEx = agoraEngine?.enableContentInspectEx(enabled, config = config, connection = connection)

Catch banning events

To know when your local user is banned from the scene, use the connection state callback:

override fun onConnectionStateChanged(state: Int, reason: Int) {
  super.onConnectionStateChanged(state, reason)
  if (
    state == Constants.CONNECTION_STATE_FAILED &&
    reason == Constants.CONNECTION_CHANGED_BANNED_BY_SERVER
  ) {
    showMessage("Stream banned by the server")
  }
}

Reference