Word filter within n8n

Hi there! I am struggling with something I though you guys could help me with :slight_smile:
I want to send out tweets, but check them whether they are containing any profanity before. If so, I set the field containsProfanity to true, and consequently at an IF node it goes to a google sheet to record the message and details on a ‘naughty’ list.

My first solution was to use an API call of a free service, called purgomalum. But this is too buggy, things get filtered out that should not get filtered out (especially special characters).

Then I found this topic: Block offensive words when tweeting - #6 by jan
But this was just a bit too difficult for me. When I tried connecting it to a different node, it just told me that the ‘filter’ was not a json object (or something like that).

I am not really keen on copying my current workflow here, so hopefully this is fine. Something similar to the topic above would be great. The data comes from an API call → list (split out) → batch → (in here I want to detect and remove all profanity submissions to a google sheet) → IF (the if separates different data). Hopefully someone can help me! :slight_smile:

Thanks in advance

1 Like

Hi @bees8

What are you exactly stuck on? I might be reading it too fast/incorrectly, but it seems like you already have a solution you can use with the switch node.

The best way of explaining what you are stuck on is with an example. it can be a very much simplified example. Some example showing input and output and where you are stuck is very helpful.

1 Like

Hey Bram, thanks for the reply.

The api profanity filter was too buggy - text had to be included in the url, which made it go mad when using special characters.

Therefore I would like to use the solution that was mentioned in my link - but I do not know how as it is javascript (and I cannot code). This is what I would like the process to look like: The data comes from an API call → list (split out) → batch → (in here I want to detect and remove all profanity submissions to a google sheet) → IF (the if separates different data).

Thank you, I’ve just looked at the switch node. I guess that could work, but where do I put the list with words that are in the ‘blacklist’? So I would want to run data through the switch node, and if it contains a profanity word, it goes to a different node.

Thanks again!

Hi @bees8

The example from Jan is a bit outdated it seems.
Modified it for you:

Only need to add words here:

1 Like

Ah @BramKn, You got me by seconds…

1 Like

And we got basically the same rework. :sweat_smile:
That was quite unexpected

1 Like

@BramKn @Jon
YOU GUYS ARE AMAZING! It works!!
Thanks so much!!

2 Likes

hey guys @BramKn @Jon
It works great! except for the fact that it also bans words like ‘associate’ and ‘assesment’ - you know what I mean :sweat_smile:
Is there a piece of code to add that looks for an exact match instead of partial? thanks!

Only real option for that is to use regex I think.
If I have time tomorrow I will modify the example for you.

much appreciated! :slight_smile:

3 Likes

awesome, thanks so much!

1 Like