Using ChatGPT to help write scripts

Each month I artisanally handcraft a newsletter for A month ago I decided to see what parts of that process I could automate using ChatGPT

Using ChatGPT to help write scripts
Photo by SwapnIl Dwivedi / Unsplash

Each month I artisanally handcraft a newsletter for In it, I summarize upcoming conferences and workshops, calls for participation and discounts. I put pressure on myself to deliver them consistently since they are sponsored.

Creating the newsletters is difficult. It takes hours to pull out the information, check to make sure it’s up to date and then format it for MailChimp. (That’s why I refer to them as "artisanally handcrafted".)

A month ago I decided to see what parts of that process I could automate. The script wouldn't need to do everything I do, only help do a few things.

This is roughly what I do:

  1. Open _data/current.yml
  2. Grab the data for the conferences in the newsletter (e.g. all events in July, August, September)
  3. Grab the data for any events with a status of CFP
  4. Grab the data for any events with a status of discounts (Early Bird, Super Early Bird, etc)
  5. Copy all that data and paste it into many sheets in Visual Studio Code
  6. Start to remove all the yaml formatting → remove quotes, dashes, keys, and upper case a few words
  7. Remove the twitter data
  8. Check each link to make sure the data is up to date. When it isn’t, update it and push the updates forward
  9. Copy the name, date, location, status and URL and paste into the sections of the newsletter based on month and/or status. Hope Mailchimp doesn’t crash in the process

I haven’t written Ruby for a long time but is written in it. This seemed like a good use case for GPT by OpenAI. I'd break down what I need the script to do, GPT would compose it and then I would test and iterate on it.

A Quick Script

I shared a partial current.yml file with ChatGPT to provide context. I asked it to create a ruby script that would iterate through the key:value pairs and delete the rows with twitter data in it. Great, that worked right away and it only took a few minutes.

Next, I want the script to locate the monthly data I need. I asked ChatGPT to update the script so it asks me for a month, finds all events with a matching month and writes them to a separate text file.

In about 30 minutes I was able to create a script that handles items 1, 2, 7 and part of 6. (I have the script removing quotes from the date field. More to do with that going forward.) Each time ChatGPT would spit something out, I would test it. There were small problems but nothing I couldn’t fix.

This is the code it generated (albeit with a few changes for myself):

require 'yaml'

yaml_data ='../_data/current.yml')
conferences = YAML.safe_load(yaml_data)

print 'Enter the month: '
input_month = gets.chomp.downcase

filename = input_month + '_conferences.txt'

filtered_conferences = do |conference|
  dates = conference['dates']
  next false unless dates.is_a?(String)

  month = dates.split(' ')[0]
  month.downcase == input_month

filtered_conferences.each { |conference| conference.delete('twitter') }

modified_yaml_data = YAML.dump(filtered_conferences)

File.write(filename, modified_yaml_data)

puts "Output saved to #{filename}"


After this script worked, I wrote a second to handle items 3 and 4. It took roughly an hour to create some tools to help reduce the amount of time I spend on a regular task.

The Value

It would have taken a lot longer for me to figure out how to import, decode and re-encode yaml on my own. Even though I had to correct obvious bugs, ChatGPT added a lot of value.

We often get sold a storyline of automation replacing the work of a human. However, this is a good example of the power of AI helping extend capabilities. There’s a lot to be gained by professionals who can leverage these tools effectively.

Did you know is an open-source project that anyone can contribute to? If you are looking to get involved in the project, it’s pretty easy to update the list of conferences. This makes it an easy introduction to using git, GitHub and making changes.

Subscribe to Chris Kenst

Sign up now to get access to the library of members-only issues.
Jamie Larson