How to set up content suppression
This guide describes how to add content suppression to your chat for the purposes of moderation.
With content suppression, you can add a forbidden word list or custom suppression patterns to automatically block out words, word parts, or complete phrases from chat messages. This way, you can offer a safe and respectful environment for everyone.
Your TalkJS content suppression replaces each instance of a blocked word or pattern in a message with a replacement text you can specify. It leaves the rest of the message intact, and doesn't prevent the message from being sent altogether.
To follow along with this guide, you need:
- Admin access to the TalkJS dashboard for your project.
- Login to your TalkJS dashboard and go to the Chat UI tab.
- In the section Mask unwanted content, under Mode, choose what type of content suppression you want to apply.
| Option | Suppression effect |
|---|---|
| No suppression | Doesn't block any content. Default option. |
| Selective suppression | Blocks content. Shows what content is suppressed only in messages from other users, not in the user's own messages. |
| Global suppression | Blocks content. Always shows what content is suppressed. |
Selective suppression doesn't show the user when content in their own message content is suppressed. This makes it more difficult for users to try to work around your content moderation system. That said, it can be confusing if people in a conversation are unaware that parts of their messages are getting blocked.
- In the section Replacement text, specify what text should replace the suppressed content. By default, text is replaced with
(hidden information), localized to the user's language.
You can suppress content using a forbidden word list, custom suppression patterns, or use both together.
A forbidden word list allows you to add a plain list with any words or phrases you'd like to suppress. Suitable for most use cases.
To add a forbidden word list:
- On your TalkJS dashboard, go to the Chat UI tab.
- In the section Forbidden words, add any words or phrases that you'd like to suppress. Add one word or phrase per line.
Matches for the words or phrases you add are case insensitive. Empty lines and lines that begin with # are ignored.
Custom suppression patterns allow you to define a pattern to match all the words or word parts that you would like to block from messages. Use this if you need more complex suppression patterns.
To define a custom pattern to suppress in messages:
- On your TalkJS dashboard, go to the Chat UI tab.
- In the section Custom suppression patterns, select Add entry.
- Add your pattern for content suppression. Your entry is saved automatically.
The custom suppression pattern you add must be a valid JavaScript regular expression literal, consisting of a pattern enclosed between two slashes (/.../). You can use special characters to block certain variant spellings of a word, to prevent users from circumventing your word blocklist. For example, if you'd like to block mentions of popular fruit, then to block both ‘banana’, ‘baaanaaanaaa’ and ‘b4n4n4’, add /b\w+n\w+n\w+/i.

Suppressed words on a forbidden word list get replaced by the text '(hidden information)', localized to the user's language, or any custom text you specify.
Broad suppression patterns can also catch unrelated words you don't want to block. To avoid this, you can add exceptions for patterns that shouldn't get blocked by your custom suppression pattern.
To add an exception:
- In the section Suppression exceptions, select Add entry and add an exception pattern. Your entry is saved automatically.
For example, if you're blocking mention of popular fruits but would still like to allow the phrase “they’re going bananas”, specify /bananas/i in the exceptions field.
Exception patterns also need to be valid JavaScript regular expression literals.
You now have content suppression for your chat.