Image for post
Image for post
“This is Tina.” http://redd.it/ctj32b #aww

How to make a Twitter cuteness bot.

The easy way and the hard way.

Kevin McElwee
Aug 25, 2019 · 3 min read

The “aww” subreddit is arguably the cuteness singularity of the internet. With more than 20 million members, usually tens of thousands of users judge the cuteness of every post. We can leverage Twitter and Reddit’s developer APIs to share the best content of r/aww to Twitter.

How it works.

The bot requests the top five posts on r/aww’s “hot” tab. If the content has not been tweeted before, then it properly formats the content and posts to Twitter. Here’s a flowchart that breaks down how the code functions.

Image for post
Image for post
reddit_says_aww.py flowchart

Uploading media to Twitter through the API can get complicated. For this reason, the bot only handles images and gifs, not videos, at least for now. If the content is hosted on imgur or gfycat, then Twitter will automatically load a preview, so instead of uploading the media, we can simply post the link. Reddit’s video, however, is not supported in Twitter’s embed system, so the bot must miss some cute videos. There are many exceptions and if statements used to handle how different file formats are uploaded. Another exception to consider is the Twitter character limit. If Reddit titles exceed the twitter count, there’s a function to shorten the title and add ellipses.

UPDATE: This bot used to rely on Heroku, but it has now migrated to GitHub Actions, a free alternative. More information is available here to set up a bot with one’s own configuration. This allows for anyone to quickly deploy their own Reddit-to-Twitter bot without ever having to leave GitHub!

Why simpler methods won’t work too well.


Questions? Comments? Puppy photos? Contact me and see more projects on my website.

The Startup

Medium's largest active publication, followed by +708K people. Follow to join our community.

Kevin McElwee

Written by

🏳️‍🌈 Machine learning engineer and data journalist. Learn about me and my projects at www.BrownAnalytics.com

The Startup

Medium's largest active publication, followed by +708K people. Follow to join our community.

Kevin McElwee

Written by

🏳️‍🌈 Machine learning engineer and data journalist. Learn about me and my projects at www.BrownAnalytics.com

The Startup

Medium's largest active publication, followed by +708K people. Follow to join our community.

Welcome to a place where words matter. On Medium, smart voices and original ideas take center stage - with no ads in sight. Watch

Follow all the topics you care about, and we’ll deliver the best stories for you to your homepage and inbox. Explore

Get unlimited access to the best stories on Medium — and support writers while you’re at it. Just $5/month. Upgrade

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store