As your number of users grows, so does the risk of unwanted spam messages in your chat. Even more so if your chat is available on an open platform that anyone can join.

TalkJS has a number of built-in chat moderation tools that you can use to reduce the risk of spam messaging in your chat, keep your channels clean, and protect your community.

This guide will run you through how to enable three common anti-spam features for your chat:

  • Link blocking
  • Disallowing mentions
  • Preventing shouting (all caps messaging)

Spam messages will often encourage people to click on external links. You can reduce spam by not allowing specific groups of users to send links, or by only allowing them to send links that point to some of a specific set of website addresses.

To block link sharing, take the following steps:

  1. Login to your TalkJS dashboard.
  2. In 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. In the section Mask unwanted content, under Mode, choose what type of content suppression you would like to apply. You can choose from:

    Do not suppress any content – The default option, where no links are suppressed.
    Suppress content in all messages – An option to suppress links 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 links as suppressed only in messages that the current user receives from others, but not in their own messages. The user will not know that their link was suppressed.
  4. To suppress links, check the Suppress links checkbox that appears.
  5. To specify what text should replace the suppressed links, in the section Mask unwanted content, under Replacement, fill out the field with your replacement text.

    By default it will show (hidden information), localized to the current user's language.
  6. To add exceptions for links to certain domains that a user is allowed to share, in the section Allowed hostnames, click on the plus (+) to add any additional (sub)domains that you would like to allow linking to.

    To allow any (sub)domain, use a asterisk (*) in the relevant part of the web address. For example, to allow links to any website with a .com top-level domain, use *.com. Or to allow links to a specific website and all of its subdomains, use example.com and *.example.com.
  7. Click the Save all roles button in the sticky menu at the top of the screen to save changes to your link blocking setting.

You are now blocking links for spam prevention.

Disallow mentions

Spamming can also involve irrelevant and unsolicited messages, where a spammer tries to draw the attention of users by mentioning them in the chat.

In TalkJS, users can mention other users by writing an @-sign followed by a name. Depending on their notification settings, a user will get a notification whenever they are mentioned.

To shield your users from unsolicited mentions, you can decide not to allow certain user groups to mention people in the chat.

To disallow mentions, take the following steps:

  1. Login to your TalkJS dashboard.
  2. In 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 not allow users to mention other users, make sure that the Allow mentions checkbox that appears is unchecked.
  4. Click the Save all roles button in the sticky menu at the top of the screen to save your settings for disallowing mentions.

You are now disallowing mentions for spam prevention.

Prevent shouting (all caps messaging)

Sometimes spam can be less about what is said, and more about how it is said. For example, using ALL CAPS can be experienced as shouting, and can make certain users feel unwelcome.

In TalkJS you can suppress message content that uses a sequence of all caps characters.

To prevent shouting, take the following steps:

  1. Login to your TalkJS dashboard.
  2. In 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. In the section Mask unwanted content, under Mode, choose what type of content suppression you would like to apply. You can choose from:

    Do not suppress any content – The default option, where shouting is not suppressed.
    Suppress content in all messages – An option to suppress shouting 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 shouting as suppressed only in messages that the current user receives from others, but not in their own messages. The user will not know that their shouting was suppressed.
  4. To add a custom suppression pattern to suppress shouting, under Custom suppression patterns, click the plus (+) sign.

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

    To suppress any content in a message that has a sequence of ten or more all caps characters, you can for example add the following custom suppression pattern:

    /^[^a-z]{10,}$/

    If you would like to set a different threshold for the number of sequential all caps characters that should be suppressed, change the 10 in this regular expression to your desired threshold number.
  5. To specify what text should replace the suppressed all caps content, in the section Mask unwanted content, under Replacement, fill out the field with your replacement text.

    By default it will show (hidden information), localized to the current user's language.
  6. Click the Save all roles button in the sticky menu at the top of the screen to save your settings for suppressing all caps content in messages.

This shouting prevention setting will replace each instance of a shouting pattern in a message with the replacement text. It will leave the rest of the message intact and will not prevent the message itself from being sent.

You are now preventing shouting (all caps messaging) for spam prevention.


Do you have any questions about preventing spam messaging in 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.