Writing a Twitter bot has been one of those projects that I have wanted to do for years, but I had not had an idea for what the bot should do. Then I was sent a link to onewayroadtobeer.com and I thought I could do a countdown to what I am most looking forward to after lockdown ends – riding bikes with my friends!
The next step of the plan was easy, as an AWS Certified Cloud Practitioner I knew that Lambda is the right environment for running a small task once a day. In my previous Lambda projects, such as Automatically Deploying Website from Git to AWS S3, I have used the Python programming language, so opted for that again. From there it did not take me long to find Dylan Castillo’s excellent tutorial and GitHub repository for a Python Twitter bot on AWS Lambda. If anything it was too helpful, but it did force me to try writing the Python code on my Mac, rather than direct into the Lambda console on AWS, as I had done previously. This made it much easier to test/debug my changes to the code.
The changes were pretty minimal, instead of pulling the tweet from a file, the get_tweet
function, compares the current date to the lifting of restrictions as defined in the government’s “Roadmap out of lockdown”, which I have hard coded for now. Hopefully the goalposts will not be moved too much! After a small tweak to change “in 1 day we will be able…” to “tomorrow we will be able…” the bot was ready to deploy. So far it has been tweeting out its daily message at 9:00 each morning, giving me a sense of pride whenever I see it in my Twitter feed. As well as building up the excitement for being able to ride with my friends – only 14 days to go!!!
You can follow the bot at @untilweride and if you are not already following me, my organic tweets are at @lewiscraik. If you want to to deploy a bot of your own, my project is on GitHub.