I used ChatGPT to build my first Twitter bot

Chris Emmett
4 min readJan 9, 2023

Like many others, the release of ChatGPT immediately blew my mind. It’s writing ability is certainly powerful, but I’m still most impressed by it’s ability to write and debug code. I decided to put ChatGPT to the test by helping me write a Twitter bot.

The Idea

I originally had some pretty ambitious ideas for what I wanted this Twitter bot to do. My first idea was to have it track what a specific set of users are tweeting, and quote tweet them if they tweeted a specific phrase (being vague here in case I want to try it later). I realized that since this is my first Twitter bot and first time using ChatGPT to ship code, I should probably aim for something easier. I decided on a bot that tweets once a day, announcing how many days are left until my school, Ohio State, has their next football game.

Prompting ChatGPT

Not knowing much about what goes into a Twitter bot, I simply asked ChatGPT to “Write me the Python code for a Twitter bot”. I knew enough about Python to tell that it was importing a Python library called ‘Tweepy’ and that I was going to have to authenticate the bot with credentials from the Twitter API. I set up my Twitter developer account and started glancing over the Tweepy documentation.

A ChatGPT prompt asking for the Python code of a Twitter bot, followed by the beginning of ChatGPT’s response.

Writing the code

--

--

Chris Emmett
0 Followers

Thoughts on entrepreneurship, engineering, urbanism, etc.