Tired of ads? Enjoy an ad-free experience by signing up.
Tomomi Imura · · 11 min read

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:

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:

  1. Read each message on a channel
  2. Send the message to IBM Watson for examination
  3. 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 ahead in Asia’s tech landscape

You've reached your 2 free content limit for the month. Sign up for free to read the full story.

🏄 For casual readers / 👶 Free

Basic

US$0

Free forever

Get instant access to this article and more every month

0 premium content

Unlimited news briefs

5

5 articles

Ad-free reading experience

Just US$0 per day

⌛Sign up in 20s. No payment details needed.

📖 For learners / 👍 Starter

Lite

US$4.92/month

Billed annually at US$59/year

Get instant access to this article and more every month

4

4 premium content

Unlimited news briefs & articles

Ad-free reading experience

Just US$0.17 per day

Cancel anytime

Our subscriber community includes professionals from these companies:

Stay updated on the go with our mobile app.

Get latest insights with smoother, more personalized experience through TIA mobile app.

Community Writer

Tomomi Imura

Tomomi Imura (a.k.a girlie_mac) is an avid open web & open technology advocate, and a creative technologist, who is currently working at Slack in San Francisco. When she is not at work, she still geeks around and tries to combine technology with cats- her past projects include HTTP Status Cats, and Raspberry Pi Cat Camera.