How to filter your content in real-time with the Sift Ninja API and Flybase

If you have an app that involves letting users enter content of any kind, regardless if it’s chat, discussion boards, or a social site, you want to have the ability to filter content to make sure it is appropriate.

Sift Ninja provides a handy API that does just that, and combined with Flybase, you can offer real-time content checking before posting it anywhere.

Getting Started

To get started, you’ll need two things:

  1. A Sift Ninja account, sign up here if you don’t already have one.
  2. A Flybase account, sign up here if you don’t already have one.

Setting up Sift Ninja

When you set up your Sift Ninja account, you’ll be asked to create a custom channel, name it whatever you want. This will then give you a unique URL as well as your API key.

Setting up Flybase

Inside your Flybase account, create an app called siftninja, you’ll want that and your API key.

Setting up our Node app.

Our node app is going to be really simple, from your terminal type:

$ npm init
$ npm install --save finalhandler flybase siftninja serve-static

This will install the node modules we need for our app.

The backend

Create a file called index.js, which will contain a Flybase listener to check content entered on our chat page:

This will create a custom event listener called check_content, which will check the message for any inapproriate text and return the results back to our frontend app.

If response was true, then the text was ok, and we save it to our Flybase app, and thus let it appear in the chat window.

If the response was false, then there was a problem with the text and we notify the user who entered it and do not save it. We’ll pass a unique session id for the user, which lets us respond to that user without notifying all other users.

The Frontend

Create a folder called public and inside that folder, create a file called index.html:

We’ve kept this app simple, when the user hits the enter key on their text it sends an event to our backend via Flybase and then listens for a reply.

We assign our chat users a unique session ID that follows them for the life of that browser session, this then lets us add a unique listening event called results_<SESSIONKEY> that we can use to pass any issues we’ve found directly back to that user.

Finishing Up

You can see the original repo here.

Feel free to expand on what this can do, as Sift Ninja is a handy tool to have in your arsenal and the guys behind it are solid in this area, and combining it with Flybase’s real-time events lets you check content entered in real-time before saving it to your database or forwarding it to other users.

Ready To Build Awesome Apps?
Get started for free