/ Platform API
Platform API
    Chat Platform API v3
    Chat Platform API
    Chat Platform API
    Version 3

    Profanity-triggered moderation

    Copy link

    Based on the profanity filter, this feature moderates users who are sending profanity words to a channel. You can apply profanity-triggered moderation as a global application setting or only to channels with a custom type. You can also adjust the level of the moderation by configuring the number of violation limit, the time window for counting violations, and the type of moderation penalty.


    HTTP request

    Copy link
    // To apply the settings application-wide.
    PUT https://api-{application_id}.sendbird.com/v3/applications/settings_global
    
    // To apply the filter to channels with a custom channel type.
    PUT https://api-{application_id}.sendbird.com/v3/applications/settings_by_channel_custom_type/{custom_type}
    

    Parameters

    Copy link

    The following table lists the parameters that this action supports.

    Required
    Parameter nameTypeDescription

    custom_type

    string

    Specifies the custom channel type to apply a set of settings to a channel.


    Request body

    Copy link

    The following table lists the properties of an HTTP request that this action supports.

    Properties
    OptionalTypeDescription

    profanity_triggered_moderation

    nested object

    Specifies a moderation configuration to impose a penalty on users who reach the profanity violation limit within a channel.

    profanity_triggered_moderation.count

    int

    Specifies the number of profanity violations that would automatically impose a penalty on the user. A value of 0 indicates that the moderation is turned off. A value of 1 or greater indicates that the moderation is turned on and the user is penalized for their violations within the time period set in the duration property.

    profanity_triggered_moderation.duration

    int

    Specifies the time period in seconds. This time frame is used to count the number of violations a user commits within a channel. For example, if the value of the count property is 2 and the value of the duration property is 5, the number of violations equal to or greater than two will be moderated every five seconds. The maximum acceptable value is 86400, which is 24 hours. (Default: 1 second)

    profanity_triggered_moderation.action

    int

    Specifies the type of moderation penalty. The penalty is imposed permanently unless you cancel it. Acceptable values are the following:
    - 0: imposes no action as penalty. This is the default value.
    - 1: mutes the user in the channel.
    - 2: kicks the user out of the channel.
    - 3: bans the user from the channel.

    application widechannels with custom type
    {
        "profanity_filter": {
            "keywords": "dumb,dummy",
            "regex_filters": [
                {
                    "regex": "[^!@#$%^&*]*(damn|crap)[^!@#$%^&*]*"
                },
                {
                    "regex": "(http://|https://)?(casino|sex)+([-.]{1}[a-z0-9]+)*.[a-z]{2,5}(:[0-9]{1,5})?(/.*)?"
                }
            ],
            "type": 2
        },
        "profanity_triggered_moderation": {
            "count": 5,
            "duration": 5,
            "action": 1
        }
    }
    

    If you want to turn off the profanity-triggered moderation, send a PUT request with a value of the count property set to 0 as shown below:

    application widechannels with custom type
    {
        "profanity_triggered_moderation": {
            "count": 0
        }
    }
    

    Response

    Copy link

    If successful, this action returns the updated moderation settings or channels with a custom channel type in the response body.

    In the case of an error, an error object is returned. A detailed list of error codes is available here.