This post wants to convince you to try out creating a Twitter bot using Python Tweepy and AmazonAWS Lambda because it’s easy and fun. Of course, you can use any other utilities but Tweepy and AWS Lambda are the ones I tried. This is not a full tutorial but I can make one if anyone is interested.
Inspired by the #100DaysofDH challenge
In this post, I will just give you some basic Twitter knowledge, links for what you need to know to get it done and a link to the github of my #100DaysofDH challenge for which I implemented such a bot. If you want more guidance, please let me know.
Also, read the post on the challenge because I noted down some restrictions I realized the Twitter automation guidelines impose on bots as I went along. In my example, I think I’m in fact doing one or two things which you actually shouldn’t do (I think bots shouldn’t like posts or something, so I just made sure I only liked replies to my own posts since that won’t be many – but don’t do this in large quantities to avoid detection 😉 ).
You also can’t do polls either which I find mildly sad. The Twitter API is able to do that but it’s not open to the public nor does it seem that Twitter is willing to open it up (the issues on it were closed in 2018).
A short note on the Twitter algorithm
Beware that the Twitter algorithm boosts you when it thinks your posts are interesting. It measures “interest” in your posts in terms of interactions, i.e. the ratio between how many people saw it and how many interactions it got (likes, comments, retweets). It’s important to note here that it’s not about the total /absolute number of interactions but about the relative ratio of interactions. I.e. being retweeted by a bot will give you greater visibility but will not necessarily boost you if the bot’s audience is not interested in = interacting with your post! So getting as many views as possible (impressions) is not necessarily beneficial if your interactions can’t keep up with it because the views are not coming from the target audience interested in your content. You can boost your interactions by making polls or answering to all the answers to your tweets. However, this can’t be automated due to Twitter’s automation rules. Learn more about the strategy from the great channel
careerconverstaions (Twitter and Youtube).
The best way of getting lots of interactions and (real) followers is to create meaningful, valueable content that your audience likes and making sure you get your message out in a targeted way to exactly that audience you identified. This can be tricky. What you can do is, first of all, to get to know the relevant hashtags, i.e. some broader ones and some niche ones. Then use those to find people to follow which might be “your audience”, then like their posts, interact with them, etc. This can be done by leaving meaningful comments, i.e. starting a real discussion. It is likely then, if your interests acutually align, that they will follow you back and become the kind of audience which will boost your visibility because they interact with your content. This, however, while being a great overall Twitter strategy as pointed out by
careerconversations, is not really a strategy that works well for automation. You can, of course, realize parts of this in a bot – but I’m not sure how well it could go. I will experiment for my own accounts in the future and let you know (I’d like to automate some of the work which goes into maintaining my various channel’s Twitter presences and also maybe get more followers along the way).
What I’m trying to say with all of this is: Even though you have a Twitter bot, your content might not actually shown to a lot of people by Twitter. But I think making a bot is a fun experience (I created a bot for my #100DaysofDH challenge, even though I had to stop implementing all the features promised for a while due to time constraints, i.e. it’s not really finished…) and it doesn’t take long.
How to make your bot in 1 day or less
Check out the following resources for making one using Python Tweepy and Amazon AWS Lambda:
- Twitter Bot setup in 5min
- Great guide to writing your Twitter bot code using Python’s Tweepy
- Run your bot using Amazon AWS Lambda (though I myself used and loved another tutorial I now can’t find anymore). Make sure you increase the timeout limit from 3s to some more or lots of your functions won’t be run at all!
- This is how I did it for my bot although it currently isn’t fully functional – due to some non-sensical conditions I implemented because I felt like I needed to make things unnecessarily complicated – , so keep that in mind 😉 (I’ll try to update and correct it as soon as I can with all my other stuff going on…)
This is it for today. Let me know if you want to have a full tutorial on my bot (once I’ve cleaned up the code a bit). Twitter bots can be an option for science communication, so maybe also read my posts on quick and easy ideas for
#scicomm 😉 This could also be a project for learning to program or improving your programming skills which is why I added it to the “Learning to program” category. You can also make it part of a #100DaysofDH challenge 😉
Buy me coffee!
If my content has helped you, donate 3€ to buy me coffee. Thanks a lot, I appreciate it!