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.

Because blocklists in TalkJS are added at the role level, you have the flexibility to filter out specific content for different types of users—for example, word blocklists that differ between a buyer and a seller, between students and a teacher, or between event attendees and a moderator.

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


1. Login to your TalkJS dashboard.

2. To select the role that you want to add a word blocklist for, go to the Roles tab. From the overview under Your current roles, click on the role name. You will be led to the settings for your selected role.

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

  • Do not suppress any content – The default option, where no specific word patterns are blocked.
  • Suppress content in all messages – An option to suppress content in both the current user’s own messages and in messages they receive from others.
  • Only suppress content in messages written by others – 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.
The ‘Mask unwanted content’ section in the TalkJS dashboard with a drop-down menu to select the suppression mode. The drop-down menu lists three options: ‘Do not suppress any content’, ‘Suppress content in all messages’, ‘Only suppress content in messages written by others’.
Drop-down menu to select the mode of word suppression

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

5. To add a pattern to match all the words that you would like to block from messages, click the plus (+) sign 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.

Example of a word that is suppressed in a message. The message shows the word “Hey”, followed by “(hidden information)” in italics. Next to the message is the profile picture of the sender.
Suppression of a word on a blocklist

6. To add an exception for one or more words that should not get blocked by your custom suppression pattern, click the plus (+) sign 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.

7. To save your word blocklist changes, click the Save all roles button in the sticky menu at the top of the screen.

You now have a working word blocklist for content moderation.

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

You’ve successfully subscribed to TalkJS
Welcome back! You’ve successfully signed in.
Great! You’ve successfully signed up.
Your link has expired
Success! Check your email for magic link to sign-in.