If you want to moderate and filter message content as the data is streamed, PubNub Functions lets you add content moderation functionality into your PubNub Data Streams. This provides you with an easy way to automatically moderate and filter published messages before they reach end users.
You can select from a list of prebuilt Functions or build your own logic to restrict adult content on your application. Here are a few suggestions:
- PubNub's Profanity Filter replaces words (such as profanity) based on a dictionary of words before the message is delivered to users.
- Sift Ninja is an API that integrates with chat, comments, gaming, and other social applications. Sift Ninja analyzes and filters text based on certain risk levels, and can then automatically moderate, hash out profanity, or mark as NSFW, all fully customizable.
- Neutrino's Bad Word Filter API detects bad words, swear words, and profanity in given text, and censors it in a variety of different ways.
- Sightengine's image moderation API allows you to moderate and filter user-generated photos for adult content, validation, and photo type.
PubNub Profanity Filter Tutorial
The PubNub Profanity Filter lets you moderate chat messages in real time as they go over the PubNub Data Stream Network. The function detects objectionable words in any given text, and lets you censor the content in a variety of different ways.
Whenever a user publishes a message, the function processes the text for profanity, and can then either block the publishing of the post, or censors the specific words.
Setting up the PubNub Function
Click Try it Now on the PubNub Profanity Filter page to import the code directly into a new or existing project.
Set a channel to trigger the function. You can use wildcards (example
chat.*) to trigger the function on multiple channels.
Click Start Module to start the Function, and test it using the Publish button and payload on the left.
For a more detailed overview of writing a function, refer to these instructions on the Functions Overview page.
Publishing a message triggers the function to check the content of the message against a dictionary of objectionable words. The function allows you to either replace a part of the text with special characters or completely block the message.
Input: Publish a message on any channel with a text field included.
Output: If profanity is present in the original message text, the output message will have the profanity filtered.