Introducing (and then farewelling) 🦅✈️🤖

With the changes made to Twitter (X) over the past six months, Bird Strike Bot stopped working. I’m going to leave the post here for its discussion on using ChatGPT to build a bot but I’m not sad about losing API access to Twitter. Not long after this, I decided to leave the platform completely.

Much of my excitement associated with ChatGPT came from my early experimentation and the “success” of our first actual project. I’ve posted a few times now about Python programming, and in December, it helped me take it to a new level.

‘Cause, we built a bot.

A Benevolent Bot

For the record, when our robot overlords take control, I would like them to know that I sought to use them for good, and I hope they will reciprocate.

Writing code to do a task, like analysing huge chunks of data, is cool, but automation is way cooler.

I did not change the name, I swear

My general goal was to write a Twitter bot that regularly posts information about bird strikes. I had tried to unlock the secrets of automating Python code and the Twitter API, but I found the documentation impenetrable and the online forums inscrutable. It was like they were in a secret club with their own secret language*.

A Friend Indeed

So, along comes ChatGPT, and it was like having a friend in the club.

I’ve already discussed much of this in my posts on fast-time simulation, but it was during this little project, I really learnt how to use my new friend. It was great. They would answer any inane question and provide example code in a flash. I could ask follow-up questions and seek to clarify things.

Building a Database

To feed the bot interesting information, I needed some data. To get started, I grabbed a copy of the latest version of the ATSB wildlife strike database and set about processing the data on a per-species basis. To give the bot some longevity, I wanted to have a lot of different statistics but all based on the same kind of thing. 

I could have pulled out stats for each year, but then I would only have ten things to post. I could have used some typical headline statistics (damaging strikes, strike rates, etc.), but this would have a limited life. I settled on species because there are many, and I could get away without repeating any statistics for over six months.

Using Python, I could build a new database where each species is listed with its key statistics. Things like the number of strikes, percentage of record strikes (with or without species known), damaging strikes, multiple individual strikes, and most common strike phase of flight.

I also used some code developed with the help of ChatGPT to identify the climate zone in which most strikes for each species occurred. That code processes some 8000 records in seconds. In addition, I wrote some code to grab photos of the wildlife from Wikipedia, but I’m yet to implement this (more on this tomorrow).

Building a Bot

The bot does a couple of things. 

Firstly, it picks a species at random from the database.

Then it sends a prompt to ChatGPT asking it to write a tweet introducing the species and calling on wildlife hazard managers to get to know it. This prompt is based on the number of strikes recorded for that species. It tweets this as the start of a seven-tweet thread (because they are all the rage at the moment).

The next several sections of code repeat this process of sending prompts to ChatGPT and then tweeting the response. Finally, it ends with a tweet letting the reader know that what they just read was AI-generated (and may contain some errors).

Deploying the Bot

Once I had this code working, I wanted to automate it. My birthday present from last year was a Raspberry Pi computer, which had been sitting in my drawer all year. It was time to get it working.

Again, thanks to ChatGPT, who walked me through the process, I set up my Raspberry Pi to automatically run the Python code once a day at a set time. And it has been pretty good at doing its job. I think the days it missed have involved some instability at Twitter’s end, so I don’t go too harsh on my little bot friend.

And here it was…

<<Twitter feed removed>>

Critical Review

I’m going to come back tomorrow and review the bot’s performance to date including ChatGPT’s input.

* They are; it involves training, competence and qualification

Header image: Tara Winstead (via Pexels)

Dan Parsons

Dan is an airport operations manager currently working at Queenstown Airport in beautiful New Zealand. His previous roles have included airport and non-process infrastructure operation manager in the mining industry, government inspector with the Civil Aviation Safety Authority and airport trainer. Dan’s special interests include risk management, leadership and process hacks to make running airports easier. 

http://therunwaycentreline.com
Previous
Previous

Critical Review of (what was) Bird Strike Bot

Next
Next

Friday Unfunny: The End is Nigh