How this engineer built a sentiment analysis bot with IBM Watson and Raspberry Pi
Have you ever wondered how your teammates perceive your Slack chat messages? Maybe you sound heroic, unpleasant, or perhaps you just project harsh undertones you haven’t even noticed!
Imagine a robot that can analyze your written communications and message tone, “reading” the emotion of each posted message. Now, stop imagining because I’ve created one using IBM Watson.
In this article, I’ll share how I created the bot.
First, I’ll show you how to use the Events API to capture messages, send them to IBM Watson for analysis, and then post the result using chat.postMessage.
Then, I will present a totally optional but fun exercise! We will port our bot to a Raspberry Pi and reflect emotions using colors produced by an RGB LED.
The source code is available on GitHub. 🐙🐱
Before starting this project
This project uses Node.js, so make sure it’s installed on your machine. You’ll also need to add the Watson Tone Analyzer and have an IBM Bluemix account. Your service credentials will be required later.
If you also want to build a physical Raspberry Pi bot that shows the results with color LEDs, you’ll need some affordable hack-friendly hardware. You can either buy the IBM TJBot Kit that includes the cardboard robot or prepare the following separately:
- One Raspberry Pi 3 (if you are using Pi 2, you’ll need a wifi dongle)
- One NeoPixel RGB LED
- Three female-female jumper wires
You need to install the latest Raspbian OS, connect to a wifi connection, and update and upgrade the system. See this website for additional instructions.
Building a sentiment analysis bot
Now, let’s build a Slack bot that reads messages and analyzes emotional content!
Here’s our bot’s workflow:
- Read each message on a channel
- Send the message to IBM Watson for examination
- If the likelihood of an emotion is above the given confidence threshold, post the most prominent emotion to the Slack channel
Creating and configuring your Slack app
First, let’s create a new app here. Fill out the app name and choose a Slack team that you are allowed to develop apps on:
Making the Bot into a physical bot with Raspberry Pi
Stay updated on the go with our mobile app.
Get latest insights with smoother, more personalized experience through TIA mobile app.






