How to handle profanity inputs in Dialogflow ES
I got this question from a student:
I need your help in one of the logic. How to handle profanity inputs in the dialogflow es in the best way. Can you suggest some best approaches.
Here is one way to do it.
Declare an entityBoth Dialogflow ES and Dialogflow CX support entities and th... More with a list of profane words. I will use some fairly mild words for this example.
Create an intentBoth Dialogflow ES and Dialogflow CX have the concept of int... More to handle the profane input.
The key is to use the wildcard entity to create training phrases to handle any word/phrase appearing before and after the profane term.
The training phrase below handles random input before the profane word
Handle any word or phrase after the profane term:
Handle profane word alone:
Handle random phrase before and after the profane word:
Add a suitable response message:
Now test it:
This will usually handle all the profane words that you have already listed in the entity, but it will miss the ones which you did not add to the list.
Occasionally, you might also run into false positives where the user inputs a single profane word as part of a genuine intent.
Note: This is my old website and is in maintenance mode. I am publishing new articles only on my new website.
If you are not sure where to start on my new website, I recommend the following article:
Is Dialogflow still relevant in the era of Large Language Models?