How to Set up a Twitter Bot with Python and Heroku

Emily Cain (@data_bae) on June 24, 2018

I just set up a Twitter bot to generate pharmaceutical ads and tweet them out a few times a day. (Source code here). I ended up piecing together ... [Read Full]
markdown guide

Can you elaborate? What step are you on? What have you done so far?


The code on my GitHub is the most recent version.

What happens when you try to run it in the command line (commenting out the env variable loading and uncommenting the import from constants)?


Heroku plus uptime or cronjob can help you automate the bot. My bot is up and running @ My blog post below has more details.


I recently tried following this article to set up a twitter bot that replies with sentiment analysis of whatever user the person requests. Currently the bot works and runs through terminal but is not doing anything once deployed in heroku. If someone is willing to take a look at what I have so far and give feedback would be greatly appreciated. The github link below has my heroku bot folder


Hi, I just followed your guide and pushed everything successfully, but nothing is happening. How can I tell if my bot is running properly? I have print() statements that I should be seeing in the logs. The bot builds correctly its just nothing happens. Does it run automatically, or do I have to do something to run it?


I just saw you have a Twitter account hooked up to it? Is it publishing tweets?


You can also use heroku scheduler without setting up a web app. Just set it up to run python at your desired interval.


Good post! I did the same for a bot I just rewrote (@linuxsecbot). I was about to setup flask when I saw that Heroku supports scheduled tasks. With python is done with APScheduler. Thanks for posting!


Good job. I've been looking for such a solution to run my code other than my local machine. Thnx Emily!

code of conduct - report abuse