Building a Chat System – Part 4

by 

| July 18, 2023 | in

In our journey to build a chat system, we’ve covered setting up the Ionic framework, creating a user in Azure Chat, and adding the ability to store more messages. Now it’s time to clean up our language.

With any chat solution, you run the risk of communication creating some points of conflict. One of those points of contention would be if some naughty words were used in the chat itself.

We have to be careful with worrying about a few naughty words here or there. But in this blog post, I’ll give you a way to blank out unwanted naughty words.

The easiest way I know to solve this problem is with the npm package called “bad-words”.

You can install the npm bad-words package by running:

npm i bad-words

Once installed, using the bad-words package to clean the language of our chats is straightforward. It includes a clean method that will remove naughty words for us and replace them with *.

Now we can remove naughty words from our chat. In the example below, “Why are you such a poop head?” got converted to “Why are you such a **** head?”

Chat conversation with a word censored

Related posts