I'm not very active on Twitter nowadays and I'm missing some important tweets that contain valuable information. I wanted to create something simple that would send me an email whenever one of my favorite accounts tweeted a thread, that way I wouldn't miss any important information shared by these accounts.
This is definitely not 'production ready' and it wasn't meant to be offered as a service. You can clone this repo and deploy it on AWS if you still want something like this. It's practically free to run this on AWS. More info below.
I coded it using Python and deployed it on AWS using Lambda, EventBridge, DynamoDB and SES. EventBridge was used to trigger the Lambda function every 6 hours.
I tried my best to write thorough instructions below, let me know if something doesn't make sense.
Note: Yeah I hate the nested for loops in lambda_function.py
too, but it's good enough for my use case.
- Clone this repository and navigate into it.
- Install the dependencies listed below using
pip3
- Change the list of usernames to the ones you'd like to monitor in the
lambda_function.py
file - Add Environment Variables in a
.env
file for Twitter (CONSUMER_KEY
,CONSUMER_SECRET
,ACCESS_TOKEN
,TOKEN_SECRET
,BEARER_TOKEN
) and Email (EMAIL_SENDER
,EMAIL_RECIPIENT
). - Create an AWS account if you don't have one and setup your access keys on your machine (more info)
- Run
python3 lambda_function.py
- Create a Lambda deployment package following the instructions here.
- Make sure to install all project dependencies on step 4
- Also add the
models/Thread.py
,email_template/email.css
andses_email.py
files in the zip file on step 6
- Create a new Lambda Function and upload zip using these instructions.
- Add the appropriate policies to the Lambda function IAM Role for DynamoDB and SES access. (more info)
- Change function timeout to ~30 seconds (or a longer time frame, depending on the number of Twitter users this script will go through). (more info)
- Add Environment Variables to your Lambda function for Twitter (
CONSUMER_KEY
,CONSUMER_SECRET
,ACCESS_TOKEN
,TOKEN_SECRET
,BEARER_TOKEN
) and Email (EMAIL_SENDER
,EMAIL_RECIPIENT
). - Test your Function! You should receive a few emails with threads from the accounts you specified in Step 3 of the previous segment.
- Create an EventBridge Trigger for your Lambda function and schedule it to run every 6 hours. (more info)
- Done! Things might break, sorry. Let me know if they do :)
- Python 3
- AWS Lambda
- AWS DynamoDB (NoSQL)
- AWS Simple Email Service
- AWS EventBridge