How to add a word blocklist for content moderation

A core part of content moderation is to ensure that your platform offers a safe and respectful environment for everyone. A word blocklist is one of the chat moderation tools that can help you make sure that no inappropriate or harmful content gets shared in your chat.

A word blocklist is a list of words or phrases to block in chat messages. In TalkJS, you can add a word blocklist to automatically suppress unwanted content.

This guide will run you through how to add a word blocklist to your chat.

Steps

1. Login to your TalkJS dashboard and go to the Chat UI tab.

2. To select what type of content suppression you want to apply, in the section Mask unwanted content, under Mode, choose from:

  • No suppression – The default option, where no specific word patterns are blocked.
  • Global suppression – An option to suppress content in both the current user’s own messages and in messages they receive from others.
  • Selective suppression – An option to mark content as suppressed only in messages that the current user receives from others. With this option, the current user will not know when their own message content was suppressed. This can make it more difficult for the user to find a workaround and ‘trick’ the content moderation system. At the same time, it can also lead to confusion in a conversation if a user is unaware of exactly what message the other user has received.
Drop-down menu to select the mode of word suppression

3. To specify what text should replace the suppressed content, in the section Mask unwanted content, under Replacement text, fill out your replacement text in the supplied field. As a default, it will show (hidden information), localized to the current user's language.

4. To add a pattern to match all the words that you would like to block from messages, click Add entry under Custom suppression patterns.

The custom suppression pattern you add must be a valid JavaScript regular expression literal, consisting of a pattern enclosed between two slashes (/.../).

You can add a list of exact words to block. For example, to block mention of some popular fruit, add /banana|apple|pear|cherry/i (case insensitive). Or you can use special characters to block certain variant spellings of a word, to prevent users from circumventing your word blocklist. For example, to block both ‘banana’, ‘baaanaaanaaa’ and ‘b4n4n4’, add /b\w+n\w+n\w+/i .

When composing your wordlist, be aware of the Scunthorpe problem of unintentionally blocking benign uses of blocked strings or substrings.

Your TalkJS word blocklist will replace each instance of a blocked word pattern in a message with the replacement text. It will leave the rest of the message intact, and will not prevent the message from being sent altogether.

Suppression of a word on a blocklist

5. To add an exception for one or more words that should not get blocked by your custom suppression pattern, click Add entry under the Exceptions heading and add an exception pattern. Exception patterns also need to be valid JS regular expression literals.

For example, to allow the phrase “they’re going bananas” even while blocking mention of popular fruits, specify /bananas/i in the exceptions field.

You now have a working word blocklist for content moderation.


Do you have any questions about moderating your chat? Get in touch.