When covid vaccine appointments were initially rolled out, they were difficult to book, requiring users to navigate confusing forms, refresh pages and pray for openings. To ease the frustration for nearby friends & family, I created a python script to automate the steps to find covid appointments. Things snowballed from there into this twitter bot. The bot ran for 3 months, generated 12,349 tweets, 106,353 clicks and cost $1.25/day.
TL;DR; I created a twitter bot to help people find available covid appointments, it served a purpose by minimizing the pain of finding appointments and maintaining accurate searches required constant maintenance.
The general business logic to find a covid appointment was relatively simple. Look for a covid appointment, collect available appointment data, then post a tweet if necessary.
Technical Notes
from sys import platform
prod = True if platform == "linux" else False # dev = my mac, prod = AWS
if prod == False:
<use mac libraries, see chrome windows>
elif prod == True:
<use EC2 libraries, headless chrome>
This tiny feature made my life much easier, so I’m pointing it out here. There was a constant need to debug scraping logic and this hack cut down the effort needed to deploy the many incremental updates.
state:
california: # Name of the state
santa_barbara: # Name of the county
costco: # Name of the clinic
twitter_name: "Costco" # Name to use in a tweet
status: "active" # Can be active/inactive
url: "https://book.appointment-plus.com/d133yng2/#/book-appointment/select-a-location?_qk=lbvsv9hv4u" # Target URL to begin a search
cuttly_url: "https://cutt.ly/0vwl8qL" # URL to use in a tweet
city: "santa_maria" # Name of city where clinic is located
data: # Information to help the selenium actions
id: 477 # Misc info needed for this particular clinic
selectEmployeeButton: 1097 # Misc info needed for this particular clinic
In this case we’re searching for a Costco clinic. A posted tweet would look something like…
¯\_(ツ)_/¯
Vaxstter Code
Vaxster code to manage the search logic + Helper code to manage Terraform & twitter…
Vaxster code
.
├── clinic.py Manages generic business logic
├── clinic_libs Collection of selenium scripts designed to navigate individual clinics
│ ├── __init__.py
│ ├── costco.py Selenium steps to check costco
│ ├── cvs.py Selenium steps to check cvs
│ ├── goleta_valley_cottage_frame.py Selenium steps to check a local hospital v1
│ ├── goleta_valley_cottage_v1.py Selenium steps to check a local hospital v2, needed after the hospital refactored some links
│ ├── mhealthcheckin_v1.py Selenium steps to check albertsons/ralphs/savon v1
│ ├── mhealthcheckin_v2.py Selenium steps to check albertsons/ralphs/savon v2, needed after mhealthcheckin refactored their UI
│ ├── santa_barbara_medcenter.py Selenium steps to check a local clinic in Santa Barbara
│ ├── slocounty_ca_gov.py Selenium steps to check San Luis Obispo
│ └── walgreens.py Selenium steps to check walgreens
├── config.yml YAML file for clinic information
├── county.py Manages counties, forks parallel selenium threads
├── requirements.txt
├── state.py Intended to manage multiple states but I never managed to move beyond California
└── vaxster.py Mostly reads YAML settings then kicks off states.py
Helper code
.
├── collect_stats.py Collect click stats from cutt.ly, post results to twitter
├── terraform
│ ├── main.tf
│ ├── outputs.tf
│ ├── provider.tf
│ ├── user_data.tpl Commands to set up a new EC2 instance: add AWS creds, install chrome driver, clone git repo, etc.
│ └── variables.tf
└── twitter_helper.py Create tweets using the twitter API
The evolution of clinic searches
Clinics went through some not so obvious changes over time, where demand and supply fluctuated dramatically. Here’s a brief description of how that went.
Maintenance
Maintenance was the biggest surprise. At best, every new clinic was a few lines in a YAML file. At worst, every new clinic was a new python class. To expand on that, here’s a generalization of the different types of clinics
Keeping searching running and able to deliver accurate appointment data was an ongoing chore. Part of me thinks the govt dropped the ball by not rolling out a nationwide covid appointment booking website, but that now seems like a near impossible task.
Lessons learned