I have been wanting to get my feet wet with extensions for a while and this was a really fun experience. I thought it would be fun to try to build an at-a-glance twitch chat analysis tool for streamers and viewers alike to see the general mood of a chat.

What it does

In essence the application is a chat monitor that performs analysis using some javascript and the AWS Comprehend NLP engine. The once the streamer has the extension open, it will begin to read chat, submitting 2 minutes for processing. Once results are received, the extension will show:

Sentiment Analysis Using Comprehend, the overall sentiment of the last 2 minutes of chat. The UI shows an emoji consistent with the chat sentiment and some text on the sentiment return. As a note, emojis are excluded from analysis as they may skew the results. Under the simple at a glance sentiment there is a small line graph showing the sentiment of the session in relation of positive sentiment score, the higher the point, the more positive the chat was, this can be expanded in future iterations.

Profanity Percentage This card will show the simple percentage of lines that contained profanity. Again, emotes are excluded from this list to avoid skew. Unlike sentiment analysis this is a running percentage for the session. The anaysis is a regex filter that looks for common 'bad words' and makes the occurrence per line. The measurement is the percentage of chat messages containing at least one bad word.

Repeated Lines This simple comparison is also a running percentage of the number of repeated lines in a segment. Emotes excluded again this is a very simple text comparison. In future iterations I would hope to be able to take advantage of a better (and cheaper :)) text analysis tool to better compare text lines for similarity.

Emote Spam This simple calculation shows the percentage of chat lines that were emote only and contained more than one emote. No hard calculations here as I am able to grab the emote tags to determine if emotes are present and how many and this becomes my counter.

How I built it

The front end of the extension is built using react. There are 2 main views for the application, the broadcaster's live dashboard and the panel portion of the channel page. On the dashboard the view will execute the polling of the broadcaster's chat and will submit collected chat lines every 2 minutes. The analysis of the chat is centralized to a lambda endpoint that is hit with a POST request. This endpoint will first verify the JWT of the caller and then break off into the 3 major analysis threads. The sentiment analysis is an API call to Amazon Comprehend with an array of chat lines with emotes redacted. Additionally, there are 2 node functions that will complete the analysis for profanity and repeated lines. Once all 3 have completed, the lambda will broadcast a pub/sub message to all connected clients. Once the clients receive the messages, they will update the UI to reflect the information. Another note is that the dashboard will persist the information for the session, meaning if a client comes into the stream late, they will still receive the most recent information, thus keeping all clients in sync. The analysis data points are also kept in DynamoDB for future analysis and trending tools for streamers.

Challenges I ran into

Getting up and running with the developer rig was somewhat challenging as this was my first foray into the tool. After some getting used to, it turned out to be a great resource. I had worked with Lambda and AWS quite a bit in the past but working with the comprehend API was another learning experience with this project. The biggest challenges I ran into were performance at scale. I wanted to make sure my pack size and response sizes were small so this could scale up. I made some major architectural adjustments to account for performance as well as some potential issues with pub/sub limitations.

Accomplishments that I'm proud of

In all honesty just having an extension that is functional and does remotely what I set out to do is something I am very proud of. This was a 'nights and weekends' project for me and I loved working on it and learning about extension development.

What I learned

I learned a ton about twitch extensions in general as well as some of the inner workings of amazon machine learning APIs. I learned about the twitch API and how twitch's JWT validation works. There was also a good amount of performance tuning and webpack config fun that was a good experience.

What's next for FeelsChat

In the short term I would like to expand some of the available information including potential new measures of chat. As mentioned earlier, I would like to expand the text matching capability as well as to add some information around key words and phrases. Finally, trending over time is something I am very keen to expand. To be able to show streamers the change in sentiment (and other factors) in response to game changes, raids, hosts, etc.

Built With

+ 50 more
Share this project: