This serverless app processes events from the aws-serverless-twitter-event-source serverless app, calls Amazon Comprehend to do sentiment analysis on the tweet text, and publishes the sentiment scores as custom metrics to Amazon CloudWatch Metrics.
This app was built during an AWS live coding session on Twitch.
- The aws-serverless-twitter-event-source app periodically invokes the TweetSentiment Lambda function to process tweet search results.
- The TweetSentiment Lambda calls Amazon Comprehend to get sentiment scores on the tweet text and then sends the scores as metrics to CloudWatch Metrics.
- Create an AWS account if you do not already have one and login
- Go to this app's page on the Serverless Application Repository and click "Deploy"
- Go to the AWS Lambda Console and note down the name of the TweetSentiment function that was created by the deployment.
The tweet-sentiment app uses the aws-serverless-twitter-event-source app as a source of Tweet data. So after deploying the tweet-sentiment app to your account, you need to install the aws-serverless-twitter-event-source app to send twitter events to the tweet-sentiment app.
Refer to the aws-serverless-twitter-event-source README for general installation steps. There are some parameter settings specific to this app:
TweetProcessorFunctionName
- This should be set to the name of the TweetSentiment function that you noted down when installing the tweet-sentiment app.BatchSize
- It's fine to use the aws-serverless-twitter-event-source default value of 15.SearchText
- This controls what tweets are pulled in for sentiment analysis. The search used during the live stream was#AWSLambda -filter:nativeretweets
. However, you can use whatever Twitter search you'd like to perform sentiment analysis on. Note, if you want to change the SearchText after deploying the app, you can always do this via the AWS Lambda Console by finding the TwitterSearchPoller lambda created by the aws-serverless-twitter-event-source app and changing itsSEARCH_TEXT
environment variable value.
This code is made available under the MIT license. See the LICENSE file.