Bots have always been something that’s caught my attention, but I had always assumed they were much to complicated to make myself. This project opened my eyes to the possibilities, and showed me how its possible to make bots, with minimal effort.


  • Mini HDMI Cord
  • USB-C Power Cord
  • Cooling system / Fan
  • Keyboard
  • Mouse
  • Raspberry PI 4
  • Desktop / Laptop
  • Micro SD Card




Creating this Twitter Bot, I had very little clue of how I was going to get it working. My first step was looking on YouTube for a tutorial, after a bit of searching I came across a tutorial, which I would later realize was outdated, since the Twitter API (Tweepy) was constantly changing and updating, this would become a theme throughout the making of this bot.

Despite this I was able to create a Twitter Development Account, after typing a 250 character word explanation on what I would be using this account for, I was able to grab the correct API Key’s to authenticate my Bot.

Once an up to date tutorial was found on the code itself, the struggle was to get it to work, after troubleshooting for a few hours, I decided the best step would to eliminate the possible of the Raspberry PI itself being an issue, and tested the same code ran on my PI, on my PC. It would work fine without issue on the PC.

Realizing the Raspberry PI was running on a very outdated version of Python (Python2), I began going through the hassle of updating it, luckily I found an informative tutorial that was able to get me through it. With the PI overheating once or twice, Python3 was installed. After getting the system to default to using Python3, instead of Python2, I was able to install Tweepy V.4.14.0 and get the Tweet to finally send through.

My original idea for the bots actual functionality was to be a joke bot, that would post a funny joke everyday, I decided to go with that idea and create a “Mad Libs Bot”. Predetermining 7 animals, and 7 actions, I would randomize a number and come out with a sentence like this “Did you know a pig can pinch a chicken 25221 times?”. This would then go through each and every day and print a different combination of words!


#Add the needed imports
import random
import tweepy
from time import *
from random import *

# Each key is used to authenticate with Twitter
API_KEY = ‘ ‘

# Create the client instance with the correct credentials

# Authenticate in order to use the API
auth = tweepy.OAuthHandler(API_KEY, API_KEY_SECRET)
auth.set_access_token(ACCESS_KEY, ACCESS_KEY_SECRET)

api = tweepy.API(auth)

# Create a list of different words and such
animalList = [ ‘dog’, ‘cat’, ‘pig’, ‘cow’, ‘chicken’, ‘donkey’, ‘airplane’, ‘t-rex’, ‘rooster’, ‘alligator’, ‘sloth’ ]
actionList = [ ‘jump’, ‘pinch’, ‘throw’, ‘hug’, ‘catch’, ‘record’ ]

while True: 

    # Randomize different elements of our twee

numberAnimal1 = randint(0, len(animalList ) – 1)
    numberAnimal2 = randint(0, len(animalList) – 1)
    numberAction = randint(0, len(actionList) – 1)
    number = randint(10000, 30000)

    # Create the final tweet, and tweet it!
    message = ‘Did you know a ‘ + animalList[numberAnimal1] + ‘ can ‘ +           actionList[numberAction] + ‘ a ‘ + animalList[numberAnimal2] + ‘ ‘ + str(number) + ‘


    client.create_tweet(text = message)

    # Wait a day before posting another Tweet
    sleep(60 * 60 * 60 * 24)


This was by far on of my favorite projects I’ve gotten to work on. This project has really opened up a lot of different possibilities for me in terms of creating bots with even the Raspberry PI itself. The most annoying part of this project was by far getting everything up to date on the PI, but overall it was very fun to work on!

Categories: Raspberry Pi


Leave a Reply

Avatar placeholder

Your email address will not be published. Required fields are marked *