PubNub Sentiment Machine: Real-time Tweet Analysis

1 min readOct 23, 2018

People tweet a lot. And lots of people tweet about things they feel passionately about. It’s easy to sift through a Twitter feed to look at how one person is feeling about a subject. But what about how everyone feels about a subject? That’s a little harder to do.

At PubNub, we sought out the best way to do this analysis at the scale of Twitter. In other words, we wanted to consume the Twitter firehose, filter tweets by subject, analyze the sentiment (emotion), and visualize it on a real-time dashboard.

That’s exactly what we did with our Sentiment Analysis Machine. And the first thing we want to measure is the 2018 Midterms.

To test our machine, we chose to analyze the most polarizing upcoming event we could think of – the 2018 Midterms. The machine tracks dozens of keywords like Midterms, #election, redwave, bluewave, Cruz, Beto, and gauges each Tweet on a scale of 😠to 😁.

How Does It Work?

Sentiment-Machine-Diagram

The application itself is truly real-time, and all processing and analysis, from firehose to dashboard, takes under a second. All messaging runs through PubNub.

  • The PubNub Twitter Firehose pipes in 50 Tweets per second, which are filtered by keywords.
  • Tweets that match one of our selected keywords are processed through the Amazon Comprehend Block, which serverlessly gauges the sentiment of the Tweet.
  • Results are sent in real time to the live-visualization dashboard, powered by Initial State.

Want to check out the code? The full GitHub repo is available here.

More from PubNub

How to Create a Dating App: 7 Steps to Fit Any Design
Insights6 minMar 15, 2023

How to Create a Dating App: 7 Steps to Fit Any Design

There are common underlying technologies for a dating app, and in this post, we’ll talk about the major technologies and designs...

Michael Carroll

Michael Carroll

How to Create a Real-time Public Transportation Schedule App
Build6 minMar 14, 2023

How to Create a Real-time Public Transportation Schedule App

How to use geohashing, JavaScript, Google Maps API, and BART API to build a real-time public transit schedule app.

Michael Carroll

Michael Carroll

How to Create Real-Time Vehicle Location Tracking App
Build2 minMar 9, 2023

How to Create Real-Time Vehicle Location Tracking App

How to track and stream real-time vehicle location on a live-updating map using EON, JavaScript, and the Mapbox API.

Michael Carroll

Michael Carroll

Talk to an expert