Skip to main content

Draft: Making a Twitter bot

Update 17.3.2023: The post is out of date, because of Twitter's changed API policies.

I wanted to make a bot that would tweet energy saving tips. The idea was for it to be a part of Finland's national campaign aimed at citizens to reduce energy consumption for the coming winter.

Rough steps of what I did:

  1. Create a gmail account for the bot.
  2. Make a Twitter account for the bot.
  3. Apply for Twitter's developer account.
    • Go through hoops of getting rights to read and write statuses, and API keys.
  4. Make a prototype:
    1. Make a Google Sheets document that works as a tweet database.
    2. Write Python script that fetches and posts statuses (manually).
  5. Get Google Sheets API, so your script can access the sheet.
  6. Move the Python script to Google Cloud.
  7. Automate the Python script with Google Scheduler.
  8. Get the bot running! Check out @energiarobotti.

By the way, I pretty much followed Aaron Jack's Twitter bot building video. It's a bit outdated, but it helps a lot. The sad thing is that he didn't show how to get the developer account for Twitter working. It's the most complicated part of the whole project.

Make it open source

Note that "open source" in this case means making the Sheet (content in Finnish) and the code available (without showing the API keys!). Contributing to the Sheet or code is not possible at the moment.

It is especially important to state your sources when giving advice that impacts people's wellbeing. It also drives you to make better.