Accelerate the value of multicloud with collaborative DevSecOps Learn more

Build a chatbot moderator for anger detection, natural language understanding, and removal of explicit images


Learn how to build a chatbot that monitors for angry or inappropriate messages and explicit images. This code pattern explains how you can build a monitoring chatbot that you can then use in a chat room like Slack or a website that allows reviews.


Rude behavior. Angry or inappropriate messages. Explicit images. All of these things are used daily in social media platforms. So how can you filter out these issues? By building a chatbot that monitors messages and images. You can use this monitoring in a chat room like Slack or a website that allows reviews, and it can remove explicit images or inappropriate text.

In this code pattern, you’ll create a chatbot that uses IBM® Cloud Functions and Watson™ services. The chatbot flow is enhanced by using Watson Visual Recognition and Watson Natural Language Understanding to identify and remove explicit images and detect angry and inappropriate messages.

When you have completed this code pattern, you will understand how to:

  • Create a chatbot that integrates with Slack through IBM Cloud Functions
  • Use Watson Visual Recognition to detect explicit images (in beta)
  • Use Watson Natural Understanding to detect emotions in a conversation
  • Identify entities with Watson Natural Language Understanding



  1. The user interacts with the Slack app and either sends a text or uploads an image.
  2. A bot passes the text or image used in Slack to an IBM Cloud Functions API. The API is a call to an IBM Function that categorizes the text or images based on the response of Watson Visual Recognition or Watson Natural Language Processing.
  3. Watson Visual Recognition categorizes the uploaded image using the default and explicit classifiers.
  4. Watson Natural Language Processing categorizes the text if text is sent as part of the Slack communication.
  5. IBM Cloud Functions receives the response, and if the text is not polite, the bot sends a message to the Slack user to be more polite using the Slack post message API. If an image that is considered explicit is used, the image is deleted by IBM Cloud Functions using the Slack files delete API.


Get the detailed instructions in the README file. These steps explain how to:

  1. Clone the GitHub repo.
  2. Create Watson Visual Recognition and Natural Language Understanding services with IBM Cloud.
  3. Create the Slack app and bot for a workspace.
  4. Deploy the function to IBM Cloud.
  5. Test using Slack.